blob: b654b67e1a3c492c8729e96c512d5b2217da2b19 [file] [log] [blame]
FROM golang:1.13 as builder
LABEL maintainer="Han-Wen Nienhuys <>"
# Set the Current Working Directory inside the container
# Copy go mod and sum files
COPY go.mod go.sum ./
RUN go version
# Download all dependencies. Dependencies will be cached if the go.mod and go.sum files are not changed
RUN go mod download
# Copy the source from the current directory to the Working Directory inside the container
COPY . .
# Build the Go app. The netgo tag ensures we build a static binary.
RUN go build -tags netgo -o gerrit-linter ./cmd/checker
RUN go build -tags netgo -o buildifier
RUN curl -L -o google-java-format.jar
RUN chmod +x google-java-format.jar
RUN cp $(which gofmt) .
FROM alpine:latest
RUN apk --no-cache add ca-certificates
# Copy the Pre-built binary file from the previous stage
COPY --from=builder /app/gerrit-linter .
COPY --from=builder /app/gofmt .
COPY --from=builder /app/buildifier .
COPY --from=builder /app/google-java-format.jar .
ENTRYPOINT [ "/app/gerrit-linter" ]
CMD []