From fd5e57bbe2accbdb16b6aa65337c5ef44b5bd8fb Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 7 May 2018 18:39:42 +0200 Subject: Docker config directory as volume --- support/doc/docker.md | 2 +- support/docker/production/Dockerfile.stretch | 12 ++--- .../config/custom-environment-variables.yaml | 6 +-- support/docker/production/docker-compose.yml | 15 ++++--- support/docker/production/docker-entrypoint.sh | 7 +++ support/docker/production/swarm-stack.sample.yml | 52 ---------------------- 6 files changed, 26 insertions(+), 68 deletions(-) delete mode 100644 support/docker/production/swarm-stack.sample.yml (limited to 'support') diff --git a/support/doc/docker.md b/support/doc/docker.md index 093d7124e..ae2b0f9c0 100644 --- a/support/doc/docker.md +++ b/support/doc/docker.md @@ -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 \ diff --git a/support/docker/production/Dockerfile.stretch b/support/docker/production/Dockerfile.stretch index a8c3d62ce..6edd33546 100644 --- a/support/docker/production/Dockerfile.stretch +++ b/support/docker/production/Dockerfile.stretch @@ -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"] diff --git a/support/docker/production/config/custom-environment-variables.yaml b/support/docker/production/config/custom-environment-variables.yaml index bcae32079..e157aaea9 100644 --- a/support/docker/production/config/custom-environment-variables.yaml +++ b/support/docker/production/config/custom-environment-variables.yaml @@ -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: diff --git a/support/docker/production/docker-compose.yml b/support/docker/production/docker-compose.yml index ee1d29853..eefd6e5bb 100644 --- a/support/docker/production/docker-compose.yml +++ b/support/docker/production/docker-compose.yml @@ -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" diff --git a/support/docker/production/docker-entrypoint.sh b/support/docker/production/docker-entrypoint.sh index ba9fcfed5..8ee968b3d 100755 --- a/support/docker/production/docker-entrypoint.sh +++ b/support/docker/production/docker-entrypoint.sh @@ -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 index 794f44753..000000000 --- a/support/docker/production/swarm-stack.sample.yml +++ /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 -- cgit v1.2.3