feat: finalize file structure for Docker

This commit is contained in:
Emmanuel BENOîT 2025-01-02 14:04:58 +01:00
parent 2523581537
commit 7439475766
Signed by: Emmanuel BENOîT
SSH key fingerprint: SHA256:l7PFUUF5TCDsvYeQC9OnTNz08dFY7Fvf4Hv3neIqYpg
6 changed files with 99 additions and 3 deletions

1
.gitignore vendored Normal file
View file

@ -0,0 +1 @@
docker/.env

View file

@ -0,0 +1,3 @@
FROM postgres:17-alpine
ADD sql /opt/lwsql
ADD misc/init-sql.sh /docker-entrypoint-initdb.d

View file

@ -1,5 +1,4 @@
FROM debian:12-slim
ADD . /opt/lwb5
RUN <<EOF
set -e
export DEBIAN_FRONTEND=noninteractive
@ -19,7 +18,7 @@ RUN <<EOF
php8.3-xml socat
adduser --system --ingroup www-data \
--shell '/usr/bin/php /opt/lwb5/scripts/ticks.php' \
--shell '/bin/false' \
--comment 'LWB5 Ticks' \
--home /opt/lwb5 --no-create-home \
lwticks
@ -69,6 +68,8 @@ EOC
EOF
VOLUME /var/spool/pgen
EXPOSE 80 81
ADD game /opt/lwb5
ENTRYPOINT ["/opt/lwb5/run-lwb5.sh"]

74
docker/compose.yml Normal file
View file

@ -0,0 +1,74 @@
name: legacyworlds
services:
db:
build:
context: ../
dockerfile: docker/Dockerfile.database
restart: always
shm_size: 128mb
volumes:
- database:/var/lib/postgresql/data
environment:
LW_ADMIN_MAIL: ${LW_ADMIN_MAIL}
LW_ADMIN_NAME: ${LW_ADMIN_NAME}
LW_ADMIN_PASSWORD_FILE: /run/secrets/lw_admin_password
LW_DB_ADMIN_PASS_FILE: /run/secrets/lw_db_admin_pass
LW_DB_USER_PASS_FILE: /run/secrets/lw_db_user_pass
LW_PEACEKEEPERS_PASSWORD_FILE: /run/secrets/lw_peacekeepers_password
POSTGRES_PASSWORD_FILE: /run/secrets/db_password
secrets:
- db_password
- lw_db_user_pass
- lw_db_admin_pass
- lw_admin_password
- lw_peacekeepers_password
game:
build:
context: ../
dockerfile: docker/Dockerfile.game
restart: always
ports:
- "80:80"
- "81:81"
volumes:
- type: bind
source: ../game
target: /opt/lwb5
- type: tmpfs
target: /tmp
tmpfs:
size: 1g
- planets:/opt/lwb5/site/static/beta5/pics/pl:ro
- pgen:/var/spool/pgen:rw
planetgen:
build:
context: ..
dockerfile: docker/Dockerfile.planetgen
restart: always
volumes:
- pgen:/var/spool/pgen/input:rw
- planets:/var/spool/pgen/output:rw
environment:
PGEN_INPUT: /var/spool/pgen/input
PGEN_OUTPUT: /var/spool/pgen/output
volumes:
pgen:
planets:
database:
secrets:
db_password:
environment: DB_PASSWORD
lw_db_user_pass:
environment: LW_DB_USER_PASS
lw_db_admin_pass:
environment: LW_DB_ADMIN_PASS
lw_admin_password:
environment: LW_ADMIN_PASSWORD
lw_peacekeepers_password:
environment: LW_PEACEKEEPERS_PASSWORD

17
docker/env.example Normal file
View file

@ -0,0 +1,17 @@
# Password for the database superuser
DB_PASSWORD=...
# Legacyworlds database - Main user
LW_DB_USER_PASS=...
# Legacyworlds database - Admin user
LW_DB_ADMIN_PASS=...
# First admin account - User name
LW_ADMIN_NAME=...
# First admin account - Email address
LW_ADMIN_MAIL=...
# First admin account - Password (warning: will be stored in the clear)
LW_ADMIN_PASSWORD=...
# "Peacekeepers" fake player - Password (should be a random string)
LW_PEACEKEEPERS_PASSWORD=...