projects

showcase

A public git mirror

build: add Dockerfile and compose example

daniel daum committed parent 9215a2c commit 1888368

Showing 6 changed files with 86 additions and 0 deletions.

.dockerignoreadded +7 −0
@@ -0,0 +1,7 @@1*2!go.mod3!go.sum4!cmd/5!internal/6!web/7**/*_test.go
Dockerfileadded +31 −0
@@ -0,0 +1,31 @@1# syntax=docker/dockerfile:123# Base images are pinned by digest. To bump: crane digest <image>:<tag>4FROM golang:1.27.4-alpine3.24@sha256:70bd7ddea8b6cbe5d6943cde279d6b67feb10cc924fb9100d1d8757c1575b280 AS build5WORKDIR /src6COPY go.mod go.sum ./7RUN go mod download8COPY cmd ./cmd9COPY internal ./internal10COPY web ./web11ARG TARGETOS TARGETARCH12RUN CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH \13    go build -trimpath -ldflags="-s -w" -o /out/daumdev ./cmd/daumdev1415# git is needed at runtime for the mirrors, which is why this isn't distroless.16FROM alpine:3.24.4@sha256:f59abe656b692d901e184be3445e084786602108599d2a51d229c0f5a48c71bf17# hadolint ignore=DL301818RUN apk add --no-cache git ca-certificates \19    && mkdir /data \20    && chown 10001:10001 /data21COPY --from=build /out/daumdev /usr/local/bin/daumdev22# the mirrors are owned by this user, so no safe.directory is needed23USER 10001:1000124ENV HOME=/data25EXPOSE 808026VOLUME /data27# /healthz is 503 until the first build is published28HEALTHCHECK --interval=30s --timeout=5s --start-period=5m \29    CMD ["wget", "-q", "-O", "/dev/null", "http://127.0.0.1:8080/healthz"]30ENTRYPOINT ["/usr/local/bin/daumdev"]31CMD ["-config", "/config.json", "-data", "/data", "-listen", ":8080"]
README.md +17 −0
@@ -41,6 +41,21 @@ just run         # build from real Gitea every 10 min and serve on localhost:8004141}4242```434344## Deploy4546```sh47just image                       # docker build -t daumdev:latest . (needs Docker)48docker compose up -d             # uses compose.yaml and ./config.json49```5051The container runs as uid 10001 with a read-only root filesystem, no52capabilities and `no-new-privileges`. Only `/data` is writable: git mirrors53and site builds. It listens on plain HTTP `:8080`. Pangolin terminates TLS.5455Gitea must allow anonymous reads (`REQUIRE_SIGNIN_VIEW = false`, HTTP git56not disabled) and has to be reachable from the container at `gitea_url`.57Put Pangolin's address in `trusted_proxies` so logs show client IPs.584459## Layout45604661```@@ -54,6 +69,8 @@ internal/server/   router, static files, git + registry proxy5469web/               embedded templates and static assets5570testdata/          sample Gitea JSON and golden output5671docs/              spec and design decisions72Dockerfile         golang build stage, alpine + git runtime, pinned by digest73compose.yaml       example deployment5774```58755976## Docs
compose.yamladded +16 −0
@@ -0,0 +1,16 @@1# Example deployment. Pangolin proxies daum.dev to 127.0.0.1:8080, and the2# container reaches Gitea over the host's Tailscale connection.3services:4    daumdev:5        image: daumdev:latest6        build: .7        read_only: true8        cap_drop: [ALL]9        security_opt: ["no-new-privileges:true"]10        volumes:11            - daumdev-data:/data12            - ./config.json:/config.json:ro13        ports: ["127.0.0.1:8080:8080"]14        restart: unless-stopped15volumes:16    daumdev-data:
docs/decisions.md +13 −0
@@ -150,3 +150,16 @@ details are in `docs/theme.md`. This replaces the spec's original150150- Gitea must allow anonymous HTTP git and registry reads151151  (`REQUIRE_SIGNIN_VIEW = false`, HTTP git not disabled), or public clones and152152  pulls fail.153154## Image155156- Base images are `golang:1.27.4-alpine3.24` and `alpine:3.24.4`, pinned by157  digest. `just digests` prints the current upstream digests for bumping. Go158  is the same version as `mise.toml`.159- apk packages (`git`, `ca-certificates`) aren't version-pinned, since160  Alpine drops old package versions. The base image digest bounds them.161- `HOME=/data`, so nothing tries to write elsewhere on the read-only root.162  Builds only write under `/data`.163- `.dockerignore` is an allowlist: only `go.mod`, `go.sum`, `cmd/`,164  `internal/` and `web/` enter the build context, and tests are excluded.165- `crane` and `hadolint` are project tools in `mise.toml`.
mise.toml +2 −0
@@ -1,2 +1,4 @@11[tools]2crane = "0.22.1"23go = "1.27.4"4hadolint = "2.15.1"