diff --git a/apps/redbot-distroless/Dockerfile b/apps/redbot-distroless/Dockerfile new file mode 100644 index 00000000..c929c5cc --- /dev/null +++ b/apps/redbot-distroless/Dockerfile @@ -0,0 +1,20 @@ +# Define build-time variables +ARG VERSION +FROM ghcr.io/jjgadgets/redbot:${VERSION} AS builder + +# Stage 2: Working app image +FROM gcr.io/distroless/python3-debian12:nonroot@sha256:02c3a74bee78c927ab39dd739f0e56e36675e6adc9032208abb7ed8b83067c74 +USER 1000:1000 +WORKDIR /app + +COPY --chmod=555 --chown=1000:1000 --from=builder /app /app + +ENV VIRTUAL_ENV=/app +ENV PATH="/app/bin:$PATH" + +# ADD --chmod=555 --chown=1000:1000 --checksum=sha256:af8a43230338de67563878a25872ee2fd3d6af0f3513d55dd1ec672ad69dae53 https://github.com/openSUSE/catatonit/releases/download/v0.2.0/catatonit.x86_64 /catatonit + +USER 1000:1000 +VOLUME ["/config"] +# ENTRYPOINT ["/catatonit", "--", "/app/bin/python3", "/app/bin/entrypoint.py"] +ENTRYPOINT ["python3", "/app/entrypoint.py"] diff --git a/apps/redbot-distroless/ci/latest.sh b/apps/redbot-distroless/ci/latest.sh new file mode 100755 index 00000000..74219d0c --- /dev/null +++ b/apps/redbot-distroless/ci/latest.sh @@ -0,0 +1,9 @@ +#!/usr/bin/env bash +channel=$1 + +if [[ "${channel}" == "stable" ]]; then + version="$(curl -sX GET "https://api.github.com/repos/Cog-Creators/Red-DiscordBot/releases/latest" | jq --raw-output '.tag_name' 2>/dev/null)" +fi +version="${version#*v}" +version="${version#*release-}" +printf "%s" "${version}" diff --git a/apps/redbot-distroless/metadata.yaml b/apps/redbot-distroless/metadata.yaml new file mode 100644 index 00000000..ae699277 --- /dev/null +++ b/apps/redbot-distroless/metadata.yaml @@ -0,0 +1,16 @@ +--- +app: redbot-distroless +base: false +channels: + - &c + name: stable + platforms: + - "linux/amd64" + # - "linux/arm64" + stable: true + tests: + enabled: false # TODO: pass env vars and/or args to `dgoss run` tests: "invalid config: host must be set" + # type: web + #- <<: *c + # name: master + # stable: false diff --git a/apps/redbot/Dockerfile b/apps/redbot/Dockerfile index c6915ffe..73b73981 100644 --- a/apps/redbot/Dockerfile +++ b/apps/redbot/Dockerfile @@ -2,8 +2,9 @@ ARG VERSION # Stage 1: Build (pulled from upstream Dockerfile https://github.com/botlabs-gg/yagpdb/blob/7e6d553bd203680a0a1d68afd94f815478538611/yagpdb_docker/Dockerfile) -FROM docker.io/library/python:3.11.7-slim-bookworm AS builder +FROM docker.io/library/python:3.11.7-slim-bookworm ARG VERSION +USER 1000:1000 WORKDIR /app RUN python3 -m venv /app @@ -11,23 +12,9 @@ ENV VIRTUAL_ENV=/app ENV PATH="/app/bin:$PATH" RUN /app/bin/pip install --no-cache-dir --upgrade pip wheel ARG VERSION -# RUN /app/bin/pip install --no-cache-dir --upgrade Red-DiscordBot[postgres]==${VERSION} - -# Stage 2: Working app image -FROM gcr.io/distroless/python3-debian12:nonroot@sha256:02c3a74bee78c927ab39dd739f0e56e36675e6adc9032208abb7ed8b83067c74 -WORKDIR /app - -COPY --from=builder /app /app -COPY --chmod=555 --chown=1000:1000 ./apps/redbot/entrypoint.py /app/entrypoint.py - RUN /app/bin/pip install --no-cache-dir --upgrade Red-DiscordBot[postgres]==${VERSION} - -# ENV VIRTUAL_ENV=/app -# ENV PATH="/app/bin:$PATH" - -# ADD --chmod=555 --chown=1000:1000 --checksum=sha256:af8a43230338de67563878a25872ee2fd3d6af0f3513d55dd1ec672ad69dae53 https://github.com/openSUSE/catatonit/releases/download/v0.2.0/catatonit.x86_64 /catatonit +COPY --chmod=555 --chown=1000:1000 ./apps/redbot/entrypoint.py /app/entrypoint.py USER 1000:1000 VOLUME ["/config"] -# ENTRYPOINT ["/catatonit", "--", "/app/bin/python3", "/app/bin/entrypoint.py"] ENTRYPOINT ["python3", "/app/entrypoint.py"] diff --git a/apps/redbot/metadata.yaml b/apps/redbot/metadata.yaml index 98f46326..09c9747c 100644 --- a/apps/redbot/metadata.yaml +++ b/apps/redbot/metadata.yaml @@ -1,6 +1,6 @@ --- app: redbot -base: false +base: true channels: - &c name: stable