1. There is no need to persist DOCKER_GITCOMMIT,
as it's not needed for runtime, only for build.
So, remove ENV.
2. In case $GITCOMMIT is not defined during build time
(and it happens if .git directory is not present),
we still need to have some value set, so set it to
`undefined`. Otherwise we'll have something like
> => ERROR [builder 2/3] RUN hack/make.sh build-integration-test-binary
> ------
> > [builder 2/3] RUN hack/make.sh build-integration-test-binary:
> #32 0.488
> #32 0.505 error: .git directory missing and DOCKER_GITCOMMIT not specified
> #32 0.505 Please either build with the .git directory accessible, or specify the
> #32 0.505 exact (--short) commit hash you are building using DOCKER_GITCOMMIT for
> #32 0.505 future accountability in diagnosing build issues. Thanks!
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
(cherry picked from commit c3b24944ca10edb835de6e806ad6cd9e952ebc11)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
| ... | ... |
@@ -40,12 +40,11 @@ RUN CGO_ENABLED=0 go build -buildmode=pie -o /build/httpserver/httpserver github |
| 40 | 40 |
FROM base AS builder |
| 41 | 41 |
|
| 42 | 42 |
# Set tag and add sources |
| 43 |
-ARG DOCKER_GITCOMMIT |
|
| 44 |
-ENV DOCKER_GITCOMMIT=${DOCKER_GITCOMMIT:-undefined}
|
|
| 45 | 43 |
COPY . . |
| 46 | 44 |
# Copy test sources tests that use assert can print errors |
| 47 | 45 |
RUN mkdir -p /build${PWD} && find integration integration-cli -name \*_test.go -exec cp --parents '{}' /build${PWD} \;
|
| 48 | 46 |
# Build and install test binaries |
| 47 |
+ARG DOCKER_GITCOMMIT=undefined |
|
| 49 | 48 |
RUN hack/make.sh build-integration-test-binary |
| 50 | 49 |
RUN mkdir -p /build/tests && find . -name test.main -exec cp --parents '{}' /build/tests \;
|
| 51 | 50 |
|