-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathDockerfile
More file actions
56 lines (42 loc) · 1.79 KB
/
Dockerfile
File metadata and controls
56 lines (42 loc) · 1.79 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
# =============================================================================
# Dockerfile for hub.hellowp.io
# Multi-stage build: Node.js 20 + Nginx Alpine
# Build: ./build.sh (requires FontAwesome Pro token)
# =============================================================================
# -----------------------------------------------------------------------------
# Stage 1: Build
# -----------------------------------------------------------------------------
FROM node:20-alpine AS builder
# Set working directory
WORKDIR /app
# Install dependencies first (better layer caching)
COPY package.json package-lock.json* yarn.lock* ./
# FontAwesome Pro token (build arg)
ARG FONTAWESOME_NPM_AUTH_TOKEN
ENV FONTAWESOME_NPM_AUTH_TOKEN=${FONTAWESOME_NPM_AUTH_TOKEN}
# Configure FontAwesome Pro registry
RUN if [ -n "$FONTAWESOME_NPM_AUTH_TOKEN" ]; then \
echo "@fortawesome:registry=https://npm.fontawesome.com/" >> .npmrc && \
echo "//npm.fontawesome.com/:_authToken=${FONTAWESOME_NPM_AUTH_TOKEN}" >> .npmrc; \
fi
# Install dependencies
RUN npm ci --legacy-peer-deps || npm install --legacy-peer-deps
# Copy source code
COPY . .
# Build the static site
RUN npm run build
# ----------------------------------------------------------------------------
# Stage 2: Production (Nginx)
# -----------------------------------------------------------------------------
FROM nginx:alpine AS production
# Copy custom nginx config
COPY nginx.conf /etc/nginx/conf.d/default.conf
# Copy built static files from builder stage
COPY --from=builder /app/build /usr/share/nginx/html
# Expose port 80
EXPOSE 80
# Health check
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD wget --no-verbose --tries=1 --spider http://localhost/ || exit 1
# Start nginx
CMD ["nginx", "-g", "daemon off;"]