From 2483dce9412c80b28bd4788cc3fb8d4c4470cefa Mon Sep 17 00:00:00 2001 From: Nicolas Giard Date: Tue, 28 Aug 2018 00:23:05 -0400 Subject: [PATCH] feat: dev docker-compose --- dev/docker/Dockerfile | 19 +++++--- dev/docker/config.yml | 16 +++++++ dev/examples/Dockerfile | 12 +++++ dev/{docker => examples}/docker-compose.yml | 0 docker-compose.yml | 50 +++++++++++++++++++++ server/core/config.js | 4 ++ 6 files changed, 95 insertions(+), 6 deletions(-) create mode 100644 dev/docker/config.yml create mode 100644 dev/examples/Dockerfile rename dev/{docker => examples}/docker-compose.yml (100%) create mode 100644 docker-compose.yml diff --git a/dev/docker/Dockerfile b/dev/docker/Dockerfile index 34b22f9c..52db8e0a 100644 --- a/dev/docker/Dockerfile +++ b/dev/docker/Dockerfile @@ -1,12 +1,19 @@ -FROM requarks/wiki:latest +# -- DEV DOCKERFILE -- +# -- DO NOT USE IN PRODUCTION! -- -# Replace with your email address: -ENV WIKI_ADMIN_EMAIL admin@example.com +FROM node:8-alpine +LABEL maintainer "requarks.io" + +RUN apk update && \ + apk add bash curl git python make g++ --no-cache && \ + mkdir -p /var/wiki WORKDIR /var/wiki +COPY package.json . +RUN yarn --silent -# Replace your-config.yml with the path to your config file: -ADD your-config.yml config.yml +ENV dockerdev 1 EXPOSE 3000 -ENTRYPOINT [ "node", "server" ] + +CMD ["tail", "-f", "/dev/null"] diff --git a/dev/docker/config.yml b/dev/docker/config.yml new file mode 100644 index 00000000..a35c3b4f --- /dev/null +++ b/dev/docker/config.yml @@ -0,0 +1,16 @@ +port: 3000 +paths: + content: ./content + data: ./data +db: + type: postgres + host: db + port: 5432 + user: wikijs + pass: wikijsrocks + db: wiki +redis: + host: redis + port: 6379 + db: 0 +logLevel: info diff --git a/dev/examples/Dockerfile b/dev/examples/Dockerfile new file mode 100644 index 00000000..34b22f9c --- /dev/null +++ b/dev/examples/Dockerfile @@ -0,0 +1,12 @@ +FROM requarks/wiki:latest + +# Replace with your email address: +ENV WIKI_ADMIN_EMAIL admin@example.com + +WORKDIR /var/wiki + +# Replace your-config.yml with the path to your config file: +ADD your-config.yml config.yml + +EXPOSE 3000 +ENTRYPOINT [ "node", "server" ] diff --git a/dev/docker/docker-compose.yml b/dev/examples/docker-compose.yml similarity index 100% rename from dev/docker/docker-compose.yml rename to dev/examples/docker-compose.yml diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 00000000..6439372a --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,50 @@ +# -- DEV DOCKER-COMPOSE -- +# -- DO NOT USE IN PRODUCTION! -- + +version: "3" +services: + + redis: + image: redis:4-alpine + ports: + - "16379:6379" + logging: + driver: "none" + networks: + - wikinet + + db: + image: postgres:9-alpine + environment: + POSTGRES_DB: wiki + POSTGRES_PASSWORD: wikijsrocks + POSTGRES_USER: wikijs + logging: + driver: "none" + volumes: + - db-data:/var/lib/postgresql/data + networks: + - wikinet + ports: + - "15432:5432" + + wiki: + build: + context: . + dockerfile: dev/docker/Dockerfile + depends_on: + - db + - redis + networks: + - wikinet + ports: + - "3000:3000" + volumes: + - .:/var/wiki + - /var/wiki/node_modules + +networks: + wikinet: + +volumes: + db-data: diff --git a/server/core/config.js b/server/core/config.js index 3aeb4b87..e45b7e8b 100644 --- a/server/core/config.js +++ b/server/core/config.js @@ -18,6 +18,10 @@ module.exports = { dataRegex: path.join(WIKI.SERVERPATH, 'app/regex.js') } + if (process.env.dockerdev) { + confPaths.config = path.join(WIKI.ROOTPATH, 'dev/docker/config.yml') + } + process.stdout.write(chalk.blue(`Loading configuration from ${confPaths.config}... `)) let appconfig = {}