diff --git a/docker-compose.yaml b/docker-compose.yaml index d159f72..50abb22 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -26,18 +26,24 @@ services: build: web/ volumes: - ./web/src:/src + - ./web/media:${MEDIA_DIR} environment: - DOMAIN=${DOMAIN} - DB_HOST=${DB_HOST} - DB_NAME=${DB_NAME} + - MEDIA_DIR=${MEDIA_DIR} working_dir: /src networks: - fedilove nginx: + command: sh -c "envsubst \"`env | awk -F = '{printf \" $$%s\", $$1}'`\" < /tmp/nginx.template > /etc/nginx/conf.d/default.conf && nginx -g 'daemon off;'" image: nginx:latest volumes: - - ./nginx.conf:/etc/nginx/conf.d/default.conf:ro + - ./nginx.conf:/tmp/nginx.template:ro + - ./web/media:${MEDIA_DIR}:ro + environment: + - MEDIA_DIR=${MEDIA_DIR} ports: - 127.0.0.1:8080:80 networks: diff --git a/env.example b/env.example index bb65d9f..4f52cd4 100644 --- a/env.example +++ b/env.example @@ -1,6 +1,10 @@ # Instance DOMAIN=example.org +# Storage +# media directory inside containers +MEDIA_DIR=/data/media + # Database DB_HOST=db DB_NAME=fedilove diff --git a/nginx.conf b/nginx.conf index 0b8a60f..a9b754c 100644 --- a/nginx.conf +++ b/nginx.conf @@ -3,6 +3,11 @@ server { listen *:80; server_name _; + # Media + location /media { + root ${MEDIA_DIR}; + } + # Web client location ~ ^(/$|/@|/app) { proxy_buffering off;