-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Use the default docker registry
- Loading branch information
Showing
2 changed files
with
52 additions
and
20 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,30 +1,37 @@ | ||
# Build stage | ||
FROM golang:1.21-alpine AS build-env | ||
FROM --platform=${BUILDPLATFORM:-linux/amd64} golang:1.21 as builder | ||
|
||
# Set up necessary Go environment variables (optional, based on your app's needs) | ||
# ENV GO111MODULE=on \ | ||
# CGO_ENABLED=0 \ | ||
# GOOS=linux \ | ||
# GOARCH=amd64 | ||
ARG TARGETPLATFORM | ||
ARG BUILDPLATFORM | ||
ARG TARGETOS | ||
ARG TARGETARCH | ||
|
||
ENV GO111MODULE=on | ||
|
||
# Set the working directory inside the container | ||
WORKDIR /app | ||
|
||
# Copy the source from the current directory to the working Directory inside the container | ||
COPY . . | ||
RUN go mod download | ||
|
||
# Build the Go app | ||
RUN go mod tidy && go mod vendor && go build -o fern . | ||
# RUN go mod tidy && go build -o fern . | ||
|
||
RUN GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -o fern . | ||
|
||
# Final stage: Run stage | ||
FROM alpine | ||
FROM --platform=${BUILDPLATFORM:-linux/amd64} gcr.io/distroless/static:nonroot | ||
|
||
# Copy the pre-built binary file from the previous stage | ||
COPY --from=build-env /app/fern /app/fern | ||
|
||
# Set the working directory in the container | ||
WORKDIR /app | ||
|
||
# Copy the pre-built binary file from the previous stage | ||
COPY --from=builder /app/fern /app/fern | ||
|
||
USER nonroot:nonroot | ||
|
||
# Command to run the binary | ||
CMD ["/app/fern"] | ||
|