Skip to content

Commit 2fa1ce7

Browse files
authored
Improve docker compose template (#4004)
1 parent e58e8f7 commit 2fa1ce7

File tree

2 files changed

+471
-454
lines changed

2 files changed

+471
-454
lines changed

docker-compose.minimal.yaml

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
# Docker Compose configuration for Lychee application with FrankenPHP backend
2+
# Version: 2026-01-10
3+
4+
x-base-lychee-setup: &base-lychee-setup
5+
image: ghcr.io/lycheeorg/lychee:latest
6+
restart: unless-stopped # Auto-restart at container level (outer layer)
7+
8+
# Security hardening
9+
security_opt:
10+
- no-new-privileges:true
11+
- seccomp:unconfined # FrankenPHP may need this; consider custom seccomp profile
12+
cap_drop:
13+
- ALL
14+
cap_add:
15+
- CHOWN
16+
- SETGID
17+
- SETUID
18+
- DAC_OVERRIDE
19+
- NET_BIND_SERVICE
20+
read_only: false # Laravel needs write access to storage/cache
21+
tmpfs:
22+
- /tmp:noexec,nosuid,nodev,size=100m
23+
volumes:
24+
- ./lychee/uploads:/app/public/uploads
25+
- ./lychee/logs:/app/storage/logs
26+
- ./lychee/tmp:/app/storage/tmp
27+
networks:
28+
- lychee
29+
30+
x-common-env: &common-env
31+
PUID: "${PUID:-1000}"
32+
PGID: "${PGID:-1000}"
33+
# REPLACE ME WITH YOUR VALUE GENERATED WITH `openssl rand -base64 32`
34+
APP_KEY: "base64:ucMiFCbfQZUFOxrQz1x9C0OBJeLCCCAieZmnEHXmyGI="
35+
APP_NAME: "${APP_NAME:-Lychee}"
36+
APP_ENV: "${APP_ENV:-production}"
37+
APP_TIMEZONE: "${TIMEZONE:-UTC}"
38+
APP_URL: "${APP_URL:-http://localhost:8000}"
39+
APP_FORCE_HTTPS: "${APP_FORCE_HTTPS:-false}"
40+
DB_CONNECTION: "${DB_CONNECTION:-mysql}"
41+
DB_HOST: "${DB_HOST:-lychee_db}"
42+
DB_PORT: "${DB_PORT:-3306}"
43+
DB_DATABASE: "${DB_DATABASE:-lychee}"
44+
DB_USERNAME: "${DB_USERNAME:-lychee}"
45+
DB_PASSWORD: "${DB_PASSWORD:-password}"
46+
SESSION_DRIVER: "${SESSION_DRIVER:-file}"
47+
SESSION_LIFETIME: "${SESSION_LIFETIME:-120}"
48+
QUEUE_CONNECTION: "${QUEUE_CONNECTION:-database}"
49+
50+
services:
51+
lychee_api:
52+
<<: *base-lychee-setup
53+
container_name: lychee-api
54+
expose:
55+
- "${APP_PORT:-8000}"
56+
ports:
57+
- "${APP_PORT:-8000}:8000"
58+
environment:
59+
<<: *common-env
60+
# Enable WORKER MODE
61+
depends_on:
62+
lychee_db:
63+
condition: service_healthy
64+
healthcheck:
65+
test: ["CMD", "curl", "-f", "http://localhost:8000/up"]
66+
interval: 10s
67+
timeout: 5s
68+
retries: 5
69+
start_period: 30s
70+
71+
lychee_worker:
72+
<<: *base-lychee-setup
73+
container_name: lychee-worker
74+
environment:
75+
<<: *common-env
76+
# Enable WORKER MODE
77+
LYCHEE_MODE: worker
78+
79+
depends_on:
80+
lychee_db:
81+
condition: service_healthy
82+
lychee_api:
83+
condition: service_healthy
84+
healthcheck:
85+
test: ["CMD-SHELL", "pgrep -f 'queue:work' || exit 1"]
86+
interval: 30s
87+
timeout: 10s
88+
retries: 3
89+
start_period: 60s # Give worker time to start up
90+
91+
lychee_db:
92+
image: mariadb:10
93+
security_opt:
94+
- no-new-privileges:true
95+
cap_drop:
96+
- ALL
97+
cap_add:
98+
- SETGID
99+
- SETUID
100+
- DAC_OVERRIDE
101+
- CHOWN
102+
read_only: false # MariaDB needs write access
103+
tmpfs:
104+
- /tmp:noexec,nosuid,nodev,size=200m
105+
- /var/run/mysqld:noexec,nosuid,nodev,size=10m
106+
environment:
107+
- MYSQL_ROOT_PASSWORD=${DB_ROOT_PASSWORD:-rootpassword}
108+
- MYSQL_DATABASE=${DB_DATABASE:-lychee}
109+
- MYSQL_USER=${DB_USERNAME:-lychee}
110+
- MYSQL_PASSWORD=${DB_PASSWORD:-password}
111+
expose:
112+
- 3306
113+
volumes:
114+
- mysql:/var/lib/mysql
115+
networks:
116+
- lychee
117+
restart: unless-stopped
118+
healthcheck:
119+
test: ["CMD", "healthcheck.sh", "--connect", "--innodb_initialized"]
120+
interval: 5s
121+
timeout: 3s
122+
retries: 10
123+
start_period: 10s
124+
125+
networks:
126+
lychee:
127+
128+
volumes:
129+
mysql:
130+
name: lychee_prod_mysql
131+
driver: local

0 commit comments

Comments
 (0)