refactor: adopt portigo infrastructure patterns

Add config package with build-tag-switched dev/prod environments,
structured logging via zerolog, Taskfile for dev workflow, golangci-lint
config, testutil package, and improved DB setup with proper SQLite
pragmas and cleanup. Rename sqlc output package from gen to repository.

Switch to allowlist .gitignore, Alpine+UPX+scratch Dockerfile, and
CI pipeline with test/lint gates before deploy.
This commit is contained in:
Ryan Hamamura
2026-03-02 11:48:47 -10:00
parent 6d4f3eb821
commit 2df20c2840
27 changed files with 694 additions and 143 deletions

View File

@@ -1,4 +1,6 @@
FROM golang:1.25.4-bookworm AS build
FROM docker.io/golang:1.25.4-alpine AS build
RUN apk add --no-cache upx
WORKDIR /src
COPY go.mod go.sum ./
@@ -6,24 +8,11 @@ RUN go mod download
COPY . .
RUN go tool gotailwind -i assets/css/input.css -o assets/css/output.css --minify
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o /c4 .
RUN --mount=type=cache,target=/root/.cache/go-build \
CGO_ENABLED=0 go build -ldflags="-s" -o /bin/c4 .
RUN upx -9 -k /bin/c4
FROM debian:bookworm-slim
RUN apt-get update && \
apt-get install -y --no-install-recommends ca-certificates wget && \
rm -rf /var/lib/apt/lists/*
COPY --from=build /c4 /usr/local/bin/c4
WORKDIR /app
RUN mkdir data && chown games:games data
USER games
EXPOSE 8080
HEALTHCHECK --interval=30s --timeout=5s --start-period=5s --retries=3 \
CMD wget -qO /dev/null http://localhost:8080/
CMD ["c4"]
FROM scratch
ENV PORT=8080
COPY --from=build /bin/c4 /
ENTRYPOINT ["/c4"]