mirror of
https://github.com/hanzoai/forge.git
synced 2026-10-30 15:00:39 +00:00
The image baked `ENV GIT_CUSTOM=/data/gitea`. The live deployment overrides it to
/data/git and the running server does use /data/git — app.ini, git.db, the 178 GB
repository root and the indexers are all there, and `git ls-remote` resolves
against it.
But an empty /data/gitea/{log,conf} still reappeared on every boot: 12 KB, zero
files, zero mappings in the server process, cwd /etc/s6. Inert, and confusing —
it reads like a second data directory next to the real one, which is exactly the
shape a split-brain repo root would have.
Fixing the default means the override in the App CR is belt-and-braces rather than
load-bearing, and a fresh volume lands in the right place with no override at all.
Nothing on disk moves: the deployment already sets /data/git explicitly, so this
only changes what an unconfigured container would do.
Co-authored-by: Hanzo Dev <[email protected]>
105 lines
3.6 KiB
Docker
105 lines
3.6 KiB
Docker
# syntax=docker/dockerfile:1
|
|
# Build frontend on the native platform to avoid QEMU-related issues with nodejs ecosystem
|
|
FROM --platform=$BUILDPLATFORM docker.io/library/golang:1.26-alpine3.24 AS frontend-build
|
|
RUN apk --no-cache add build-base git nodejs pnpm
|
|
WORKDIR /src
|
|
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml ./
|
|
RUN --mount=type=cache,target=/root/.local/share/pnpm/store pnpm install --frozen-lockfile
|
|
COPY --exclude=.git/ . .
|
|
RUN make frontend
|
|
|
|
# Build backend for each target platform
|
|
FROM docker.io/library/golang:1.26-alpine3.24 AS build-env
|
|
|
|
ARG GIT_VERSION
|
|
ARG TAGS=""
|
|
ENV TAGS="bindata timetzdata $TAGS"
|
|
ARG CGO_EXTRA_CFLAGS
|
|
|
|
# Build deps
|
|
RUN apk --no-cache add \
|
|
build-base \
|
|
git
|
|
|
|
WORKDIR ${GOPATH}/src/hanzo-git
|
|
# Sources private hanzoai modules (xorm, builder): mark them private
|
|
# (direct VCS fetch, no proxy/sumdb) and, when gh_token is mounted, rewrite
|
|
# github.com to an authenticated fetch so `go mod download` can read them. No-op
|
|
# without the token, so public-only builds still work. gh_token is the secret id
|
|
# the canonical hanzoai/ci reusable mounts (was GIT_AUTH_TOKEN, which ci never set).
|
|
ENV GOPRIVATE=github.com/hanzoai/*
|
|
COPY go.mod go.sum ./
|
|
RUN --mount=type=secret,id=gh_token \
|
|
if [ -s /run/secrets/gh_token ]; then \
|
|
git config --global url."https://x-access-token:$(cat /run/secrets/gh_token)@github.com/".insteadOf "https://github.com/"; \
|
|
fi && \
|
|
go mod download
|
|
# Use COPY instead of bind mount as read-only one breaks makefile state tracking and read-write one needs binary to be moved as it's discarded.
|
|
# ".git" directory is mounted separately later only for version data extraction.
|
|
COPY --exclude=.git/ . .
|
|
COPY --from=frontend-build /src/public/assets public/assets
|
|
|
|
# Build gitd. The version comes from the GIT_VERSION arg, written to the VERSION
|
|
# file the Makefile prefers over `git describe`. The native runner fabric exports
|
|
# a tree rather than a clone, and the earlier bind on .git failed there with
|
|
# "/.git: not found"; line 39 excludes .git from the COPY as well, so inside this
|
|
# image the arg is the ONLY source of a version — a build that omits it gets
|
|
# 0.0.0+unknown whether or not it started from a clone. hanzoai/cloud passes it
|
|
# from the image tag (clients/platform buildFrontendCmd), which is why a tagged
|
|
# build is versioned and an ad-hoc `docker build` is not.
|
|
RUN --mount=type=cache,target="/root/.cache/go-build" \
|
|
if [ -n "${GIT_VERSION}" ]; then echo "${GIT_VERSION}" > VERSION; \
|
|
elif [ ! -d .git ] && [ ! -f VERSION ]; then echo "0.0.0+unknown" > VERSION; fi && \
|
|
make backend
|
|
|
|
COPY docker/root /tmp/local
|
|
|
|
# Set permissions for builds that made under windows which strips the executable bit from file
|
|
RUN chmod 755 /tmp/local/usr/bin/entrypoint \
|
|
/tmp/local/usr/local/bin/* \
|
|
/tmp/local/etc/s6/gitd/* \
|
|
/tmp/local/etc/s6/openssh/* \
|
|
/tmp/local/etc/s6/.s6-svscan/* \
|
|
/go/src/hanzo-git/gitd
|
|
|
|
FROM docker.io/library/alpine:3.24 AS hanzo-git
|
|
|
|
EXPOSE 22 3000
|
|
|
|
RUN apk --no-cache add \
|
|
bash \
|
|
ca-certificates \
|
|
curl \
|
|
gettext \
|
|
git \
|
|
linux-pam \
|
|
openssh \
|
|
s6 \
|
|
sqlite \
|
|
su-exec \
|
|
gnupg
|
|
|
|
RUN addgroup \
|
|
-S -g 1000 \
|
|
git && \
|
|
adduser \
|
|
-S -H -D \
|
|
-h /data/git \
|
|
-s /bin/bash \
|
|
-u 1000 \
|
|
-G git \
|
|
git && \
|
|
echo "git:*" | chpasswd -e
|
|
|
|
COPY --from=build-env /tmp/local /
|
|
COPY --from=build-env /go/src/hanzo-git/gitd /app/git/gitd
|
|
|
|
ENV USER=git
|
|
ENV GIT_CUSTOM=/data/git
|
|
|
|
VOLUME ["/data"]
|
|
|
|
# HINT: HEALTH-CHECK-ENDPOINT: don't use HEALTHCHECK, search this hint keyword for more information
|
|
ENTRYPOINT ["/usr/bin/entrypoint"]
|
|
CMD ["/usr/bin/s6-svscan", "/etc/s6"]
|