-
Notifications
You must be signed in to change notification settings - Fork 237
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Provide Dapper free build alternative (#254)
* Bump dapper version Signed-off-by: Derek Nola <[email protected]> * Consolidate validation Signed-off-by: Derek Nola <[email protected]> * Support for regular multistage docker Signed-off-by: Derek Nola <[email protected]> * Dirty determination outside docker Signed-off-by: Derek Nola <[email protected]> * Optimize caching for code change and tagging Signed-off-by: Derek Nola <[email protected]> * Nit: codespell Signed-off-by: Derek Nola <[email protected]> * Arm build fix Signed-off-by: Derek Nola <[email protected]> * Typo Signed-off-by: Derek Nola <[email protected]> --------- Signed-off-by: Derek Nola <[email protected]>
- Loading branch information
Showing
10 changed files
with
106 additions
and
39 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 |
---|---|---|
@@ -0,0 +1,50 @@ | ||
|
||
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 separate it out for better caching | ||
FROM infra as validate | ||
ARG SKIP_VALIDATE | ||
ENV SKIP_VALIDATE=${SKIP_VALIDATE} | ||
COPY . . | ||
RUN --mount=type=cache,id=gomod,target=/go/pkg/mod \ | ||
--mount=type=cache,id=gobuild,target=/root/.cache/go-build \ | ||
--mount=type=cache,id=lint,target=/root/.cache/golangci-lint \ | ||
./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 --mount=type=cache,id=gomod,target=/go/pkg/mod \ | ||
--mount=type=cache,id=gobuild,target=/root/.cache/go-build \ | ||
./scripts/build | ||
|
||
COPY ./scripts/package ./scripts/entry ./scripts/ | ||
COPY ./package ./package | ||
CMD ./scripts/entry package | ||
|
||
FROM scratch as binary | ||
ENV SRC_DIR=/go/src/github.com/k3s-io/kine | ||
COPY --from=build ${SRC_DIR}/bin /bin |
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
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
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,19 +1,32 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
if [ -n "$SKIP_VALIDATE" ]; then | ||
echo Skipping validation | ||
exit 0 | ||
fi | ||
|
||
cd $(dirname $0)/.. | ||
|
||
echo Running validation | ||
|
||
PACKAGES="$(go list ./...)" | ||
|
||
if ! command -v golangci-lint; then | ||
echo Skipping validation: no golangci-lint available | ||
exit | ||
if command -v golangci-lint; then | ||
echo Running: golangci-lint | ||
golangci-lint run | ||
fi | ||
|
||
echo Running: golangci-lint | ||
golangci-lint run | ||
|
||
echo Running: go fmt | ||
test -z "$(go fmt ${PACKAGES} | tee /dev/stderr)" | ||
|
||
go generate | ||
|
||
source ./scripts/version | ||
|
||
if [ -n "$DIRTY" ]; then | ||
echo Git is dirty | ||
git status | ||
git diff | ||
exit 1 | ||
fi |
This file was deleted.
Oops, something went wrong.
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