summaryrefslogtreecommitdiff
path: root/Containerfile
blob: e15c99cbbda8968c3b88ee657b80e1dde4ecc494 (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
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
ARG DEBIAN_VERSION=trixie
ARG CGIT_VERSION=1.3.1
ARG IMAGE_REVISION=1

FROM debian:${DEBIAN_VERSION}-slim AS builder

ARG CGIT_VERSION=1.3.1
ARG CGIT_COMMIT=044821677c774cd24f25f1818ea51d09cc64b006

RUN apt-get update \
    && apt-get install --no-install-recommends -y \
        build-essential \
        ca-certificates \
        git \
        libssl-dev \
        libzip-dev \
        pkg-config \
        zlib1g-dev \
    && rm -rf /var/lib/apt/lists/*

WORKDIR /src

RUN git init cgit \
    && cd cgit \
    && git remote add origin https://git.zx2c4.com/cgit \
    && git fetch --depth=1 origin "${CGIT_COMMIT}" \
    && git checkout --detach FETCH_HEAD \
    && git submodule update --init --recursive

WORKDIR /src/cgit

RUN make -j"$(nproc)" \
    CGIT_VERSION="${CGIT_VERSION}" \
    NO_LUA=1 \
    NO_GETTEXT=YesPlease

RUN make install \
    CGIT_VERSION="${CGIT_VERSION}" \
    NO_LUA=1 \
    NO_GETTEXT=YesPlease \
    DESTDIR=/out \
    CGIT_SCRIPT_PATH=/www/cgi-bin \
    CGIT_DATA_PATH=/www


FROM debian:${DEBIAN_VERSION}-slim

ARG CGIT_VERSION=1.3.1
ARG IMAGE_REVISION=1

LABEL org.opencontainers.image.title="cgit" \
      org.opencontainers.image.version="${CGIT_VERSION}-r${IMAGE_REVISION}"

RUN apt-get update \
    && apt-get install --no-install-recommends -y \
        busybox-static \
        python3-pygments \
        tini \
        zlib1g \
    && rm -rf /var/lib/apt/lists/*

COPY --from=builder /out/www /www

COPY --chmod=0555 syntax-highlighting.py /usr/libexec/cgit/syntax-highlighting.py

RUN mkdir -p \
      /srv/git \
      /var/cache/cgit

EXPOSE 8080

ENTRYPOINT ["/usr/bin/tini", "--", "/bin/busybox", "httpd", "-f", "-p", "0.0.0.0:8080", "-h", "/www"]
an class="s1">major_version=${cgit_version%%.*} printf '%s\n' \ "${repository}:${cgit_version}-r${image_revision}" \ "${repository}:${cgit_version}" \ "${repository}:${minor_version}" \ "${repository}:${major_version}" ''' [tasks.build] description = "Build the current cgit image with Podman" run = ''' #!/usr/bin/env bash set -euo pipefail arg_value() { local name=$1 local values values=$(sed -n "s/^ARG ${name}=//p" Containerfile | sort -u) if [[ -z $values || $values == *$'\n'* ]]; then echo "Containerfile must define one consistent value for ARG ${name}" >&2 exit 1 fi printf '%s' "$values" } repository=${CGIT_IMAGE_REPOSITORY:-docker.io/pablu/cgit} cgit_version=$(arg_value CGIT_VERSION) image_revision=$(arg_value IMAGE_REVISION) image=${repository}:${cgit_version}-r${image_revision} podman build --tag "$image" --file Containerfile . ''' [tasks.push] description = "Build and push the versioned and rolling Docker Hub tags" depends = ["build"] run = ''' #!/usr/bin/env bash set -euo pipefail mapfile -t images < <(mise run tags) source_image=${images[0]} for image in "${images[@]}"; do if [[ $image != "$source_image" ]]; then podman tag "$source_image" "$image" fi podman push "$image" done '''