Skip to content

Commit d66cb74

Browse files
committed
fix: create /app/data owned by runtime user; add DATABASE_PATH to compose
Dockerfile: create /app/data and chown it to the runtime user before USER switch so Docker volume initialization inherits correct ownership. Previously, Docker named volumes were root:root on first mount, causing SQLite SQLITE_CANTOPEN (even though Node fs writes worked fine). The actual compose volume names are prefixed by docker compose project names (cas_cas-data, template_template-data) — the chown fix ensures any fresh volume deploy initialises with the correct uid 100:101. docker-compose.yml: add explicit DATABASE_PATH env var (was missing, though the code has a sensible default, explicit is better).
1 parent 666d690 commit d66cb74

File tree

4 files changed

+8
-0
lines changed

4 files changed

+8
-0
lines changed

apps/cas/backend/Dockerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@ COPY --from=builder /app/apps/cas/backend/dist ./dist
7272
COPY --from=builder /app/apps/cas/backend/package.json ./package.json
7373

7474
RUN addgroup --system cas && adduser --system --ingroup cas cas
75+
# Create the data directory owned by the runtime user so that Docker volume
76+
# mounts (and mkdirSync inside the app) can write to it without root privs.
77+
RUN mkdir -p /app/data && chown -R cas:cas /app/data
7578
USER cas
7679

7780
ENV NODE_ENV=production \

apps/cas/docker-compose.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ services:
1717
NODE_ENV: production
1818
PORT: "3001"
1919
HOST: "0.0.0.0"
20+
DATABASE_PATH: "/app/data/cas.db"
2021
CAS_API_KEY: "${CAS_API_KEY}"
2122
CORS_ORIGIN: "${CORS_ORIGIN:-https://cas.cfxdevkit.org}" # CAS frontend on Vercel
2223
volumes:

apps/template/backend/Dockerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,9 @@ COPY --from=builder /app/apps/template/backend/dist ./dist
8282
COPY --from=builder /app/apps/template/backend/package.json ./package.json
8383

8484
RUN addgroup --system template && adduser --system --ingroup template template
85+
# Create the data directory owned by the runtime user so that Docker volume
86+
# mounts (and mkdirSync inside the app) can write to it without root privs.
87+
RUN mkdir -p /app/data && chown -R template:template /app/data
8588
USER template
8689

8790
ENV NODE_ENV=production \

apps/template/docker-compose.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ services:
1717
NODE_ENV: production
1818
PORT: "3002"
1919
HOST: "0.0.0.0"
20+
DATABASE_PATH: "/app/data/template.db"
2021
JWT_SECRET: "${JWT_SECRET}"
2122
CORS_ORIGIN: "${CORS_ORIGIN:-https://template.cfxdevkit.org}"
2223
volumes:

0 commit comments

Comments
 (0)