feat(nginx): Use builtin envsubst mechanics of nginx container

Part-of: <https://dev.funkwhale.audio/funkwhale/funkwhale/-/merge_requests/2541>
This commit is contained in:
Georg Krause 2023-07-26 10:17:42 +02:00 committed by Marge
parent d714c721b4
commit 1808cf6cf7
4 changed files with 120 additions and 159 deletions

View File

@ -0,0 +1 @@
Merge nginx configs for docker production and development setups (#1939)

View File

@ -115,7 +115,6 @@ services:
- "node3.funkwhale.test:172.17.0.1"
nginx:
command: /entrypoint.sh
env_file:
- .env.dev
- .env
@ -134,8 +133,7 @@ services:
- api
- front
volumes:
- ./docker/nginx/conf.dev:/etc/nginx/nginx.conf.template:ro
- ./docker/nginx/entrypoint.sh:/entrypoint.sh:ro
- ./docker/nginx/conf.dev:/etc/nginx/templates/default.conf.template:ro
- "${MUSIC_DIRECTORY_SERVE_PATH-./data/music}:/music:ro"
- ./deploy/funkwhale_proxy.conf:/etc/nginx/funkwhale_proxy.conf:ro
- "./front:/frontend:ro"

View File

@ -1,43 +1,17 @@
user nginx;
worker_processes 1;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
upstream funkwhale-api {
server ${FUNKWHALE_API_IP}:${FUNKWHALE_API_PORT};
}
upstream funkwhale-front {
server ${FUNKWHALE_FRONT_IP}:${FUNKWHALE_FRONT_PORT};
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
keepalive_timeout 65;
upstream funkwhale-api {
server ${FUNKWHALE_API_IP}:${FUNKWHALE_API_PORT};
}
upstream funkwhale-front {
server ${FUNKWHALE_FRONT_IP}:${FUNKWHALE_FRONT_PORT};
}
# Required for websocket support.
map $http_upgrade $connection_upgrade {
# Required for websocket support.
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
}
server {
server {
listen 80;
listen [::]:80;
charset utf-8;
@ -163,5 +137,4 @@ http {
alias /staticfiles/;
}
}
}

View File

@ -1,11 +0,0 @@
#!/bin/sh
set -eux
TEMPLATE_PATH="/etc/nginx/nginx.conf.template"
CONFIG_PATH="/etc/nginx/nginx.conf"
ALLOWED_VARS="$(env | cut -d '=' -f 1 | xargs printf "\${%s} ")"
envsubst "$ALLOWED_VARS" < "$TEMPLATE_PATH" | tee "$CONFIG_PATH"
nginx-debug -g 'daemon off;'