diff options
| -rw-r--r-- | Dockerfile | 14 | ||||
| -rw-r--r-- | docker-compose.yml | 8 | ||||
| -rw-r--r-- | entrypoint.sh | 20 |
3 files changed, 35 insertions, 7 deletions
@@ -28,11 +28,8 @@ 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/^\(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 @@ -41,7 +38,12 @@ ENV CGIT_APP_USER=cgit COPY ./rootfs/ / COPY --from=build /opt/cgit /opt/cgit -RUN chown cgit:cgit -R /opt/cgit +RUN chmod 755 -R /opt/cgit + +COPY entrypoint.sh /usr/local/bin/entrypoint.sh +RUN chmod +x /usr/local/bin/entrypoint.sh VOLUME ["/opt/git"] +ENTRYPOINT ["entrypoint.sh"] +CMD ["httpd-foreground"] EXPOSE 80 diff --git a/docker-compose.yml b/docker-compose.yml index e97a947..fc68ebe 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -5,10 +5,16 @@ services: build: . ports: - "8086:80" + environment: + PUID: "1000" + PGID: "1000" volumes: - /srv/shares/git:/srv/git/:ro - - /srv/shares/cgit/cache:/opt/cgit/cache:rw + - cgit-cache:/opt/cgit/cache:rw - ./cgit.css:/opt/cgit/app/cgit.css:ro - ./cgit.png:/opt/cgit/app/cgit.png:ro - ./favicon.ico:/opt/cgit/app/favicon.ico:ro - ./cgitrc:/opt/cgit/cgitrc:ro + +volumes: + cgit-cache: diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100644 index 0000000..f6b0b54 --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,20 @@ +#!/bin/sh +set -eu + +: "${PUID:=1000}" +: "${PGID:=1000}" + +# Create group at container start +if ! grep -q '^cgit:' /etc/group; then + addgroup -g "$PGID" cgit +fi + +# Create user at container start +if ! grep -q '^cgit:' /etc/passwd; then + adduser -D -H -u "$PUID" -G cgit cgit +fi + +# Make cache writable for Apache/cgit +chown -R "$PUID:$PGID" /opt/cgit/cache + +exec "$@" |
