-
-
Notifications
You must be signed in to change notification settings - Fork 77
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
Showing
9 changed files
with
122 additions
and
137 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
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,41 +1,61 @@ | ||
# syntax=docker/dockerfile:1.3 | ||
# syntax=docker/dockerfile:1.3-labs | ||
|
||
ARG GO_VERSION | ||
ARG GORELEASER_XX_VERSION="1.2.2" | ||
|
||
FROM --platform=$BUILDPLATFORM crazymax/goreleaser-xx:latest AS goreleaser-xx | ||
FROM --platform=$BUILDPLATFORM crazymax/goreleaser-xx:${GORELEASER_XX_VERSION} AS goreleaser-xx | ||
FROM --platform=$BUILDPLATFORM golang:${GO_VERSION}-alpine3.14 AS base | ||
ENV CGO_ENABLED=0 | ||
COPY --from=goreleaser-xx / / | ||
RUN apk add --no-cache ca-certificates gcc file git linux-headers musl-dev tar | ||
RUN apk add --no-cache file git | ||
WORKDIR /src | ||
|
||
FROM base AS vendored | ||
RUN --mount=type=bind,source=.,target=/src,rw \ | ||
--mount=type=cache,target=/go/pkg/mod \ | ||
go mod tidy && go mod download | ||
|
||
FROM vendored AS test | ||
ENV CGO_ENABLED=1 | ||
RUN apk add --no-cache gcc linux-headers musl-dev | ||
RUN --mount=type=bind,target=. \ | ||
--mount=type=cache,target=/root/.cache \ | ||
--mount=type=cache,target=/go/pkg/mod <<EOT | ||
go test -v -coverprofile=/tmp/coverage.txt -covermode=atomic -race ./... | ||
go tool cover -func=/tmp/coverage.txt | ||
EOT | ||
|
||
FROM scratch AS test-coverage | ||
COPY --from=test /tmp/coverage.txt /coverage.txt | ||
|
||
FROM base AS build | ||
ARG TARGETPLATFORM | ||
ARG GIT_REF | ||
RUN --mount=type=bind,target=/src,rw \ | ||
--mount=type=cache,target=/root/.cache \ | ||
--mount=type=cache,target=/go/pkg/mod \ | ||
goreleaser-xx --debug \ | ||
--name "ftpgrab" \ | ||
--dist "/out" \ | ||
--hooks="go mod tidy" \ | ||
--hooks="go mod download" \ | ||
--main="./cmd/main.go" \ | ||
--main="./cmd" \ | ||
--flags="-trimpath" \ | ||
--ldflags="-s -w -X 'main.version={{.Version}}'" \ | ||
--files="CHANGELOG.md" \ | ||
--files="LICENSE" \ | ||
--files="README.md" | ||
|
||
FROM scratch AS artifacts | ||
FROM scratch AS artifact | ||
COPY --from=build /out/*.tar.gz / | ||
COPY --from=build /out/*.zip / | ||
|
||
FROM scratch AS binary | ||
COPY --from=build /usr/local/bin/ftpgrab* / | ||
|
||
FROM alpine:3.14 | ||
RUN apk --update --no-cache add ca-certificates openssl | ||
COPY --from=build /usr/local/bin/ftpgrab /usr/local/bin/ftpgrab | ||
|
||
ENV FTPGRAB_DB_PATH="/db/ftpgrab.db" \ | ||
FTPGRAB_DOWNLOAD_OUTPUT="/download" | ||
|
||
RUN apk --update --no-cache add ca-certificates openssl | ||
COPY --from=build /usr/local/bin/ftpgrab /usr/local/bin/ftpgrab | ||
RUN ftpgrab --version | ||
|
||
VOLUME [ "/db", "/download" ] | ||
ENTRYPOINT [ "ftpgrab" ] |
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,3 @@ | ||
comment: false | ||
github_checks: | ||
annotations: false |
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,15 +1,15 @@ | ||
# syntax=docker/dockerfile:1.3 | ||
|
||
ARG GO_VERSION | ||
ARG GOLANGCI_LINT_VERSION="v1.37" | ||
|
||
FROM golang:${GO_VERSION}-alpine AS base | ||
RUN apk add --no-cache gcc musl-dev | ||
RUN apk add --no-cache gcc linux-headers musl-dev | ||
WORKDIR /src | ||
|
||
FROM golangci/golangci-lint:v1.37-alpine AS golangci-lint | ||
|
||
FROM golangci/golangci-lint:${GOLANGCI_LINT_VERSION}-alpine AS golangci-lint | ||
FROM base AS lint | ||
RUN --mount=type=bind,target=. \ | ||
--mount=type=cache,target=/root/.cache/go-build \ | ||
--mount=type=cache,target=/root/.cache/golangci-lint \ | ||
--mount=type=cache,target=/root/.cache \ | ||
--mount=from=golangci-lint,source=/usr/bin/golangci-lint,target=/usr/bin/golangci-lint \ | ||
golangci-lint run --timeout 10m0s ./... |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,41 @@ | ||
# syntax=docker/dockerfile:1.3 | ||
# syntax=docker/dockerfile:1.3-labs | ||
|
||
ARG GO_VERSION | ||
ARG GOMOD_OUTDATED_VERSION="v0.8.0" | ||
|
||
FROM golang:${GO_VERSION}-alpine AS base | ||
RUN apk add --no-cache git | ||
RUN apk add --no-cache git linux-headers musl-dev | ||
WORKDIR /src | ||
|
||
FROM base AS vendored | ||
RUN --mount=type=bind,target=.,rw \ | ||
--mount=type=cache,target=/go/pkg/mod \ | ||
go mod tidy && go mod download && \ | ||
mkdir /out && cp go.mod go.sum /out | ||
--mount=type=cache,target=/go/pkg/mod <<EOT | ||
set -e | ||
go mod tidy | ||
go mod download | ||
mkdir /out | ||
cp go.mod go.sum /out | ||
EOT | ||
|
||
FROM scratch AS update | ||
COPY --from=vendored /out / | ||
|
||
FROM vendored AS validate | ||
RUN --mount=type=bind,target=.,rw \ | ||
git add -A && cp -rf /out/* .; \ | ||
if [ -n "$(git status --porcelain -- go.mod go.sum)" ]; then \ | ||
echo >&2 'ERROR: Vendor result differs. Please vendor your package with "docker buildx bake vendor-update"'; \ | ||
git status --porcelain -- go.mod go.sum; \ | ||
exit 1; \ | ||
fi | ||
RUN --mount=type=bind,target=.,rw <<EOT | ||
set -e | ||
git add -A | ||
cp -rf /out/* . | ||
diff=$(git status --porcelain -- go.mod go.sum) | ||
if [ -n "$diff" ]; then | ||
echo >&2 'ERROR: Vendor result differs. Please vendor your package with "docker buildx bake vendor"' | ||
echo "$diff" | ||
exit 1 | ||
fi | ||
EOT | ||
|
||
FROM psampaz/go-mod-outdated:v0.8.0 AS go-mod-outdated | ||
FROM psampaz/go-mod-outdated:${GOMOD_OUTDATED_VERSION} AS go-mod-outdated | ||
FROM base AS outdated | ||
RUN --mount=type=bind,target=.,ro \ | ||
RUN --mount=type=bind,target=. \ | ||
--mount=type=cache,target=/go/pkg/mod \ | ||
--mount=from=go-mod-outdated,source=/home/go-mod-outdated,target=/usr/bin/go-mod-outdated \ | ||
go list -mod=readonly -u -m -json all | go-mod-outdated -update -direct |