Added a way to template environment variables inside NGINX config using docker

* Created configuration for storing media (avatars, images, videos...)
This commit is contained in:
Niko 2022-02-11 01:24:25 +01:00
parent 390cffbed2
commit 88db2c2919
3 changed files with 16 additions and 1 deletions

View File

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

View File

@ -1,6 +1,10 @@
# Instance
DOMAIN=example.org
# Storage
# media directory inside containers
MEDIA_DIR=/data/media
# Database
DB_HOST=db
DB_NAME=fedilove

View File

@ -3,6 +3,11 @@ server {
listen *:80;
server_name _;
# Media
location /media {
root ${MEDIA_DIR};
}
# Web client
location ~ ^(/$|/@|/app) {
proxy_buffering off;