-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathDockerfile
More file actions
43 lines (36 loc) · 1.34 KB
/
Copy pathDockerfile
File metadata and controls
43 lines (36 loc) · 1.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
FROM node:22-alpine3.23 AS frontend-builder
WORKDIR /build/frontend
RUN apk upgrade --no-cache
COPY frontend/package*.json ./
RUN npm install
COPY frontend/ .
RUN npm run build
# Separate stage to compile native modules (better-sqlite3 needs python3/make/g++)
# Build tools stay here and never reach the final image
FROM node:22-alpine3.23 AS backend-builder
WORKDIR /app
RUN apk add --no-cache python3 make g++
COPY backend/package*.json ./
RUN npm install --omit=dev
FROM node:22-alpine3.23
ARG APP_VERSION
ENV APP_VERSION=$APP_VERSION
WORKDIR /app
# Upgrade Alpine packages + add docker-cli for optional EPG scraper feature
RUN apk upgrade --no-cache && apk add --no-cache docker-cli su-exec
ENV DOCKER_API_VERSION=1.41
# Copy pre-compiled node_modules — no build tools needed in final image
COPY --from=backend-builder /app/node_modules ./node_modules
COPY backend/src ./src
COPY package.json ./package.json
COPY --from=frontend-builder /build/public ./public
COPY docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh
RUN chmod +x /usr/local/bin/docker-entrypoint.sh
# Create runtime data dirs (final ownership is enforced at container start)
RUN mkdir -p /app/data /app/data/scraper && chown -R node:node /app/data
ENV NODE_ENV=production
ENV PORT=3000
ENV DATA_DIR=/app/data
EXPOSE 3000
ENTRYPOINT ["docker-entrypoint.sh"]
CMD ["node", "src/index.js"]