Sign inSign up

ragedunicorn/golang

By ragedunicorn

•Updated 5 days ago

Public repository for ragedunicorn docker golang images

Image
Languages & frameworks
Integration & delivery
Developer tools
0

398

ragedunicorn/golang repository overview

⁠Go Alpine Docker Image

Docker Go

The Go toolchain on Alpine Linux, shipping a pinned upstream Go release decoupled from the Alpine version.

⁠Quick Start

# Pull latest version
docker pull ragedunicorn/golang:latest

# Or pull specific version (see the Tags tab for the available versions)
docker pull ragedunicorn/golang:<go-version>-alpine<alpine-version>-<build>

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

On Windows, use the PowerShell form - ${PWD} with braces and the colon inside the quotes (without braces PowerShell parses $PWD: as a scope-qualified variable, as in $env:PATH, and rejects the argument):

# Build the code in the current directory
docker run --rm -v "${PWD}:/app" ragedunicorn/golang:latest build ./...

⁠Features

  • 🚀 Small footprint: compact toolchain image built on Alpine Linux
  • 🐹 Upstream Go: pinned upstream release, verified by GPG at build time
  • 🔧 Cgo ready: gcc and musl-dev included, so cgo and go test -race work out of the box
  • 📦 Module aware: git for VCS module paths, pre-created cache tree at /go
  • 🔒 Security: non-root user, minimal attack surface
  • 🏗️ Multi-platform: supports linux/amd64 and linux/arm64

⁠Usage Examples

⁠Run a Go program
docker run --rm -v $(pwd):/app ragedunicorn/golang:latest run main.go

PowerShell:

docker run --rm -v "${PWD}:/app" ragedunicorn/golang:latest run main.go
⁠Build a module
docker run --rm -v $(pwd):/app -v gocache:/go ragedunicorn/golang:latest build ./...

PowerShell:

docker run --rm -v "${PWD}:/app" -v gocache:/go ragedunicorn/golang:latest build ./...
⁠Run tests, with and without the race detector
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 ./...

PowerShell:

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 ./...
⁠Produce a portable static binary
docker run --rm -v $(pwd):/app -v gocache:/go \
  -e CGO_ENABLED=0 \
  ragedunicorn/golang:latest build -o app ./cmd/app

PowerShell:

docker run --rm -v "${PWD}:/app" -v gocache:/go `
  -e CGO_ENABLED=0 `
  ragedunicorn/golang:latest build -o app ./cmd/app
⁠Build a custom image
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:latest
COPY --from=build /go/bin/app /usr/local/bin/app
ENTRYPOINT ["app"]

⁠Tags

This image uses semantic versioning that includes all component versions:

Format: {go_version}-alpine{alpine_version}-{build_number}

⁠Version Examples

X.Y.Z is the Go version, A.B.C the Alpine version:

  • X.Y.Z-alpineA.B.C-1 - Go X.Y.Z on Alpine A.B.C, build 1
  • X.Y.Z-alpineA.B.C-2 - Rebuild of same versions (bug fixes, security patches)
  • X.Y.Z - Bare Go version, tracking the most recent build of that release
  • latest - Most recent stable release

The available versions are listed in the Tags tab⁠.

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

⁠Environment Variables

  • GOPATH=/go - Pre-created and owned by the golang user
  • GOMODCACHE=/go/pkg/mod - Downloaded modules
  • GOCACHE=/go/cache - Build cache
  • GOTOOLCHAIN=local - No implicit toolchain downloads

The whole cache tree lives under GOPATH, so a single named volume mounted at /go covers both the module cache and the build cache.

⁠Working Directory

The default working directory is /app. Mount your code here:

docker run --rm -v $(pwd):/app ragedunicorn/golang:latest build ./...

PowerShell:

docker run --rm -v "${PWD}:/app" ragedunicorn/golang:latest build ./...

⁠A Note on musl

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.

⁠License

MIT License - See GitHub repository⁠ for details.

Tag summary

Content type

Image

Digest

sha256:85985e2f2…

Size

149 MB

Last updated

5 days ago

docker pull ragedunicorn/golang