-
Notifications
You must be signed in to change notification settings - Fork 250
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support for regular multistage docker
Signed-off-by: Derek Nola <[email protected]>
- Loading branch information
Showing
2 changed files
with
63 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,47 @@ | ||
|
||
FROM golang:1.21-alpine3.18 AS infra | ||
ARG ARCH=amd64 | ||
|
||
RUN apk -U add bash coreutils git gcc musl-dev docker-cli vim less file curl wget ca-certificates | ||
# go imports version gopls/v0.14.1 | ||
# https://github.com/golang/tools/releases/latest | ||
RUN go install golang.org/x/tools/cmd/goimports@e985f842fa05caad2f3486f0711512aedffbcda8 | ||
RUN rm -rf /go/src /go/pkg | ||
RUN if [ "${ARCH}" == "amd64" ]; then \ | ||
curl -sL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s; \ | ||
fi | ||
|
||
ENV SRC_DIR=/go/src/github.com/k3s-io/kine | ||
WORKDIR ${SRC_DIR}/ | ||
|
||
# Validate needs everything in the project, so we seperate it out better caching | ||
FROM infra as validate | ||
ARG SKIP_VALIDATE | ||
ENV SKIP_VALIDATE=${SKIP_VALIDATE} | ||
COPY . . | ||
|
||
RUN ./scripts/validate | ||
|
||
FROM infra AS build | ||
ARG CROSS | ||
ARG TAG | ||
ARG DRONE_TAG | ||
ARG ARCH=amd64 | ||
ENV ARCH=${ARCH} | ||
|
||
COPY ./scripts/build ./scripts/version ./scripts/ | ||
COPY ./go.mod ./go.sum ./main.go ./ | ||
COPY ./pkg ./pkg | ||
COPY ./.git ./.git | ||
COPY ./.golangci.json ./.golangci.json | ||
|
||
RUN ./scripts/build | ||
|
||
FROM scratch as binary | ||
ENV SRC_DIR=/go/src/github.com/k3s-io/kine | ||
COPY --from=build ${SRC_DIR}/bin /bin | ||
|
||
FROM build as package | ||
COPY ./scripts/package ./scripts/package | ||
COPY ./package ./package | ||
CMD ./scripts/package |
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