-
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
72 additions
and
61 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,37 @@ | ||
FROM node:22-alpine3.19 AS ui | ||
# Base stage for the front end (used for both build and test) | ||
FROM node:22-alpine3.19 AS frontend-base | ||
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/ ./ | ||
|
||
FROM golang:1.22.5 AS backend | ||
# Stage 1: Build the front end | ||
FROM frontend-base AS frontend-build | ||
RUN npm run build | ||
|
||
# Stage 2: Test the front end | ||
FROM frontend-base AS frontend-test | ||
RUN npm run build | ||
RUN npm test | ||
|
||
# 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/ | ||
|
||
FROM alpine:3.2 | ||
# Stage 4: Test the backend (if applicable) | ||
# FROM backend-build AS backend-test | ||
|
||
# Stage 5: Packaging | ||
FROM alpine:3.2 AS final | ||
WORKDIR /app | ||
RUN apk add --no-cache ca-certificates && update-ca-certificates | ||
COPY --from=ui /ui/dist/ . | ||
COPY --from=backend /swarm-cd . | ||
COPY --from=frontend-build /ui/dist/ /app/ui/ | ||
COPY --from=backend-build /swarm-cd /app/ | ||
CMD ["/app/swarm-cd"] |