-
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
1 parent
7c04ce0
commit f26a1be
Showing
5 changed files
with
157 additions
and
156 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 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,31 +1,16 @@ | ||
FROM golang:1.22-alpine3.19 as builder | ||
ENV GO111MODULE=on | ||
|
||
RUN apk update && \ | ||
apk add bash jq alpine-sdk sed gawk git ca-certificates curl && \ | ||
apk add --no-cache gcc musl-dev | ||
|
||
WORKDIR /go/src/github.com/equinor/radix-api/ | ||
|
||
# get dependencies | ||
# Build stage | ||
FROM docker.io/golang:1.22-alpine3.20 as builder | ||
ENV CGO_ENABLED=0 \ | ||
GOOS=linux | ||
WORKDIR /src | ||
COPY go.mod go.sum ./ | ||
RUN go mod download | ||
|
||
# copy api code | ||
COPY . . | ||
RUN go build -ldflags="-s -w" -o /build/radix-api | ||
|
||
# Build radix api go project | ||
RUN CGO_ENABLED=0 GOOS=linux go build -ldflags "-s -w" -a -installsuffix cgo -o /usr/local/bin/radix-api | ||
|
||
RUN addgroup -S -g 1000 api-user | ||
RUN adduser -S -u 1000 -G api-user api-user | ||
|
||
FROM scratch | ||
|
||
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ | ||
COPY --from=builder /etc/passwd /etc/passwd | ||
COPY --from=builder /usr/local/bin/radix-api /usr/local/bin/radix-api | ||
|
||
EXPOSE 3001 | ||
# Final stage, ref https://github.com/GoogleContainerTools/distroless/blob/main/base/README.md for distroless | ||
FROM gcr.io/distroless/static | ||
WORKDIR /app | ||
COPY --from=builder /build/radix-api . | ||
USER 1000 | ||
ENTRYPOINT ["/usr/local/bin/radix-api"] | ||
ENTRYPOINT ["/app/radix-api"] |
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
Oops, something went wrong.