Skip to content

feat(server): multi-stage Dockerfile that builds Go from source#19

Open
Flo5k5 wants to merge 1 commit intom5stack:mainfrom
Flo5k5:feat/multi-stage-dockerfile
Open

feat(server): multi-stage Dockerfile that builds Go from source#19
Flo5k5 wants to merge 1 commit intom5stack:mainfrom
Flo5k5:feat/multi-stage-dockerfile

Conversation

@Flo5k5
Copy link
Copy Markdown

@Flo5k5 Flo5k5 commented Apr 22, 2026

The previous Dockerfile assumed that the Go binary was already built on
the host and copied into the build context before running docker build.
That required a separate prep step, only worked when the host arch
matched the target, and made the docker.sh pre-build shell mandatory.

The multi-stage version compiles the server inside the image using
golang:1.24-alpine, so a plain "docker build" works out of the box on
any platform supported by the builder (amd64, arm64...). This is what
lets a homelab node cross-build and run the server natively on
Raspberry Pi without juggling pre-compiled binaries.

Also:

  • build with -trimpath and stripped symbols for smaller images
  • install ca-certificates and tzdata in the runtime layer so TLS and
    timezone-aware logging work correctly
  • EXPOSE 12800 so compose tools and scanners see the port
  • run the binary via absolute path to remove the implicit ./ in CMD

The previous Dockerfile assumed that the Go binary was already built on
the host and copied into the build context before running docker build.
That required a separate prep step, only worked when the host arch
matched the target, and made the docker.sh pre-build shell mandatory.

The multi-stage version compiles the server inside the image using
golang:1.24-alpine, so a plain "docker build" works out of the box on
any platform supported by the builder (amd64, arm64...). This is what
lets a homelab node cross-build and run the server natively on
Raspberry Pi without juggling pre-compiled binaries.

Also:
- build with -trimpath and stripped symbols for smaller images
- install ca-certificates and tzdata in the runtime layer so TLS and
  timezone-aware logging work correctly
- EXPOSE 12800 so compose tools and scanners see the port
- run the binary via absolute path to remove the implicit ./ in CMD
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant