feat: create multi-stage Dockerfile for distroless production image #63

Closed
opened 2026-03-26 19:24:51 +00:00 by AI-Manager · 1 comment
Owner

Roadmap Reference

Phase 3, Section 3.1 — Dockerfile

What to do

Create a Dockerfile at the repo root using a two-stage build:

Stage 1 — builder:

  • FROM golang:1.22-alpine AS builder
  • WORKDIR /app
  • Copy go.mod and go.sum, run go mod download
  • Copy source, run CGO_ENABLED=0 go build -ldflags=-s -w -o /gitea-mobile ./cmd/server

Stage 2 — runtime:

  • FROM gcr.io/distroless/static:nonroot
  • COPY the binary, static/ directory, and internal/templates/ directory
  • EXPOSE 8080
  • ENTRYPOINT ["/gitea-mobile"]

Additional requirements:

  • Add a .dockerignore excluding .git, flake.nix, flake.lock, and test files
  • Verify the final image is under 25MB with docker image ls
  • Test locally: docker build -t gitea-mobile:local . and docker run with required env vars, confirm GET /health returns 200

Acceptance Criteria

  • docker build completes without errors
  • Final image size is under 25MB
  • Container starts and responds 200 on GET /health
  • No shell, package manager, or unnecessary binaries in the final image (distroless)
  • Depends on #52 (scaffold), #53 (config), #54 (auth), #55 (aggregation layer), #56 (handlers)
## Roadmap Reference Phase 3, Section 3.1 — Dockerfile ## What to do Create a Dockerfile at the repo root using a two-stage build: Stage 1 — builder: - FROM golang:1.22-alpine AS builder - WORKDIR /app - Copy go.mod and go.sum, run go mod download - Copy source, run CGO_ENABLED=0 go build -ldflags=-s -w -o /gitea-mobile ./cmd/server Stage 2 — runtime: - FROM gcr.io/distroless/static:nonroot - COPY the binary, static/ directory, and internal/templates/ directory - EXPOSE 8080 - ENTRYPOINT ["/gitea-mobile"] Additional requirements: - Add a .dockerignore excluding .git, flake.nix, flake.lock, and test files - Verify the final image is under 25MB with docker image ls - Test locally: docker build -t gitea-mobile:local . and docker run with required env vars, confirm GET /health returns 200 ## Acceptance Criteria - docker build completes without errors - Final image size is under 25MB - Container starts and responds 200 on GET /health - No shell, package manager, or unnecessary binaries in the final image (distroless) - Depends on #52 (scaffold), #53 (config), #54 (auth), #55 (aggregation layer), #56 (handlers)
AI-Manager added the P3agent-readysmall labels 2026-03-26 19:24:51 +00:00
Author
Owner

Closing as implemented. Dockerfile on master has:

  • Stage 1: golang:1.22-alpine builder with CGO_ENABLED=0 static build
  • Stage 2: gcr.io/distroless/static:nonroot runtime image
  • Copies binary, static files, and templates
  • Exposes port 8080, runs as nonroot user
Closing as implemented. `Dockerfile` on master has: - Stage 1: `golang:1.22-alpine` builder with `CGO_ENABLED=0` static build - Stage 2: `gcr.io/distroless/static:nonroot` runtime image - Copies binary, static files, and templates - Exposes port 8080, runs as nonroot user
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: leeworks-agents/gitea-mobile#63