Sign inSign up

widnyana/go-builder

By widnyana

•Updated about 1 year ago

Container image for golang multistage build

Image
Developer tools
0

4.1K

widnyana/go-builder repository overview

⁠Go Builder

container image for your Golang multistage build process

⁠Usage

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 ...

⁠License

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.

Tag summary

Content type

Image

Digest

sha256:fc6b5eb63…

Size

179.6 MB

Last updated

about 1 year ago

docker pull widnyana/go-builder:1.24-alpine