-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
77 lines (57 loc) · 2.11 KB
/
Dockerfile
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
70
71
72
73
74
75
76
77
ARG ALPINE_VERSION
##
# This is a stage container used to build CGIT only
##
FROM alpine:${ALPINE_VERSION} AS build-cgit
WORKDIR /root
ADD cgit-pkg/APKBUILD .
RUN apk add alpine-sdk
RUN abuild-keygen --append --quiet -n
RUN abuild -Fr
RUN mv ~/packages/"$(abuild -FA)"/"$(abuild -F listpkg)" /root/cgit.apk
##
# This is the a stage container that install all needed files
##
FROM alpine:${ALPINE_VERSION} AS build-image
ARG S6_VERSION
# Upgrade everything!
RUN apk upgrade --update --no-cache
# Install s6-overlay
ADD https://github.com/just-containers/s6-overlay/releases/download/${S6_VERSION}/s6-overlay-amd64.tar.gz /tmp/
RUN tar xzf /tmp/s6-overlay-amd64.tar.gz -C / && rm /tmp/s6-overlay-amd64.tar.gz
# Install needed packages
COPY --from=build-cgit /root/cgit.apk /tmp
RUN apk add --allow-untrusted /tmp/cgit.apk && rm /tmp/cgit.apk
RUN apk add tzdata git openssh-server nginx fcgiwrap \
gettext python3 py3-pygments py3-markdown bash \
jq busybox-suid curl
RUN apk del vim
# Create the git user
RUN adduser -h /srv/git -s /usr/bin/gitty-shell -D git && passwd -u git
# Copy all files to the container
COPY rootfs /
# Fix the permissions of the crontab file
RUN chown root:git /etc/crontabs/git && chmod 0600 /etc/crontabs/git
# Add a crontab entry for root user
# It has to run as root so the output SSH key file has correct permissions
RUN echo "*/5 * * * * /usr/bin/ssh-key-fetch" >> /etc/crontabs/root
# Finally we cleanup the image
RUN rm -rf /var/cache/apk/*
##
# Final image build - it copies all files from the build-image stage image in a single statement,
# making the final image as thin as possible
##
FROM scratch
LABEL org.opencontainers.image.authors="Daniel Pereira <[email protected]>"
LABEL org.opencontainers.image.source="https://github.com/kriansa/gitty"
COPY --from=build-image / /
# Exposed ports and paths
EXPOSE 22 80
VOLUME ["/srv/git", "/config"]
# Default ENV variables
ENV TZ="Etc/UTC"
ENV SERVER_URL="git-server-of-mine.com"
ENV AUTO_PULL_SSH_KEYS=""
ENV CGIT_TITLE="My private git server"
ENV CGIT_DESC="A web interface for my git private server"
ENTRYPOINT ["/init"]