-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathDockerfile
More file actions
40 lines (29 loc) · 953 Bytes
/
Dockerfile
File metadata and controls
40 lines (29 loc) · 953 Bytes
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
# Build stage
FROM node:18-alpine AS builder
WORKDIR /app
# Install pnpm
RUN npm install -g pnpm
# Only copy lockfile and package manifest first for better cache
COPY package.json pnpm-lock.yaml ./
# Install deps
RUN pnpm install --frozen-lockfile
# Copy source
COPY . .
# Add build timestamp to break cache for data generation
ARG BUILD_DATE
ENV BUILD_DATE=${BUILD_DATE}
# Generate data and build static site (read optional token via BuildKit secret)
RUN --mount=type=secret,id=GH_TOKEN \
sh -c 'TOKEN=""; \
if [ -f /run/secrets/GH_TOKEN ]; then TOKEN=$(cat /run/secrets/GH_TOKEN); fi; \
echo "Build date: $BUILD_DATE"; \
node generateData.js "$TOKEN" && pnpm run build'
# Runtime stage
FROM nginx:1.27-alpine
# Nginx config
COPY nginx.conf /etc/nginx/conf.d/default.conf
# Static assets
COPY --from=builder /app/dist /usr/share/nginx/html
EXPOSE 80
# Use default nginx start command
CMD ["nginx", "-g", "daemon off;"]