-
-
Notifications
You must be signed in to change notification settings - Fork 54
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
yusing
committed
Feb 23, 2025
1 parent
4af2eaa
commit 8d06f7c
Showing
1 changed file
with
17 additions
and
15 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,5 +1,5 @@ | ||
# Stage 1: Builder | ||
FROM golang:1.24.0-alpine AS builder | ||
# Stage 1: deps | ||
FROM golang:1.24.0-alpine AS deps | ||
HEALTHCHECK NONE | ||
|
||
# package version does not matter | ||
|
@@ -11,31 +11,33 @@ WORKDIR /src | |
# Only copy go.mod and go.sum initially for better caching | ||
COPY go.mod go.sum /src/ | ||
|
||
# Utilize build cache | ||
RUN --mount=type=cache,target="/go/pkg/mod" \ | ||
go mod download -x | ||
ENV GOPATH=/root/go | ||
RUN go mod download -x | ||
|
||
ENV GOCACHE=/root/.cache/go-build | ||
# Stage 2: builder | ||
FROM deps AS builder | ||
|
||
WORKDIR /src | ||
|
||
COPY Makefile /src/ | ||
COPY cmd /src/cmd | ||
COPY internal /src/internal | ||
COPY pkg /src/pkg | ||
COPY agent /src/agent | ||
COPY Makefile ./ | ||
COPY cmd ./cmd | ||
COPY internal ./internal | ||
COPY pkg ./pkg | ||
COPY agent ./agent | ||
|
||
ARG VERSION | ||
ENV VERSION=${VERSION} | ||
|
||
ARG MAKE_ARGS | ||
ENV MAKE_ARGS=${MAKE_ARGS} | ||
|
||
RUN --mount=type=cache,target="/go/pkg/mod" \ | ||
--mount=type=cache,target="/root/.cache/go-build" \ | ||
make ${MAKE_ARGS} build link-binary && \ | ||
ENV GOCACHE=/root/.cache/go-build | ||
ENV GOPATH=/root/go | ||
RUN make ${MAKE_ARGS} build link-binary && \ | ||
mv bin /app/ && \ | ||
mkdir -p /app/error_pages /app/certs | ||
|
||
# Stage 2: Final image | ||
# Stage 3: Final image | ||
FROM scratch | ||
|
||
LABEL maintainer="[email protected]" | ||
|