Container image for golang multistage build
4.1K
container image for your Golang multistage build process
FROM widnyana/go-builder:1.20-bookworm as builder
WORKDIR /app
COPY . /app
ENV GO111MODULE=on \
CGO_ENABLED=0 \
GOOS=linux
RUN set -ex \
&& cd /app \
&& go mod download \
&& GIT_TAG=$(git describe --abbrev=0 2> /dev/null || echo "no tag") \
COMMIT=$(git log -1 --pretty=format:"%at-%h" 2> /dev/null || echo "no commit") \
COMMIT_MSG=$(git log -1 --pretty=format:"%s"2> /dev/null || echo "no msg") \
go build -a -i \
-ldflags "-w \
-X 'package/config.CommitMsg=${COMMIT_MSG}' \
-X 'package/config.CommitHash=${COMMIT}' \
-X 'package/config.AppVersion=${GIT_TAG}'" \
-o whatever \
FROM debian:bookworm
ARG WHATEVER_HTTP_PORT=2525
WORKDIR /root/
COPY --from=builder /app/whatever .
# Do as you want ...
Copyright © 2020 widnyana <wid -at- widnyana.web.id>
This work is free. You can redistribute it and/or modify it under the
terms of the Do What The Fuck You Want To Public License, Version 2,
as published by Sam Hocevar.
Content type
Image
Digest
sha256:fc6b5eb63…
Size
179.6 MB
Last updated
about 1 year ago
docker pull widnyana/go-builder:1.24-alpine