From a2a8f46f77c45887be94f6579d623f34151e7ff5 Mon Sep 17 00:00:00 2001 From: Philip Schmid Date: Tue, 28 May 2024 22:33:20 +0200 Subject: [PATCH] Added opencontainers LABELS to Dockerfile Signed-off-by: Philip Schmid --- Dockerfile | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 279396b..2acc020 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,7 @@ # Build stage FROM --platform=$BUILDPLATFORM golang:1.22-alpine@sha256:b8ded51bad03238f67994d0a6b88680609b392db04312f60c23358cc878d4902 AS builder -# Define ARGs and ENVs to specify the target platform +# Define ARGs to specify the target platform ARG TARGETPLATFORM ARG BUILDPLATFORM ARG TARGETOS @@ -24,6 +24,16 @@ RUN CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -a -installsuff # Final stage FROM scratch +# Add metadata to the image using opencontainers labels +LABEL org.opencontainers.image.title="echo-app" \ + org.opencontainers.image.description="Tiny golang app which returns a timestamp, a customizable message, the hostname, the request source IP, and optionally the HTTP request headers." \ + org.opencontainers.image.url="https://github.com/philipschmid/echo-app" \ + org.opencontainers.image.source="https://github.com/philipschmid/echo-app" \ + org.opencontainers.image.vendor="philipschmid" \ + org.opencontainers.image.licenses="Apache-2.0 license" \ + org.opencontainers.image.revision="${VCS_REF}" \ + org.opencontainers.image.created="${BUILD_DATE}" + # Copy the compiled binary from the builder stage COPY --from=builder /main /main @@ -31,4 +41,4 @@ COPY --from=builder /main /main ENTRYPOINT ["/main"] # Expose port 8080 -EXPOSE 8080 \ No newline at end of file +EXPOSE 8080