forked from AmintaCCCP/GithubStarsManager
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
36 lines (25 loc) · 1.08 KB
/
Copy pathDockerfile
File metadata and controls
36 lines (25 loc) · 1.08 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
# syntax=docker/dockerfile:1
# `dist` only contains static assets, so build it once on the native builder.
# The final nginx stage remains target-platform aware for amd64 and arm64.
FROM --platform=$BUILDPLATFORM node:22-alpine AS build
WORKDIR /app
# Copy package files
COPY package*.json ./
# Install dependencies
RUN npm ci
# Copy source code
COPY . .
# Build the application
RUN npm run build
# Production stage
FROM nginx:alpine
# Remove default nginx config that conflicts with ours
RUN rm -f /etc/nginx/conf.d/default.conf
# Copy built files from build stage
COPY --from=build /app/dist /usr/share/nginx/html
# Copy custom nginx configuration template (rendered at startup with BACKEND_HOST)
COPY nginx.conf.template /etc/nginx/nginx.conf.template
# Expose port
EXPOSE 80
# Render the nginx config (substituting BACKEND_HOST and RESOLVER) and start nginx
CMD ["sh", "-c", "export BACKEND_HOST=${BACKEND_HOST:-backend:3000}; export RESOLVER=${RESOLVER:-127.0.0.11}; envsubst '${BACKEND_HOST} ${RESOLVER}' < /etc/nginx/nginx.conf.template > /etc/nginx/nginx.conf && nginx -g 'daemon off;'"]