Docker config directory as volume
authorChocobozzz <me@florianbigard.com>
Mon, 7 May 2018 16:39:42 +0000 (18:39 +0200)
committerChocobozzz <me@florianbigard.com>
Mon, 7 May 2018 16:41:10 +0000 (18:41 +0200)
.gitignore
support/doc/docker.md
support/docker/production/Dockerfile.stretch
support/docker/production/config/custom-environment-variables.yaml
support/docker/production/docker-compose.yml
support/docker/production/docker-entrypoint.sh
support/docker/production/swarm-stack.sample.yml [deleted file]

index bc0756609b3f8a3abb4d76e07e695eb9328cb1a6..5b50250441e95b11f8b24992bc3757a39c1226b6 100644 (file)
@@ -24,3 +24,4 @@
 /previews/
 /logs/
 /server/tools/import-mediacore.ts
+/docker-volume/
index 093d7124edbd3782276bf53517f5159332051921..ae2b0f9c050c525de402cace198b56c295101514 100644 (file)
@@ -30,7 +30,7 @@ you can use the regular `up` command to set it up, with possible overrides of
 the environment variables:
 
 ```bash
-$ PEERTUBE_HOSTNAME=peertube.lvh.me \
+$ PEERTUBE_WEBSERVER_HOSTNAME=peertube.lvh.me \
   PEERTUBE_ADMIN_EMAIL=test@example.com \
   PEERTUBE_TRANSCODING_ENABLED=true \
   PEERTUBE_SIGNUP_ENABLED=true \
index a8c3d62cefbcbbeff5ad12f7d139014c3fea22d9..6edd33546cefbcc53930805f06f39972000db57a 100644 (file)
@@ -57,14 +57,16 @@ USER peertube
 RUN yarn install --pure-lockfile \
     && npm run build
 
-# Configure PeerTube
-RUN cp /app/config/default.yaml /app/support/docker/production/config/default.yaml
+USER root
+
+RUN mkdir /data /config
+RUN chown -R peertube:peertube /data /config
+
 ENV NODE_ENV production
-ENV NODE_CONFIG_DIR /app/support/docker/production/config
+ENV NODE_CONFIG_DIR /config
 
-USER root
-RUN mkdir /data && chown peertube:peertube /data
 VOLUME /data
+VOLUME /config
 
 COPY ./support/docker/production/docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh
 ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
index bcae32079a6d2c281407c5da36a061f604889369..e157aaea9ac29b50ba80a9fc6f8cd5ef194ae22e 100644 (file)
@@ -1,10 +1,10 @@
 webserver:
-  hostname: "PEERTUBE_HOSTNAME"
+  hostname: "PEERTUBE_WEBSERVER_HOSTNAME"
   port:
-    __name: "PEERTUBE_PORT"
+    __name: "PEERTUBE_WEBSERVER_PORT"
     __format: "json"
   https:
-    __name: "PEERTUBE_HTTPS"
+    __name: "PEERTUBE_WEBSERVER_HTTPS"
     __format: "json"
 
 database:
index ee1d29853067dcd0bc39b43a4296c7c066fed12f..eefd6e5bbfd0ef7e70ba12e461cbf36246dc4bf3 100644 (file)
@@ -9,9 +9,9 @@ services:
     #   dockerfile: ./support/docker/production/Dockerfile.stretch
     image: chocobozzz/peertube:production-stretch
     environment:
-      PEERTUBE_HOSTNAME: my.domain.tld
-      PEERTUBE_PORT: 443
-      PEERTUBE_HTTPS: "true"
+      PEERTUBE_WEBSERVER_HOSTNAME: my.domain.tld
+      PEERTUBE_WEBSERVER_PORT: 443
+      PEERTUBE_WEBSERVER_HTTPS: "true"
       PEERTUBE_ADMIN_EMAIL: admin@domain.tld
       PEERTUBE_DB_HOSTNAME: postgres
       PEERTUBE_DB_USERNAME: postgres_user
@@ -27,13 +27,14 @@ services:
     # remove them if you are using another reverse proxy.
     labels:
       traefik.enable: "true"
-      traefik.frontend.rule: "Host:${PEERTUBE_HOSTNAME}"
+      traefik.frontend.rule: "Host:${PEERTUBE_WEBSERVER_HOSTNAME}"
       traefik.port: "9000"
     # If you don't want to use a reverse proxy (not suitable for production!)
     # ports:
       # - "80:9000"
     volumes:
-      - ./data:/data
+      - ./docker-volume/data:/data
+      - ./docker-volume/config:/config
     depends_on:
       - postgres
       - redis
@@ -46,11 +47,11 @@ services:
       POSTGRES_PASSWORD: postgres_password
       POSTGRES_DB: peertube
     volumes:
-      - ./db:/var/lib/postgresql/data
+      - ./docker-volume/db:/var/lib/postgresql/data
     restart: "always"
 
   redis:
     image: redis:4-alpine
     volumes:
-      - ./redis:/data
+      - ./docker-volume/redis:/data
     restart: "always"
index ba9fcfed5b541964b1fcd335bd578e2fb5a54d26..8ee968b3da833d9f9bbff3a62595b4a63c5030a8 100755 (executable)
@@ -1,6 +1,13 @@
 #!/bin/sh
 set -e
 
+# Populate config directory
+if [ -z "$(ls -A /config)" ]; then
+    cp /app/support/docker/production/config/* /config
+    cp /app/config/default.yaml /config
+    chown -R peertube:peertube /config
+fi
+
 # first arg is `-f` or `--some-option`
 # or first arg is `something.conf`
 if [ "${1#-}" != "$1" ] || [ "${1%.conf}" != "$1" ]; then
diff --git a/support/docker/production/swarm-stack.sample.yml b/support/docker/production/swarm-stack.sample.yml
deleted file mode 100644 (file)
index 794f447..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-version: "3.3"
-
-services:
-  app:
-    image: peertube:stretch
-    environment:
-      PEERTUBE_HOSTNAME: my.domain.tld
-      PEERTUBE_PORT: 443
-      PEERTUBE_HTTPS: true
-      PEERTUBE_ADMIN_EMAIL: admin@domain.tld
-      PEERTUBE_DB_USERNAME: user
-      PEERTUBE_DB_PASSWORD: password
-      PEERTUBE_SIGNUP_ENABLED: true
-      PEERTUBE_TRANSCODING_ENABLED: true
-    labels: &labels
-      traefik.frontend.rule: "Host:my.domain.tld"
-      traefik.docker.network: traefik
-      traefik.port: "9000"
-    volumes:
-      - app_data:/usr/src/app/data
-    networks:
-      - traefik
-      - backend
-    depends_on:
-      - db
-    deploy:
-      labels: *labels
-      placement:
-        constraints:
-        - node.labels.peertube == 1
-
-  db:
-    image: postgres:10
-    environment:
-      POSTGRES_DB: peertube_prod
-    volumes:
-      - db_data:/var/lib/postgresql/data
-    networks:
-      - backend
-    deploy:
-      placement:
-        constraints:
-        - node.labels.peertube == 1
-
-volumes:
-  app_data:
-  db_data:
-
-networks:
-  backend:
-  traefik:
-    external: true