-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathDockerfile
More file actions
35 lines (33 loc) · 1.02 KB
/
Dockerfile
File metadata and controls
35 lines (33 loc) · 1.02 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
# Stage 1: Build the frontend
FROM node:22-alpine3.19 AS frontend-build
WORKDIR /ui
COPY ui/package.json ui/package-lock.json ./
RUN npm install
COPY ui/ ./
RUN npm run build
# Stage 2: Build the backend
FROM golang:1.22-alpine AS backend-build
ARG TARGETARCH
WORKDIR /backend
COPY go.mod go.sum ./
RUN go mod download
COPY cmd/ cmd/
COPY util/ util/
COPY web/ web/
COPY swarmcd/ swarmcd/
RUN CGO_ENABLED=0 GOOS=linux GOARCH=${TARGETARCH} go build -o /swarm-cd ./cmd/
# Stage 3: Final production image (depends on previous stages)
FROM alpine:3.22.1
WORKDIR /app
RUN apk add --no-cache ca-certificates gnupg && update-ca-certificates
# Copy the built backend binary from the backend build stage
COPY --from=backend-build /swarm-cd /app/
# Copy the built frontend from the frontend build stage
COPY --from=frontend-build /ui/dist/ /app/ui/
# Sets the web server mode to release
ENV GIN_MODE=release
# Set the entry point for the application
COPY entrypoint.sh /
RUN chmod +x /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]
CMD ["/app/swarm-cd"]