Skip to content

Commit

Permalink
fix(redbot): split images
Browse files Browse the repository at this point in the history
  • Loading branch information
JJGadgets committed Feb 4, 2024
1 parent e0c3aa1 commit dc97bf0
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 17 deletions.
20 changes: 20 additions & 0 deletions apps/redbot-distroless/Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
9 changes: 9 additions & 0 deletions apps/redbot-distroless/ci/latest.sh
Original file line number Diff line number Diff line change
@@ -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}"
16 changes: 16 additions & 0 deletions apps/redbot-distroless/metadata.yaml
Original file line number Diff line number Diff line change
@@ -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
19 changes: 3 additions & 16 deletions apps/redbot/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,19 @@
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
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"]
2 changes: 1 addition & 1 deletion apps/redbot/metadata.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
app: redbot
base: false
base: true
channels:
- &c
name: stable
Expand Down

0 comments on commit dc97bf0

Please sign in to comment.