mirror of
https://github.com/dockersrc/go
synced 2026-06-24 14:01:08 -04:00
♻️ Make GO_MODE canonical; MODE becomes alias ♻️
GO_MODE fits the GO_* naming convention. MODE is kept as a convenience alias. Resolution order: GO_MODE → MODE → GO_PROD=1 (legacy). - rootfs/usr/local/bin/go-workflow: resolve _RESOLVED_MODE from GO_MODE with MODE as fallback; warn message now references GO_MODE; logic otherwise unchanged - README.md: rename MODE row to GO_MODE (canonical); add MODE row as alias; update production mode section to use GO_MODE=prod README.md rootfs/usr/local/bin/go-workflow
This commit is contained in:
@@ -34,17 +34,17 @@ docker run --rm -v "$PWD:/app" casjaysdev/go:latest
|
||||
|
||||
### Production mode
|
||||
|
||||
Set `MODE=prod` 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.
|
||||
Set `GO_MODE=prod` 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 MODE=prod casjaysdev/go:latest
|
||||
docker run --rm -v "$PWD:/app" -e GO_MODE=prod casjaysdev/go:latest
|
||||
```
|
||||
|
||||
`MODE=production` is also accepted. `GO_PROD=1` is a legacy alias that still
|
||||
works when `MODE` is not set.
|
||||
`GO_MODE=production` is also accepted. `MODE` is an alias for `GO_MODE`.
|
||||
`GO_PROD=1` is a legacy alias that still works when `GO_MODE` is not set.
|
||||
|
||||
### One-shot commands
|
||||
|
||||
@@ -203,8 +203,9 @@ volumes:
|
||||
| `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 |
|
||||
| `MODE` | `development` | Build mode: `prod`/`production` or `dev`/`devel`/`development` |
|
||||
| `GO_PROD` | *(unset)* | Legacy alias for `MODE=prod` — set to `1`; superseded by `MODE` |
|
||||
| `GO_MODE` | `development` | Build mode: `prod`/`production` or `dev`/`devel`/`development` |
|
||||
| `MODE` | *(unset)* | Alias for `GO_MODE` — `GO_MODE` takes precedence when both are set |
|
||||
| `GO_PROD` | *(unset)* | Legacy alias — `GO_PROD=1` equals `GO_MODE=prod`; superseded by `GO_MODE` |
|
||||
| `TZ` | `America/New_York` | Override at run time with `-e TZ=...` |
|
||||
|
||||
Opt into CGO per build without changing the image:
|
||||
|
||||
@@ -29,19 +29,21 @@ run_step() {
|
||||
echo ""
|
||||
}
|
||||
|
||||
# Resolve build mode from MODE or the legacy GO_PROD=1 flag.
|
||||
# MODE=prod|production → strip binary (-trimpath -ldflags=-s -w); applied to go build only
|
||||
# MODE=dev|devel|development → default; full debug info, readable stack traces
|
||||
# GO_PROD=1 is kept for backwards compatibility and takes effect when MODE is unset.
|
||||
# Resolve build mode. Resolution order (first non-empty value wins):
|
||||
# GO_MODE — canonical name; prod|production or dev|devel|development
|
||||
# MODE — alias for GO_MODE (accepted for convenience)
|
||||
# GO_PROD — legacy flag; GO_PROD=1 maps to production mode
|
||||
# -trimpath -ldflags=-s -w applied to go build only; go test is unaffected.
|
||||
_RESOLVED_MODE="${GO_MODE:-${MODE:-}}"
|
||||
_IS_PROD=0
|
||||
case "${MODE:-}" in
|
||||
case "${_RESOLVED_MODE}" in
|
||||
prod | production) _IS_PROD=1 ;;
|
||||
dev | devel | development) _IS_PROD=0 ;;
|
||||
"")
|
||||
[ "${GO_PROD:-0}" = "1" ] && _IS_PROD=1
|
||||
;;
|
||||
*)
|
||||
echo "Warning: unknown MODE '${MODE}' — expected prod|production|dev|devel|development; defaulting to development" >&2
|
||||
echo "Warning: unknown GO_MODE '${_RESOLVED_MODE}' — expected prod|production|dev|devel|development; defaulting to development" >&2
|
||||
;;
|
||||
esac
|
||||
|
||||
|
||||
Reference in New Issue
Block a user