summaryrefslogtreecommitdiff
path: root/Dockerfile
blob: dd0503f62aec29455d42661ad0a32e7c6fc02773 (plain) (blame)
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
ARG ALPINE_VERSION=latest
ARG APACHE_VERSION=alpine

FROM alpine:${ALPINE_VERSION} AS build

# To avoid conflict: undeclared REG_STARTEND compiling git with musl
# https://github.com/git/git/blob/23b219f8e3f2adfb0441e135f0a880e6124f766c/git-compat-util.h#L1279-L1281
ENV NO_REGEX=NeedsStartEnd

RUN apk add --no-cache \
    git \
    make \
    gcc \
    musl-dev \
    musl-libintl \
    openssl-dev \
    zlib-dev \
    luajit-dev

WORKDIR /opt/cgit-repo
RUN git clone https://git.zx2c4.com/cgit . \
 && git submodule update --init --recursive

COPY ["cgit_build.conf", "/opt/cgit-repo/cgit.conf"]
RUN make && make install

FROM httpd:${APACHE_VERSION}

RUN apk add --no-cache luajit lua5.1-ossl

RUN sed -i 's/^\(User\) www-data/\1 cgit/' /usr/local/apache2/conf/httpd.conf
RUN sed -i 's/^\(Group\) www-data/\1 cgit/' /usr/local/apache2/conf/httpd.conf
RUN sed -i 's/#\(LoadModule cgi_module\)/\1/' /usr/local/apache2/conf/httpd.conf
RUN sed -i 's/#\(LoadModule cgid_module\)/\1/' /usr/local/apache2/conf/httpd.conf
RUN echo -e "\n#cgit configuration\nInclude conf/extra/cgit.conf" >> /usr/local/apache2/conf/httpd.conf

COPY ./rootfs/ /
COPY --from=build /opt/cgit /opt/cgit
RUN chmod 755 -R /opt/cgit

COPY entrypoint.sh /usr/local/bin/entrypoint.sh
RUN chmod +x /usr/local/bin/entrypoint.sh

ENTRYPOINT ["entrypoint.sh"]
CMD ["httpd-foreground"]
EXPOSE 80