forked from nanoandrew4/ngcplogs
-
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.
Speed up via caching and cross compiling.
- Loading branch information
Showing
1 changed file
with
9 additions
and
8 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,13 +1,14 @@ | ||
FROM golang:1.22.1-alpine as build | ||
FROM --platform=$BUILDPLATFORM golang:1.22.1-alpine as build | ||
|
||
COPY *.go /go/src/github.com/nanoandrew4/ngcplogs/ | ||
COPY go.mod /go/src/github.com/nanoandrew4/ngcplogs/ | ||
COPY go.sum /go/src/github.com/nanoandrew4/ngcplogs/ | ||
|
||
RUN cd /go/src/github.com/nanoandrew4/ngcplogs && go get && go build --ldflags '-extldflags "-static"' -o /usr/bin/ngcplogs | ||
WORKDIR /goapp | ||
COPY go.mod go.sum ./ | ||
RUN --mount=type=cache,target=/root/.cache/go-build --mount=type=cache,target=/go/pkg go mod download | ||
COPY *.go ./ | ||
ARG TARGETOS TARGETARCH | ||
RUN --mount=type=cache,target=/root/.cache/go-build --mount=type=cache,target=/go/pkg GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -o ngcplogs . | ||
|
||
FROM alpine:3.19.1 | ||
COPY --from=build /usr/bin/ngcplogs usr/bin | ||
COPY --from=build /goapp/ngcplogs usr/bin | ||
|
||
WORKDIR /usr/bin | ||
ENTRYPOINT [ "/usr/bin/ngcplogs" ] | ||
ENTRYPOINT [ "/usr/bin/ngcplogs" ] |