plugin-sonar/Dockerfile

47 lines
1.3 KiB
Docker
Raw Normal View History

2022-10-30 19:29:33 +00:00
FROM golang:1.19-alpine as go-build
ARG GO_WORK="/go/src/git.kle.li/woodpecker/plugin-sonar"
RUN mkdir -p "${GO_WORK}"
WORKDIR "${GO_WORK}"
COPY ./ "${GO_WORK}/"
RUN go mod download \
&& go mod verify \
&& go build -o /plugin-sonar ./cmd/main.go
FROM alpine:latest as sonar-prep
ARG SONAR_VERSION=4.7.0.2747
ARG SONAR_SCANNER_CLI=sonar-scanner-cli-${SONAR_VERSION}
ARG SONAR_SCANNER=sonar-scanner-${SONAR_VERSION}
WORKDIR "/sonar"
RUN apk add --no-cache --update curl unzip
RUN curl https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/${SONAR_SCANNER_CLI}.zip -so "/sonar/${SONAR_SCANNER_CLI}.zip" \
&& unzip "${SONAR_SCANNER_CLI}.zip" \
&& rm "${SONAR_SCANNER_CLI}.zip" \
&& pwd && ls -la \
&& mv "${SONAR_SCANNER}" "/sonar/sonar-scanner" \
&& echo "${SONAR_VERSION}" > "/sonar/sonar-scanner/version"
FROM alpine:latest
# set / add low change items
WORKDIR /bin
RUN apk add --no-cache --update nodejs npm && rm -rf /var/cache/apk/*
ENV JAVA_HOME=/opt/java/openjdk
COPY --from=eclipse-temurin:17-jre-alpine $JAVA_HOME $JAVA_HOME
ENV PATH="${JAVA_HOME}/bin:${PATH}"
# add plugin binary
RUN echo "/plugin-sonar $SONAR_SCANNER"
COPY --from=go-build "/plugin-sonar" /bin/
# add sonar download
COPY --from=sonar-prep "/sonar" /bin/
ENV PATH $PATH:/bin/sonar-scanner/bin
ENTRYPOINT [ "/bin/plugin-sonar" ]