-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
70 lines (51 loc) · 1.72 KB
/
Dockerfile
File metadata and controls
70 lines (51 loc) · 1.72 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# Multi-stage build for React app
FROM node:22-alpine AS build
# Enable corepack for yarn
RUN corepack enable
# Set working directory
WORKDIR /app
# Copy package files
COPY package.json yarn.lock ./
COPY .yarn ./.yarn
COPY .yarnrc.yml ./
# Install dependencies
RUN yarn install --immutable --frozen-lockfile
# Copy source code
COPY . .
# Build the application with static blog pages
RUN yarn build
# Full production image: serves built static files + API (admin uploads, content editing, etc.)
FROM node:22-alpine AS production-app
RUN corepack enable
WORKDIR /app
# Install dependencies (includes server deps like express)
COPY package.json yarn.lock ./
COPY .yarn ./.yarn
COPY .yarnrc.yml ./
RUN yarn install --immutable --frozen-lockfile
# Copy runtime assets
COPY --from=build /app/dist /app/dist
COPY --from=build /app/server /app/server
COPY --from=build /app/scripts /app/scripts
# Optional: keep repo content folders for local/dev-style flows and backward compatibility
COPY --from=build /app/public /app/public
COPY --from=build /app/src/blog /app/src/blog
ENV NODE_ENV=production
ENV PORT=80
ENV CONTENT_DIST_ROOT=/app/dist
# Persisted content DB (override via SQLITE_PATH)
ENV SQLITE_PATH=/app/server/data/content.sqlite
EXPOSE 80
CMD ["node", "server/index.js"]
# Static-only stage with Nginx (NO API).
# Use only if you don't need /admin editing at runtime.
FROM nginx:1.25-alpine AS production-nginx
# Copy custom nginx configuration (SPA fallback, optional static .html pages)
COPY nginx.conf /etc/nginx/nginx.conf
# Copy built application
COPY --from=build /app/dist /usr/share/nginx/html
EXPOSE 80
# Start nginx
CMD ["nginx", "-g", "daemon off;"]
# Default final stage: production app with API
FROM production-app AS production