summaryrefslogtreecommitdiff
path: root/Dockerfile
blob: d7532652feae4f709a41fb28cff461fbe0b9a188 (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
66
67
68
69
#
#
# docker-cgit Docker Container
###################
# Build Stage
###################
FROM rockylinux:9 AS builder

# Update everything; install dependencies.
RUN dnf -y update && dnf -y install \
    git gcc make \
    openssl-devel zlib-devel zip \
    highlight \
    && dnf clean all

# Build cgit.
RUN git clone https://git.zx2c4.com/cgit /build/cgit
WORKDIR /build/cgit
# Add compile-time config (cgit.conf).
ADD cgit.conf .
RUN git submodule init \
    && git submodule update \
    && make NO_LUA=1 \
    && make install DESTDIR=/build/install

###################
# Runtime Stage
###################
FROM rockylinux:9
LABEL MAINTAINER="RATDAD <lambda@disroot.org>"

# Runtime dependencies
RUN dnf -y update && dnf -y install \
    httpd git highlight \
    openssl zlib zip \
    && dnf clean all

# Install cgit artifacts.
COPY --from=builder /build/install /

# If set to 0, the container will not \
# handle git-http-backend for you.
ENV GIT_HTTP_MODE=0

# Configure Apache and cgit.
ADD etc/cgitrc /etc/cgitrc
ADD etc/httpd/conf/httpd.conf /etc/httpd/conf/httpd.conf

# Configure Git HTTP Modes.
ADD etc/httpd/conf.d/git-http-p.conf /etc/httpd/conf.d/git-http-p.conf
ADD etc/httpd/conf.d/git-http-cf.conf  /etc/httpd/conf.d/git-http-cf.conf
ADD etc/httpd/conf.d/git-http-pcf.conf /etc/httpd/conf.d/git-http-pcf.conf
ADD etc/httpd/conf.d/git-http-apcf.conf /etc/httpd/conf.d/git-http-apcf.conf

# Add helper scripts.
COPY opt/ /opt
RUN chmod +x /opt/*

# Prevent git-http-backend safe.directory errors.
RUN git config --system --add safe.directory /srv/git

# Entrypoint.
COPY ./entrypoint.sh /
RUN chmod +x /entrypoint.sh

# You SHOULD run this behind a reverse proxy.
# Thus, 443 isn't being exposed.
EXPOSE 80
ENTRYPOINT [ "/entrypoint.sh" ]