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 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 ENV CGIT_APP_USER=cgit 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