golangci-lint/build/Dockerfile
Ludovic Fernandez 411e0bbbd3
Some checks failed
Release a tag / release (push) Has been cancelled
Release a tag / docker-release (map[Dockerfile:build/Dockerfile]) (push) Has been cancelled
Release a tag / docker-release (map[Dockerfile:build/alpine.Dockerfile]) (push) Has been cancelled
fix: add all directories as safe git directories inside the Docker image (#4034)
2023-08-21 13:04:00 +02:00

21 lines
651 B
Docker

# stage 1 building the code
FROM golang:1.21 as builder
ARG VERSION
ARG SHORT_COMMIT
ARG DATE
COPY / /golangci
WORKDIR /golangci
RUN CGO_ENABLED=0 go build -trimpath -ldflags "-s -w -X main.version=$VERSION -X main.commit=$SHORT_COMMIT -X main.date=$DATE" -o golangci-lint ./cmd/golangci-lint/main.go
# stage 2
FROM golang:1.21
# related to https://github.com/golangci/golangci-lint/issues/3107
ENV GOROOT /usr/local/go
# Set all directories as safe
RUN git config --global --add safe.directory '*'
# don't place it into $GOPATH/bin because Drone mounts $GOPATH as volume
COPY --from=builder /golangci/golangci-lint /usr/bin/
CMD ["golangci-lint"]