Skip to content

Commit cd479d4

Browse files
committed
feat: Auto-initialize config files in Docker environment (PR #310)
- Add automatic config.json initialization on first run - Improve Docker deployment experience - Reduce manual configuration steps
2 parents 75c0408 + cec5100 commit cd479d4

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

docker-compose.yml

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,19 @@
11
services:
2+
# Init service: ensure config.db file exists before backend starts
3+
config-init:
4+
image: busybox:1.36
5+
command:
6+
- sh
7+
- -c
8+
- >
9+
touch /mnt/config.db &&
10+
if [ ! -f /mnt/config.json ] && [ -f /mnt/config.json.example ]; then
11+
cp /mnt/config.json.example /mnt/config.json;
12+
fi
13+
volumes:
14+
- ./:/mnt
15+
restart: "no"
16+
217
# Backend service (API and core logic)
318
nofx:
419
build:
@@ -18,6 +33,9 @@ services:
1833
- TZ=${NOFX_TIMEZONE:-Asia/Shanghai} # Set timezone
1934
networks:
2035
- nofx-network
36+
depends_on:
37+
config-init:
38+
condition: service_completed_successfully
2139
healthcheck:
2240
test: ["CMD", "curl", "-f", "http://localhost:8080/api/health"]
2341
interval: 30s
@@ -47,4 +65,4 @@ services:
4765

4866
networks:
4967
nofx-network:
50-
driver: bridge
68+
driver: bridge

0 commit comments

Comments
 (0)