From 6980fba88a940cef960038b0c066da77e75b2bb8 Mon Sep 17 00:00:00 2001 From: Nathan Garside Date: Fri, 6 Dec 2024 20:30:37 +0000 Subject: [PATCH] Simplify Gitea container image (#54) --- gitea/containerfile | 30 ++++++++++++++++++++++-------- gitea/justfile | 2 +- scripts/alpine.sh | 6 ++++++ 3 files changed, 29 insertions(+), 9 deletions(-) create mode 100644 scripts/alpine.sh diff --git a/gitea/containerfile b/gitea/containerfile index 92f8306..7d9229e 100644 --- a/gitea/containerfile +++ b/gitea/containerfile @@ -1,17 +1,31 @@ # This is free and unencumbered software released into the public domain. -FROM docker.io/gitea/gitea:latest AS build +FROM docker.io/alpine:latest AS build -FROM docker.io/alpine:latest +RUN apk add git -RUN apk add gitea +# gitea --version | grep -oE [0-9]+.[0-9]+.[0-9]+ +RUN wget -O gitea https://dl.gitea.com/gitea/1.22.4/gitea-1.22.4-linux-amd64 +RUN chmod +x gitea + +FROM scratch + +COPY --from=build /gitea /usr/bin/gitea + +COPY --from=build /usr/bin/git /usr/bin/git + +COPY --from=build /lib/ld-musl-x86_64.so.1 /lib/ld-musl-x86_64.so.1 + +COPY --from=build /usr/lib/libpcre2-8.so.0 /usr/lib/libpcre2-8.so.0 + +COPY --from=build /usr/lib/libz.so.1 /usr/lib/libz.so.1 + +COPY --from=build /lib/ld-musl-x86_64.so.1 /lib/ld-musl-x86_64.so.1 ENV GITEA_I_AM_BEING_UNSAFE_RUNNING_AS_ROOT=true -ENTRYPOINT ["/usr/bin/gitea"] +EXPOSE 80 -EXPOSE 3000 +ENTRYPOINT ["/usr/bin/gitea"] -CMD [ \ - "--config", "/opt/gitea/app.ini" \ -] +CMD ["web", "--config", "/opt/gitea/app.ini", "--port", "80"] diff --git a/gitea/justfile b/gitea/justfile index 9932b6f..c4f63f9 100644 --- a/gitea/justfile +++ b/gitea/justfile @@ -7,7 +7,7 @@ build: docker build --file containerfile --tag ghcr.io/ngarside/gitea:latest . run: stop - docker run --detach --name gitea --publish 8080:3000 --read-only --rm --volume {{ replace(justfile_directory(), '\', '/') }}/bin/opt:/opt/gitea --volume {{ replace(justfile_directory(), '\', '/') }}/bin/root:/root ghcr.io/ngarside/gitea:latest + docker run --detach --name gitea --publish 8080:80 --read-only --rm --volume {{ replace(justfile_directory(), '\', '/') }}/bin/opt:/opt/gitea --volume {{ replace(justfile_directory(), '\', '/') }}/bin/root:/root --volume {{ replace(justfile_directory(), '\', '/') }}/bin/tmp:/tmp ghcr.io/ngarside/gitea:latest stop: docker stop gitea || true diff --git a/scripts/alpine.sh b/scripts/alpine.sh new file mode 100644 index 0000000..7f60e48 --- /dev/null +++ b/scripts/alpine.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash +# This is free and unencumbered software released into the public domain. + +set -euo pipefail + +docker run --interactive --rm --tty alpine /bin/sh