2023-08-23 16:29:02 +02:00
|
|
|
FROM golang:1.19 AS build-env
|
2019-10-22 15:41:27 +02:00
|
|
|
COPY . /build
|
|
|
|
WORKDIR /build
|
|
|
|
|
|
|
|
# execute tests
|
2023-06-26 17:19:36 +02:00
|
|
|
RUN go test ./... -tags=unit -cover
|
2019-10-22 15:41:27 +02:00
|
|
|
|
|
|
|
## ONLY tests so far, building to be added later
|
|
|
|
# execute build
|
2020-02-27 16:01:38 +02:00
|
|
|
# with `-tags release` we ensure that shared test utilities won't end up in the binary
|
2019-10-31 14:57:29 +02:00
|
|
|
RUN export GIT_COMMIT=$(git rev-parse HEAD) && \
|
2019-11-11 16:31:02 +02:00
|
|
|
export GIT_REPOSITORY=$(git config --get remote.origin.url) && \
|
2020-01-24 15:30:27 +02:00
|
|
|
CGO_ENABLED=0 go build \
|
2019-11-11 17:38:25 +02:00
|
|
|
-ldflags \
|
|
|
|
"-X github.com/SAP/jenkins-library/cmd.GitCommit=${GIT_COMMIT} \
|
2020-01-29 14:17:54 +02:00
|
|
|
-X github.com/SAP/jenkins-library/pkg/log.LibraryRepository=${GIT_REPOSITORY} \
|
2021-05-10 19:18:16 +02:00
|
|
|
-X github.com/SAP/jenkins-library/pkg/log.LibraryName=piper-lib-os \
|
2020-01-29 14:17:54 +02:00
|
|
|
-X github.com/SAP/jenkins-library/pkg/telemetry.LibraryRepository=${GIT_REPOSITORY}" \
|
2020-02-27 16:01:38 +02:00
|
|
|
-tags release \
|
2019-11-11 16:31:02 +02:00
|
|
|
-o piper
|
2019-10-22 15:41:27 +02:00
|
|
|
|
|
|
|
# FROM gcr.io/distroless/base:latest
|
|
|
|
# COPY --from=build-env /build/piper /piper
|
|
|
|
# ENTRYPOINT ["/piper"]
|