github.com/vanstinator/golangci-lint@v0.0.0-20240223191551-cc572f00d9d1/build/alpine.Dockerfile (about) 1 # stage 1 building the code 2 FROM golang:1.21-alpine as builder 3 4 ARG VERSION 5 ARG SHORT_COMMIT 6 ARG DATE 7 8 COPY / /golangci 9 WORKDIR /golangci 10 11 # gcc is required to support cgo; 12 # git and mercurial are needed most times for go get`, etc. 13 # See https://github.com/docker-library/golang/issues/80 14 RUN apk --no-cache add gcc musl-dev git mercurial 15 RUN APP_VERSION=${VERSION#v} \ 16 CGO_ENABLED=0 \ 17 go build -trimpath -ldflags "-s -w -X main.version=$APP_VERSION -X main.commit=$SHORT_COMMIT -X main.date=$DATE" -o golangci-lint ./cmd/golangci-lint/main.go 18 19 # stage 2 20 FROM golang:1.21-alpine 21 # related to https://github.com/vanstinator/golangci-lint/issues/3107 22 ENV GOROOT /usr/local/go 23 # gcc is required to support cgo; 24 # git and mercurial are needed most times for go get`, etc. 25 # See https://github.com/docker-library/golang/issues/80 26 RUN apk --no-cache add gcc musl-dev git mercurial 27 # Set all directories as safe 28 RUN git config --global --add safe.directory '*' 29 # don't place it into $GOPATH/bin because Drone mounts $GOPATH as volume 30 COPY --from=builder /golangci/golangci-lint /usr/bin/ 31 CMD ["golangci-lint"]