Refactor: overhaul Dockerfile with multi-stage build, non-root user, and .dockerignore#135
Merged
Merged
Conversation
…and .dockerignore - Pin golang:1.26-alpine base image (was unpinned) - Add CGO_ENABLED=0 for fully static binary (Alpine/musl compatible) - Use BuildKit TARGETARCH auto-detection (arm64 on local, amd64 on CI) - Cache go.mod/go.sum download layer separately from source - Strip debug symbols with -ldflags "-s -w" (~10% smaller binary) - Add non-root user (flowgre:100) for container security - Inject version via --build-arg VERSION at build time - Create .dockerignore to exclude .git, docs, IDE configs, build artifacts - Remove dead git submodule commands (no submodules exist) - Remove GO111MODULE env var (modules enabled by default since Go 1.16) - Image size: ~22MB (down from ~30MB with glibc baggage) - No HEALTHCHECK (flowgre is a CLI tool, not a daemon)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Complete Dockerfile rewrite — from a fragile, outdated build to a production-grade multi-stage container. Also adds a
.dockerignorefor the first time.Changes
Dockerfile
FROM golang:alpine(unpinned)FROM golang:1.26-alpine(pinned)CGO_ENABLED=0GOARCH=amd64hardcodedTARGETARCHauto-detected by BuildKitgo.mod/go.sumcached in separate layer-ldflags "-s -w"(~10% smaller)flowgre(uid 100)0.4.10--build-arg VERSIONgit submodulecommandsGO111MODULE=on(deprecated)New:
.dockerignoreExcludes
.git, docs, IDE configs, build artifacts,.nfpm/,scripts/— reduces build context from ~10MB to ~300KB.Build Instructions
Verified
uid=100 flowgre)flowgre versionworks inside container