-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
41 lines (39 loc) · 1.16 KB
/
Dockerfile
File metadata and controls
41 lines (39 loc) · 1.16 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
# --- Frontend ---
# Instantiate node image and install dependencies
FROM node:20-alpine AS frontend
WORKDIR /frontend
COPY frontend/package*.json ./
RUN npm ci
COPY frontend .
# Build the frontend
RUN npm run build
# --- Backend ---
# Instantiate golang image
FROM golang:1.23-alpine AS backend
# Install CA certificates
RUN apk add --no-cache ca-certificates
# Install dependencies
WORKDIR /backend
COPY backend/go.mod backend/go.sum ./
RUN go mod download
COPY backend/ .
# Copy the frontend build
COPY --from=frontend /frontend/dist ./frontend/dist
# Build the Go application
RUN CGO_ENABLED=0 go build -o app .
# --- Runtime ---
# Use a minimal image for runtime
FROM alpine:latest
WORKDIR /app
# Install CA certificates for TLS (MongoDB Atlas, etc.)
RUN apk add --no-cache ca-certificates
# Copy the built backend application
COPY --from=backend /backend/app .
# Copy the built frontend dist
COPY --from=frontend /frontend/dist ./frontend/dist
# Ensure static assets get a fresh mtime each deploy so browsers don't keep a stale cached copy.
RUN find ./frontend/dist -type f -exec touch -c {} +
# Expose the application port
EXPOSE 8080
# Run the Go executable
CMD ["./app"]