-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
5 additions
and
17 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,18 @@ | ||
# syntax=docker/dockerfile:1 | ||
|
||
# Build the application from source | ||
FROM golang:1.22 AS build-stage | ||
FROM golang:1.22.5 AS build-stage | ||
|
||
WORKDIR /app | ||
|
||
COPY go.mod go.sum ./ | ||
RUN go mod download | ||
|
||
COPY *.go ./ | ||
RUN go mod tidy | ||
|
||
RUN CGO_ENABLED=0 GOOS=linux go build -o /techbloghub | ||
COPY . . | ||
|
||
# Run the tests in the container | ||
FROM build-stage AS run-test-stage | ||
RUN go test -v ./... | ||
|
||
# Deploy the application binary into a lean image | ||
FROM gcr.io/distroless/base-debian11 AS build-release-stage | ||
|
||
WORKDIR / | ||
|
||
COPY --from=build-stage /techbloghub /techbloghub | ||
RUN go build -o main ./main.go | ||
|
||
EXPOSE 8080 | ||
|
||
USER nonroot:nonroot | ||
|
||
ENTRYPOINT ["//techbloghub"] | ||
ENTRYPOINT ["/techbloghub"] |