summaryrefslogtreecommitdiffstats
path: root/Dockerfile
blob: 5c294343e95a2fa0f535b4145172a6dbf960630e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
FROM alpine:3.22.4 AS build

ARG GIT_HOST_C_URI=https://git.jnsn.dev/git/access-control
ARG GIT_HOST_C_REF=main

RUN apk add --no-cache build-base git

WORKDIR /src

RUN git clone --depth 1 --branch "${GIT_HOST_C_REF}" "${GIT_HOST_C_URI}" /src \
    && make -j2 && make test && make install DESTDIR=/install

FROM alpine:3.22.4

RUN apk add --no-cache \
    cgit \
    git \
    git-daemon \
    lighttpd \
    lighttpd-mod_auth \
    openssh-server \
    tini

RUN addgroup -g 1000 -S git \
    && adduser -u 1000 -S -D -G git -h /var/lib/git -s /usr/bin/git-shell git \
    && adduser git tty \
    && passwd -u git \
    && mkdir -p \
        /etc/git-host/secrets \
        /usr/local/libexec \
        /var/lib/git \
        /run/git-host/secrets \
        /run/lighttpd \
        /run/sshd \
        /var/tmp/lighttpd \
        /var/www/localhost/htdocs \
    && chown -R git:git /var/lib/git

COPY --from=build /install/ /

COPY entrypoint.sh /usr/local/bin/entrypoint.sh
COPY create-repo.sh /usr/local/bin/create-repo
COPY git-http-backend.cgi /usr/local/libexec/git-http-backend.cgi
COPY sshd_config /etc/ssh/sshd_config
COPY cgitrc /etc/cgitrc
COPY lighttpd.conf /etc/lighttpd/lighttpd.conf
COPY auth.conf /etc/lighttpd/auth.conf
COPY healthz /var/www/localhost/htdocs/healthz

RUN chmod 0755 \
        /usr/local/bin/entrypoint.sh \
        /usr/local/bin/create-repo \
        /usr/local/libexec/git-http-backend.cgi \
    && chmod 0644 /etc/git-host/authz.conf \
    && chown git:git /var/lib/git /run/lighttpd /var/tmp/lighttpd /var/www/localhost/htdocs \
    && chmod 0755 /run/git-host /run/git-host/secrets \
    && git config --file /etc/gitconfig core.hooksPath /usr/local/share/git-host/hooks \
    && grep -q "^git:" /etc/passwd \
    && lighttpd -tt -f /etc/lighttpd/lighttpd.conf \
    && /usr/local/bin/git-authz validate

EXPOSE 8080 2222
VOLUME ["/var/lib/git"]

ENTRYPOINT ["/sbin/tini", "--", "/usr/local/bin/entrypoint.sh"]