Docker config directory as volume

pull/543/merge
Chocobozzz 2018-05-07 18:39:42 +02:00
parent d9c1882dd0
commit fd5e57bbe2
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
7 changed files with 28 additions and 69 deletions

1
.gitignore vendored
View File

@ -24,3 +24,4 @@
/previews/
/logs/
/server/tools/import-mediacore.ts
/docker-volume/

View 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 \

View 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
ENV NODE_ENV production
ENV NODE_CONFIG_DIR /app/support/docker/production/config
USER root
RUN mkdir /data && chown peertube:peertube /data
RUN mkdir /data /config
RUN chown -R peertube:peertube /data /config
ENV NODE_ENV production
ENV NODE_CONFIG_DIR /config
VOLUME /data
VOLUME /config
COPY ./support/docker/production/docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh
ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]

View 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:

View 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"

View File

@ -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

View File

@ -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