From 430008800d91f8ca303dbb60f90da0d0a1972a9c Mon Sep 17 00:00:00 2001 From: Jason Ernst Date: Sat, 17 Oct 2026 02:26:00 -0700 Subject: [PATCH 1/2] Multi-stage Docker build: 1.65 GB -> 152 MB Compile in golang:1.26.1-trixie, run on debian:trixie-slim (same glibc, since SQLite and Go plugins need cgo) with only the binary, www/, themes/ and templates/. The working directory is unchanged, so bind mounts and docker exec ./goblog keep working. Closes #680 Co-Authored-By: Claude Opus 5.5 --- Dockerfile | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/Dockerfile b/Dockerfile index 17be83a0..38b9d405 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,20 +1,29 @@ -# Start from a Debian image with the latest version of Go installed -# and a workspace (GOPATH) configured at /go. -FROM golang:1.26.1 +# Build stage: the Go toolchain is only needed to compile. cgo is on +# (SQLite and Go plugins need it), so the runtime base below must be the +# same Debian release, for a matching glibc. +FROM golang:1.26.1-trixie AS build -# Copy the local package files to the container's workspace. ADD . /go/src/github.com/compscidr/goblog/ -# Build the outyet command inside the container. -# (You may fetch or manage dependencies here, -# either manually or with a tool like "godep".) ARG VERSION RUN cd /go/src/github.com/compscidr/goblog/ && go build -ldflags="-X 'main.Version=$VERSION'" -v . -# Run the outyet command by default when the container starts. -# So `docker exec ./goblog reset-admin-password` finds .env. +FROM debian:trixie-slim + +# ca-certificates: outgoing HTTPS (OAuth, the plugin directory, SMTP over TLS). +RUN apt-get update && apt-get install -y --no-install-recommends ca-certificates \ + && rm -rf /var/lib/apt/lists/* + +# Same path as before, so existing bind mounts still line up, and +# `docker exec ./goblog reset-admin-password` finds .env. WORKDIR /go/src/github.com/compscidr/goblog +# The binary plus what it reads from the working directory at runtime. +COPY --from=build /go/src/github.com/compscidr/goblog/goblog ./ +COPY www ./www +COPY themes ./themes +COPY templates ./templates + ENTRYPOINT cd /go/src/github.com/compscidr/goblog && ./goblog # Document that the service listens on port 7000. From b9f288f8c9bf470f59cf04687175e4047d88f0d6 Mon Sep 17 00:00:00 2001 From: Jason Ernst Date: Sat, 17 Oct 2026 02:31:59 -0700 Subject: [PATCH 2/2] Dockerfile: only the SQLite driver needs cgo Co-Authored-By: Claude Opus 5.5 --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 38b9d405..778b43a2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ # Build stage: the Go toolchain is only needed to compile. cgo is on -# (SQLite and Go plugins need it), so the runtime base below must be the -# same Debian release, for a matching glibc. +# (the SQLite driver, mattn/go-sqlite3, needs it), so the runtime base +# below must be the same Debian release, for a matching glibc. FROM golang:1.26.1-trixie AS build ADD . /go/src/github.com/compscidr/goblog/