[Docker] Allow overriding forwarded ports

This also makes images load on ports other than 3000 by default
This commit is contained in:
Earlopain 2023-09-25 18:21:08 +02:00
parent 8ad0e08a82
commit 156276f0c0
No known key found for this signature in database
GPG Key ID: 48860312319ADF61
3 changed files with 10 additions and 6 deletions

View File

@ -43,6 +43,11 @@
# #
# COMPOSE_PROFILES=solargraph,discord # COMPOSE_PROFILES=solargraph,discord
# Change the ports that are forwarded by docker to avoid potential conflicts
# EXPOSED_SERVER_PORT=3000
# EXPOSED_POSTGRES_PORT=34517
# The following environment variables are required when using the 'discord' profile: # The following environment variables are required when using the 'discord' profile:
# JOINER_BOT_TOKEN= # JOINER_BOT_TOKEN=

View File

@ -1,7 +1,7 @@
version: "3" version: "3"
x-environment: &common-env x-environment: &common-env
DANBOORU_HOSTNAME: http://localhost:3000 DANBOORU_HOSTNAME: http://localhost:${EXPOSED_SERVER_PORT:-3000}
DANBOORU_REDIS_URL: redis://redis DANBOORU_REDIS_URL: redis://redis
DANBOORU_ELASTICSEARCH_HOST: elastic DANBOORU_ELASTICSEARCH_HOST: elastic
DANBOORU_MEMCACHED_SERVERS: memcached DANBOORU_MEMCACHED_SERVERS: memcached
@ -70,13 +70,12 @@ services:
- ./docker/default.conf.template:/etc/nginx/templates/default.conf.template - ./docker/default.conf.template:/etc/nginx/templates/default.conf.template
environment: environment:
<<: *common-env <<: *common-env
NGINX_HOST: localhost NGINX_PORT: ${EXPOSED_SERVER_PORT:-3000}
NGINX_PORT: 3000
depends_on: depends_on:
- autocompleted - autocompleted
- e621 - e621
ports: ports:
- "3000:3000" - "${EXPOSED_SERVER_PORT:-3000}:${EXPOSED_SERVER_PORT:-3000}"
postgres: postgres:
image: postgres:15-alpine image: postgres:15-alpine
@ -87,7 +86,7 @@ services:
volumes: volumes:
- db_data:/var/lib/postgresql/data - db_data:/var/lib/postgresql/data
ports: ports:
- "34517:5432" - "${EXPOSED_POSTGRES_PORT:-34517}:5432"
redis: redis:
image: redis:7.0.10-alpine image: redis:7.0.10-alpine

View File

@ -1,6 +1,6 @@
server { server {
listen ${NGINX_PORT}; listen ${NGINX_PORT};
server_name ${NGINX_HOST}; server_name localhost;
root /app/public; root /app/public;
index index.html; index index.html;
access_log off; access_log off;