Public repository for ragedunicorn docker golang images
171

The Go toolchain on Alpine Linux, shipping a pinned upstream Go release decoupled from the Alpine version.
# Pull latest version
docker pull ragedunicorn/golang:latest
# Or pull specific version
docker pull ragedunicorn/golang:1.27.0-alpine3.24.1-1
# Print the Go version
docker run --rm ragedunicorn/golang:latest
# Build the code in the current directory
docker run --rm -v $(pwd):/app ragedunicorn/golang:latest build ./...
go test -race work out of the box/godocker run --rm -v $(pwd):/app ragedunicorn/golang:latest run main.go
docker run --rm -v $(pwd):/app -v gocache:/go ragedunicorn/golang:latest build ./...
docker run --rm -v $(pwd):/app -v gocache:/go ragedunicorn/golang:latest test ./...
docker run --rm -v $(pwd):/app -v gocache:/go ragedunicorn/golang:latest test -race ./...
docker run --rm -v $(pwd):/app -v gocache:/go \
-e CGO_ENABLED=0 \
ragedunicorn/golang:latest build -o app ./cmd/app
FROM ragedunicorn/golang:latest AS build
WORKDIR /app
COPY --chown=golang:golang . .
RUN CGO_ENABLED=0 go build -o /go/bin/app ./cmd/app
FROM alpine:3.24.1
COPY --from=build /go/bin/app /usr/local/bin/app
ENTRYPOINT ["app"]
This image uses semantic versioning that includes all component versions:
Format: {go_version}-alpine{alpine_version}-{build_number}
1.27.0-alpine3.24.1-1 - Go 1.27.0 on Alpine 3.24.1, build 11.27.0-alpine3.24.1-2 - Rebuild of same versions (bug fixes, security patches)1.27.0 - Bare Go version, tracking the most recent build of that releaselatest - Most recent stable releaseThe Go version is pinned per release and updated independently of Alpine. When updates are available through automated dependency management, new releases are created with appropriate version tags.
GOPATH=/go - Pre-created and owned by the golang userGOMODCACHE=/go/pkg/mod - Downloaded modulesGOCACHE=/go/cache - Build cacheGOTOOLCHAIN=local - No implicit toolchain downloadsThe whole cache tree lives under GOPATH, so a single named volume mounted at /go covers both the module cache and the build cache.
The default working directory is /app. Mount your code here:
docker run --rm -v $(pwd):/app ragedunicorn/golang:latest build ./...
The image is Alpine based, so cgo builds link against musl rather than glibc and will not run on a glibc host. Set CGO_ENABLED=0 for a fully static binary that runs anywhere.
MIT License - See GitHub repository for details.
Content type
Image
Digest
sha256:0fa4dcc9e…
Size
148.9 MB
Last updated
about 1 month ago
docker pull ragedunicorn/golang