mirror of
https://github.com/dockersrc/go
synced 2026-06-24 14:01:08 -04:00
📝 Update README with new env vars and production build mode 📝
- README.md: add GOBIN, GOFLAGS, GOPROXY, GOTELEMETRY to env vars table with descriptions and example override commands - README.md: add GO_PROD=1 production mode section under Docker usage, explaining -trimpath and -ldflags=-s -w behaviour - README.md: rename "📦 Pull" section to "📦 Install" per canonical layout - README.md: add GOPROXY private registry override example README.md
This commit is contained in:
@@ -9,7 +9,7 @@ you can opt in per build.
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## 📦 Pull
|
## 📦 Install
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
docker pull casjaysdev/go:latest
|
docker pull casjaysdev/go:latest
|
||||||
@@ -21,8 +21,8 @@ docker pull casjaysdev/go:latest
|
|||||||
|
|
||||||
### Default workflow — no args needed
|
### Default workflow — no args needed
|
||||||
|
|
||||||
Mount your project at `/app` and run with no arguments. The container will
|
Mount your project at `/app` and run with no arguments. The container
|
||||||
automatically run the full Go workflow:
|
automatically runs the full Go workflow:
|
||||||
|
|
||||||
```
|
```
|
||||||
go mod tidy → gofmt -w . → go vet ./... → go test ./... → go build ./...
|
go mod tidy → gofmt -w . → go vet ./... → go test ./... → go build ./...
|
||||||
@@ -32,6 +32,17 @@ go mod tidy → gofmt -w . → go vet ./... → go test ./... → go bui
|
|||||||
docker run --rm -v "$PWD:/app" casjaysdev/go:latest
|
docker run --rm -v "$PWD:/app" casjaysdev/go:latest
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Production mode
|
||||||
|
|
||||||
|
Set `GO_PROD=1` to strip binaries for release: `-trimpath` removes all local
|
||||||
|
file system paths; `-ldflags=-s -w` strips the symbol table and DWARF debug
|
||||||
|
info. Applied to `go build` only — `go test` is unaffected so stack traces
|
||||||
|
stay readable.
|
||||||
|
|
||||||
|
```shell
|
||||||
|
docker run --rm -v "$PWD:/app" -e GO_PROD=1 casjaysdev/go:latest
|
||||||
|
```
|
||||||
|
|
||||||
### One-shot commands
|
### One-shot commands
|
||||||
|
|
||||||
Pass any command and it runs directly instead of the default workflow:
|
Pass any command and it runs directly instead of the default workflow:
|
||||||
@@ -179,21 +190,33 @@ volumes:
|
|||||||
| Variable | Default | Purpose |
|
| Variable | Default | Purpose |
|
||||||
|----------|---------|---------|
|
|----------|---------|---------|
|
||||||
| `GOPATH` | `/usr/local/share/go` | Workspace; declared as `VOLUME` |
|
| `GOPATH` | `/usr/local/share/go` | Workspace; declared as `VOLUME` |
|
||||||
|
| `GOBIN` | `/usr/local/bin` | Destination for `go install` binaries |
|
||||||
| `GOCACHE` | `/usr/local/share/go/cache` | Build cache (persisted in volume) |
|
| `GOCACHE` | `/usr/local/share/go/cache` | Build cache (persisted in volume) |
|
||||||
| `GOMODCACHE` | *(defaults to `$GOPATH/pkg/mod`)* | Module cache |
|
|
||||||
| `CGO_ENABLED` | `0` | Static builds by default — override per build |
|
| `CGO_ENABLED` | `0` | Static builds by default — override per build |
|
||||||
| `GOTOOLCHAIN` | `auto` | Auto-fetch the Go version declared in `go.mod` |
|
| `GOTOOLCHAIN` | `auto` | Auto-fetch the Go version declared in `go.mod` |
|
||||||
|
| `GOFLAGS` | `-buildvcs=false` | Suppress VCS stamp errors on mounted projects |
|
||||||
|
| `GOPROXY` | `https://proxy.golang.org,direct` | Module proxy — override for private registries |
|
||||||
|
| `GOTELEMETRY` | `off` | Disable Go 1.23+ telemetry |
|
||||||
|
| `GO_PROD` | *(unset)* | Set to `1` to enable `-trimpath -ldflags=-s -w` on `go build` |
|
||||||
| `TZ` | `America/New_York` | Override at run time with `-e TZ=...` |
|
| `TZ` | `America/New_York` | Override at run time with `-e TZ=...` |
|
||||||
|
|
||||||
Opt into CGO per build without changing the image:
|
Opt into CGO per build without changing the image:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
docker run --rm -v "$PWD:/app" -w /app \
|
docker run --rm -v "$PWD:/app" \
|
||||||
-e CGO_ENABLED=1 \
|
-e CGO_ENABLED=1 \
|
||||||
casjaysdev/go:latest \
|
casjaysdev/go:latest \
|
||||||
go build ./...
|
go build ./...
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Override the module proxy for a private registry:
|
||||||
|
|
||||||
|
```shell
|
||||||
|
docker run --rm -v "$PWD:/app" \
|
||||||
|
-e GOPROXY=https://goproxy.corp.internal,direct \
|
||||||
|
casjaysdev/go:latest
|
||||||
|
```
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## 🗂️ PATH order
|
## 🗂️ PATH order
|
||||||
@@ -257,13 +280,6 @@ cd "$HOME/Projects/github/dockersrc/go"
|
|||||||
docker build --tag casjaysdev/go:test .
|
docker build --tag casjaysdev/go:test .
|
||||||
```
|
```
|
||||||
|
|
||||||
### Get source files
|
|
||||||
|
|
||||||
```shell
|
|
||||||
git clone "https://github.com/dockersrc/go" \
|
|
||||||
"$HOME/Projects/github/dockersrc/go"
|
|
||||||
```
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## 📄 License
|
## 📄 License
|
||||||
@@ -274,4 +290,4 @@ MIT
|
|||||||
|
|
||||||
🤖 [casjay](https://github.com/casjay)
|
🤖 [casjay](https://github.com/casjay)
|
||||||
⛵ [casjaysdev](https://github.com/casjaysdev)
|
⛵ [casjaysdev](https://github.com/casjaysdev)
|
||||||
🐳 [Docker Hub](https://hub.docker.com/u/casjaysdev)
|
🐳 [Docker Hub](https://hub.docker.com/u/casjaysdev)
|
||||||
|
|||||||
Reference in New Issue
Block a user