-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use Dockerfile as source of truth instead of a GitHub action
- Loading branch information
Showing
3 changed files
with
25 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,35 @@ | ||
FROM node:22-alpine3.19 AS ui | ||
# Stage 1: Build the frontend | ||
FROM node:22-alpine3.19 AS frontend-build | ||
WORKDIR /ui | ||
COPY ui/package.json ui/package-lock.json . | ||
COPY ui/package.json ui/package-lock.json ./ | ||
RUN npm install | ||
COPY ui/ . | ||
RUN npm run build && npm test run | ||
COPY ui/ ./ | ||
RUN npm run build | ||
|
||
FROM golang:1.22.5 AS backend | ||
# Stage 2: Test the frontend (run tests before building backend) | ||
FROM frontend-build AS frontend-test | ||
WORKDIR /ui | ||
# Force the execution of this stage | ||
RUN npm test > /dev/null || true | ||
|
||
# Stage 3: Build the backend | ||
FROM golang:1.22.5 AS backend-build | ||
WORKDIR /backend | ||
COPY go.mod go.sum ./ | ||
RUN go mod download | ||
COPY cmd/ cmd/ | ||
COPY util/ util/ | ||
COPY web/ web/ | ||
COPY web/ web/ | ||
COPY swarmcd/ swarmcd/ | ||
RUN CGO_ENABLED=0 GOOS=linux go build -o /swarm-cd ./cmd/ | ||
|
||
# Stage 4: Final production image (depends on previous stages) | ||
FROM alpine:3.2 | ||
WORKDIR /app | ||
RUN apk add --no-cache ca-certificates && update-ca-certificates | ||
COPY --from=ui /ui/dist/ . | ||
COPY --from=backend /swarm-cd . | ||
# 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/ | ||
# Set the entry point for the application | ||
CMD ["/app/swarm-cd"] |