-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.frontend
More file actions
40 lines (30 loc) · 888 Bytes
/
Dockerfile.frontend
File metadata and controls
40 lines (30 loc) · 888 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
# syntax=docker/dockerfile:1
# -------------------------
# Front-end Dockerfile
# -------------------------
# This is a multi-stage build. The first stage (builder) compiles the
# React/Vite project, and the second stage (production) serves the
# compiled static assets using Nginx.
###########
# Builder #
###########
FROM node:20-alpine AS builder
# Create app directory
WORKDIR /app
# Install dependencies first (leverages Docker layer caching)
COPY frontend/package*.json ./
RUN npm ci --silent
# Copy the rest of the source code
COPY frontend/ .
# Build the production files
RUN npm run build
##############
# Production #
##############
FROM nginx:stable-alpine
# Copy build output from the previous stage
COPY --from=builder /app/dist /usr/share/nginx/html
# Expose the port Nginx will listen on
EXPOSE 80
# Run Nginx in the foreground
CMD ["nginx", "-g", "daemon off;"]