Dockerfile (3470B)
1 # syntax=docker/dockerfile:1 2 3 ######################################################################## 4 # 1. Build stagit - static git page generator (log/commits/files/refs). 5 # Low-resource on purpose: once generated, serving is plain static 6 # files, no git process or CGI running at request time. 7 ######################################################################## 8 FROM debian:bookworm-slim AS stagit-builder 9 10 RUN apt-get update && apt-get install -y --no-install-recommends \ 11 build-essential \ 12 pkg-config \ 13 libgit2-dev \ 14 git \ 15 python3 \ 16 ca-certificates \ 17 && rm -rf /var/lib/apt/lists/* 18 19 RUN git clone --depth 1 https://github.com/oxalorg/stagit.git /usr/src/stagit 20 WORKDIR /usr/src/stagit 21 RUN make PREFIX=/usr/local && make PREFIX=/usr/local install 22 23 ######################################################################## 24 # 2. Generate the site: HTML browser pages + a clonable bare repo. 25 # 26 # The build context must include .git. The .dockerignore in this repo 27 # keeps it available so stagit can publish history and refs. 28 ######################################################################## 29 FROM stagit-builder AS site-builder 30 31 COPY . /src/iuna-work 32 33 RUN set -eux; \ 34 test -d /src/iuna-work/.git; \ 35 git clone --bare /src/iuna-work /src/iuna.git; \ 36 mkdir -p /site/git/iuna /var/cache/stagit-iuna; \ 37 echo "iuna - experimental devnet protocol" > /src/iuna.git/description; \ 38 echo "iuna-labs" > /src/iuna.git/owner; \ 39 echo "https://getiuna.org/git/iuna.git" > /src/iuna.git/url; \ 40 cd /src/iuna.git; \ 41 mkdir -p /tmp/iuna-packs; \ 42 mv objects/pack/* /tmp/iuna-packs/; \ 43 for pack in /tmp/iuna-packs/*.pack; do \ 44 [ -e "$pack" ] || continue; \ 45 git unpack-objects < "$pack"; \ 46 done; \ 47 rm -rf /tmp/iuna-packs; \ 48 git update-server-info; \ 49 cd /site/git/iuna; \ 50 stagit -c /var/cache/stagit-iuna/cache /src/iuna.git; \ 51 test -f /site/git/iuna/log.html; \ 52 cp /site/git/iuna/log.html /site/git/iuna/index.html; \ 53 cd /site/git && stagit-index /src/iuna.git > index.html; \ 54 cp /src/iuna-work/www/assets/static-listing.css /site/git/style.css; \ 55 cp /src/iuna-work/www/assets/static-listing.css /site/git/iuna/style.css; \ 56 cp /src/iuna-work/src-tauri/icons/32x32.png /site/git/logo.png; \ 57 cp /src/iuna-work/src-tauri/icons/32x32.png /site/git/iuna/logo.png; \ 58 cp -a /src/iuna.git /site/git/iuna.git; \ 59 find /site/git -type f -name '*.html' -exec sed -i -E 's|<a href="(\.\./)+"><img |<a href="/"><img |g' {} +; \ 60 python3 /src/iuna-work/scripts/postprocess_stagit_site.py /site/git 61 62 COPY www /site 63 COPY downloads /site/downloads 64 RUN set -eux; \ 65 version="$(sed -n 's/^version = "\(.*\)"/\1/p' /src/iuna-work/Cargo.toml | head -n 1)"; \ 66 mkdir -p /site/downloads; \ 67 cp /site/downloads.html /site/downloads/index.html; \ 68 sed -i "s|\${IUNA_VERSION}|${version}|g" /site/downloads/index.html; \ 69 printf '{"tag":"v%s","version":"%s","url":"https://getiuna.org/downloads/"}\n' "$version" "$version" > /site/downloads/latest.json; \ 70 rm -f /site/downloads.html 71 72 ######################################################################## 73 # 3. Ship it - plain nginx, static files only. 74 ######################################################################## 75 FROM nginx:1.27-alpine 76 77 COPY --from=site-builder /site /usr/share/nginx/html 78 COPY nginx.conf /etc/nginx/conf.d/default.conf 79 80 EXPOSE 80