Improve Docker build with version information
Change-Id: I76983897cb77730e6c4d659b6aaa92fee54ddc85
diff --git a/Dockerfile b/Dockerfile
index 967f8bf..4012f44 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -13,10 +13,14 @@
RUN CGO_ENABLED=0 go test ./...
+ARG BUILDDATE="[unset]"
+ARG BUILDCOMMIT="[unset]"
+ARG BUILDVERSION="EARLY"
+
# Build static
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 \
go build -v \
- -ldflags "-extldflags '-static' -s -w" \
+ -ldflags "-X github.com/KorAP/Koral-Mapper/config.Buildtime=${BUILDDATE} -X github.com/KorAP/Koral-Mapper/config.Buildhash=${BUILDCOMMIT} -X github.com/KorAP/Koral-Mapper/config.Version=${BUILDVERSION} -extldflags '-static' -s -w" \
--trimpath \
-o /src/koralmapper ./cmd/koralmapper/
@@ -34,6 +38,10 @@
EXPOSE 5725
+ARG BUILDVERSION="EARLY"
+ARG BUILDCOMMIT="[unset]"
+ARG BUILDDATE="1970-01-01T00:00:00Z"
+
COPY --from=build /etc/ssl/certs /etc/ssl/certs
COPY --from=build /src/mappings /mappings
COPY --from=upx /koralmapper /koralmapper
@@ -43,6 +51,13 @@
LABEL maintainer="korap@ids-mannheim.de"
LABEL description="Docker Image for Koral-Mapper"
LABEL repository="https://github.com/KorAP/Koral-Mapper"
+LABEL org.opencontainers.image.title="Koral-Mapper"
+LABEL org.opencontainers.image.description="Docker Image for Koral-Mapper"
+LABEL org.opencontainers.image.url="https://github.com/KorAP/Koral-Mapper"
+LABEL org.opencontainers.image.source="https://github.com/KorAP/Koral-Mapper"
+LABEL org.opencontainers.image.created="${BUILDDATE}"
+LABEL org.opencontainers.image.revision="${BUILDCOMMIT}"
+LABEL org.opencontainers.image.version="${BUILDVERSION}"
# docker build -f Dockerfile -t korap/koral-mapper:latest .
# docker run --rm --network host korap/koral-mapper:latest -m /mappings/*.yaml