secutorpro commited on
Commit
0e7df75
·
verified ·
1 Parent(s): 62c7dbc

fix: non-root user + writable data dir for HF Spaces

Browse files
Files changed (1) hide show
  1. Dockerfile +10 -11
Dockerfile CHANGED
@@ -1,22 +1,21 @@
1
- # ---- build the web frontend ----
2
  FROM node:20-alpine AS webbuild
3
- WORKDIR /build
4
  COPY web/package.json ./
5
  RUN npm install
6
- COPY web/ ./
7
  RUN npm run build
8
 
9
- # ---- server runtime ----
10
  FROM node:20-alpine
11
- WORKDIR /app/server
12
- # build tools as a fallback if better-sqlite3 has no prebuilt binary
13
  RUN apk add --no-cache python3 make g++
 
14
  COPY server/package.json ./
15
  RUN npm install --omit=dev
16
- COPY server/ ./
17
- COPY --from=webbuild /build/dist /app/web/dist
18
-
19
- ENV NODE_ENV=production
20
- ENV PORT=8080
 
21
  EXPOSE 8080
 
22
  CMD ["node", "src/index.js"]
 
 
1
  FROM node:20-alpine AS webbuild
2
+ WORKDIR /app/web
3
  COPY web/package.json ./
4
  RUN npm install
5
+ COPY web ./
6
  RUN npm run build
7
 
 
8
  FROM node:20-alpine
 
 
9
  RUN apk add --no-cache python3 make g++
10
+ WORKDIR /app/server
11
  COPY server/package.json ./
12
  RUN npm install --omit=dev
13
+ COPY server ./
14
+ COPY --from=webbuild /app/web/dist /app/web/dist
15
+ # HF Spaces runs the container as a non-root user (UID 1000):
16
+ # pre-create the data dir and hand the tree over so SQLite can write there.
17
+ RUN mkdir -p /app/server/data && chown -R 1000:1000 /app/server
18
+ ENV NODE_ENV=production PORT=8080
19
  EXPOSE 8080
20
+ USER 1000
21
  CMD ["node", "src/index.js"]