summaryrefslogtreecommitdiff
path: root/Dockerfile
diff options
context:
space:
mode:
Diffstat (limited to 'Dockerfile')
-rw-r--r--Dockerfile47
1 files changed, 47 insertions, 0 deletions
diff --git a/Dockerfile b/Dockerfile
new file mode 100644
index 0000000..67f15b6
--- /dev/null
+++ b/Dockerfile
@@ -0,0 +1,47 @@
+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 addgroup -g 1000 cgit \
+ && adduser -D -H -u 1000 -G cgit cgit
+
+RUN sed -i 's/^User www-data/User cgit/' /usr/local/apache2/conf/httpd.conf
+RUN sed -i 's/^Group www-data/Group 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 chown cgit:cgit -R /opt/cgit
+
+VOLUME ["/opt/git"]
+EXPOSE 80