{"id":1004,"slug":"secure-base-images","title":"Secure Base Images for Docker","excerpt":"A minimal, security-hardened Docker base image for Go binaries","content":"\u003cp\u003eDo you hate insecure base images?  Sure, we all do..\u003c/p\u003e\n\u003cp\u003eI built a thing: \u003ca href=\"https://github.com/swantron/secure-base-images\"\u003esecure-base-images\u003c/a\u003e. It\u0026rsquo;s a minimal, security-hardened Docker base image for static Go binaries.\u003c/p\u003e\n\u003cp\u003e\u003cimg src=\"/uploads/2025/11/secure-base-ci-workflow.png\" alt=\"CI workflow running tests and build\"\n  loading=\"lazy\"\n  decoding=\"async\"\n/\u003e\n\u003c/p\u003e\n\u003cp\u003eMost Docker images are bloated. Shells, package managers, and a ton of dependencies you don\u0026rsquo;t need. That\u0026rsquo;s attack surface your security team loves to talk about, and it drives fast pipeline guys like me insane. For a static Go tool you literally just need the binary and some certs.\u003c/p\u003e\n\u003cp\u003eSo this one is the binary and some certs. No shell, no package manager, runs as uid 65532, amd64 and arm64. Three lines in ya Dockerfile:\u003c/p\u003e\n\u003cdiv class=\"highlight\"\u003e\u003cpre tabindex=\"0\" style=\"color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;\"\u003e\u003ccode class=\"language-dockerfile\" data-lang=\"dockerfile\"\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e\u003cspan style=\"color:#66d9ef\"\u003eFROM\u003c/span\u003e \u003cspan style=\"color:#e6db74\"\u003eswantron/secure-base:latest\u003c/span\u003e\u003cspan style=\"color:#960050;background-color:#1e0010\"\u003e\n\u003c/span\u003e\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e\u003cspan style=\"color:#66d9ef\"\u003eCOPY\u003c/span\u003e myapp /app\u003cspan style=\"color:#960050;background-color:#1e0010\"\u003e\n\u003c/span\u003e\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e\u003cspan style=\"color:#66d9ef\"\u003eENTRYPOINT\u003c/span\u003e [\u003cspan style=\"color:#e6db74\"\u003e\u0026#34;/app\u0026#34;\u003c/span\u003e]\u003cspan style=\"color:#960050;background-color:#1e0010\"\u003e\n\u003c/span\u003e\u003c/span\u003e\u003c/span\u003e\u003c/code\u003e\u003c/pre\u003e\u003c/div\u003e\u003cp\u003ePush a tag, GitHub Actions builds it, scans it with Trivy, and publishes to Docker Hub if it\u0026rsquo;s clean (it is.)\u003c/p\u003e\n\u003cp\u003e\u003cimg src=\"/uploads/2025/11/secure-base-trivy-scan.png\" alt=\"Clean Trivy scan - zero vulnerabilities\"\n  loading=\"lazy\"\n  decoding=\"async\"\n/\u003e\n\u003c/p\u003e\n\u003ch2 id=\"under-the-hood\"\u003eUnder the Hood\u003c/h2\u003e\n\u003cp\u003eThe workflow does the heavy lifting:\u003c/p\u003e\n\u003col\u003e\n\u003cli\u003eRuns integration tests (non-root user, no shell, CA certs present, etc.)\u003c/li\u003e\n\u003cli\u003eBuilds the image\u003c/li\u003e\n\u003cli\u003eScans with Trivy - build \u003cstrong\u003efails\u003c/strong\u003e on CRITICAL/HIGH\u003c/li\u003e\n\u003cli\u003eMulti-platform build (amd64/arm64)\u003c/li\u003e\n\u003cli\u003ePushes to Docker Hub on release tags\u003c/li\u003e\n\u003c/ol\u003e\n\u003cp\u003e\u003cimg src=\"/uploads/2025/11/secure-base-dockerhub.png\" alt=\"Published to Docker Hub with latest and version tags\"\n  loading=\"lazy\"\n  decoding=\"async\"\n/\u003e\n\u003c/p\u003e\n\u003cp\u003eSource: \u003ca href=\"https://github.com/swantron/secure-base-images\"\u003ehttps://github.com/swantron/secure-base-images\u003c/a\u003e\u003c/p\u003e\n\u003cp\u003eDocker Hub: \u003ccode\u003eswantron/secure-base:latest\u003c/code\u003e\u003c/p\u003e\n\u003cp\u003eThe \u003ca href=\"https://github.com/swantron/secure-base-images/blob/main/QUICKSTART.md\"\u003eQUICKSTART.md\u003c/a\u003e gets you from zero to published in about 10 minutes.\u003c/p\u003e\n","date":"2025-11-30T04:45:00Z","permalink":"https://swantron.com/2025/11/30/secure-base-images/","link":"https://swantron.com/2025/11/30/secure-base-images/","path":"/2025/11/30/secure-base-images/","featuredImage":"/uploads/2025/11/secure-base-ci-workflow.png","categories":[],"tags":[]}