Skip to content

Commit b95fcdd

Browse files
authored
Merge pull request #65 from rHomelab/feat/noaudio_build
2 parents 90dbcd3 + 1450ade commit b95fcdd

File tree

5 files changed

+61
-32
lines changed

5 files changed

+61
-32
lines changed

.github/workflows/build.yml

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,17 @@ env:
1818

1919
jobs:
2020
build:
21+
name: Build ${{ matrix.variant.name }} variant
2122
runs-on: ubuntu-latest
23+
strategy:
24+
matrix:
25+
variant:
26+
- name: "default"
27+
build_args: ""
28+
tag_suffix: ""
29+
- name: "noaudio"
30+
build_args: "SKIP_JRE=1"
31+
tag_suffix: "-noaudio"
2232
steps:
2333
- uses: actions/checkout@v5
2434

@@ -54,11 +64,11 @@ jobs:
5464
ghcr.io/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}
5565
${{ github.repository_owner }}/${{ env.IMAGE_NAME }}
5666
tags: |
57-
type=raw,value=latest,enable={{is_default_branch}}
58-
type=semver,pattern={{version}},value=${{ steps.build_info.outputs.red_version }},enable={{is_default_branch}}
59-
type=semver,pattern={{major}}.{{minor}},value=${{ steps.build_info.outputs.red_version }},enable={{is_default_branch}}
60-
type=semver,pattern={{major}},value=${{ steps.build_info.outputs.red_version }},enable={{is_default_branch}}
61-
type=ref,event=pr
67+
type=raw,value=latest${{ matrix.variant.tag_suffix }},enable={{is_default_branch}}
68+
type=semver,pattern={{version}}${{ matrix.variant.tag_suffix }},value=${{ steps.build_info.outputs.red_version }},enable={{is_default_branch}}
69+
type=semver,pattern={{major}}.{{minor}}${{ matrix.variant.tag_suffix }},value=${{ steps.build_info.outputs.red_version }},enable={{is_default_branch}}
70+
type=semver,pattern={{major}}${{ matrix.variant.tag_suffix }},value=${{ steps.build_info.outputs.red_version }},enable={{is_default_branch}}
71+
type=ref,event=pr,suffix=${{ matrix.variant.tag_suffix }}
6272
6373
- name: Build and push image
6474
uses: docker/build-push-action@v6
@@ -68,11 +78,12 @@ jobs:
6878
labels: ${{ steps.meta.outputs.labels }}
6979
annotations: ${{ steps.meta.outputs.annotations }}
7080
platforms: linux/amd64,linux/arm64
81+
build-args: ${{ matrix.variant.build_args }}
7182
# Build cache is scoped to branches by default.
7283
# We use the main branch as a fallback if there's no cache for the existing branch.
7384
# https://stackoverflow.com/a/77127188/5209106
7485
cache-from: |
75-
type=gha
76-
type=gha,scope=main
77-
cache-to: type=gha,mode=max
86+
type=gha,scope=${{ matrix.variant.name }}
87+
type=gha,scope=main-${{ matrix.variant.name }}
88+
cache-to: type=gha,mode=max,scope=${{ matrix.variant.name }}
7889
provenance: false

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
/dev
2-
venv
2+
venv
3+
compose.yml
4+
test_data/

Dockerfile

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ FROM python:3.11-slim-trixie
22

33
ARG DEBIAN_FRONTEND=noninteractive \
44
RED_UID=1024 \
5-
RED_GID=1024
5+
RED_GID=1024 \
6+
SKIP_JRE
67

78
ENV PYTHONUNBUFFERED=1 \
89
PIP_DISABLE_PIP_VERSION_CHECK=1 \
@@ -22,10 +23,11 @@ RUN rm -f /etc/apt/apt.conf.d/docker-clean; echo 'Binary::apt::APT::Keep-Downloa
2223

2324
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
2425
--mount=type=cache,target=/var/lib/apt,sharing=locked \
25-
--mount=type=cache,target=${RED_HOME}/.cache/pip,sharing=locked \
26+
--mount=type=cache,target=${RED_HOME}/.cache/pip,sharing=locked,uid=${RED_UID},gid=${RED_GID} \
2627
--mount=type=bind,source=redbot/requirements.txt,target=${RED_HOME}/requirements.txt \
2728
apt update && \
28-
apt --no-install-recommends -y install build-essential git openjdk-21-jre-headless units tini && \
29+
apt --no-install-recommends -y install build-essential git units tini && \
30+
if [ -z "$SKIP_JRE" ]; then apt --no-install-recommends -y install openjdk-21-jre-headless; fi && \
2931
su $RED_USER -c "python -m pip install --user -r ${RED_HOME}/requirements.txt" && \
3032
apt remove -y build-essential && \
3133
apt autoremove -y

README.md

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
* [Running the bot with `docker compose`](#running-the-bot-with-docker-compose)
1111
* [Running the bot with `docker run`](#running-the-bot-with-docker-run)
1212
* [Tags](#tags)
13+
* [No Audio](#no-audio)
1314
* [Environment Variables](#environment-variables)
1415
* [Additional Options](#additional-options)
1516

@@ -63,10 +64,24 @@ To retrieve the invitation URL, run `docker logs RedBot`. If you only started th
6364

6465
## Tags
6566

66-
| Tag | Description |
67-
| -------- | -------------------------------------------------------------------------------------------------- |
68-
| `latest` | [Latest release](https://github.com/Cog-Creators/Red-DiscordBot/releases/latest) of Red-DiscordBot |
69-
| `x.x.x` | Specified version of Red-DiscordBot (e.g. tag `1.2.3` would be Red version `1.2.3`) |
67+
| Tag | Description |
68+
| ---------------- | -------------------------------------------------------------------------------------------------------------------------------------- |
69+
| `latest` | [Latest release](https://github.com/Cog-Creators/Red-DiscordBot/releases/latest) of Red-DiscordBot |
70+
| `latest-noaudio` | [Latest release](https://github.com/Cog-Creators/Red-DiscordBot/releases/latest) of Red-DiscordBot ([no audio cog support](#no-audio)) |
71+
| `x.x.x` | Specified version of Red-DiscordBot (e.g. tag `1.2.3` would be Red version `1.2.3`) |
72+
| `x.x.x-noaudio` | Specified version of Red-DiscordBot (e.g. tag `1.2.3` would be Red version `1.2.3`) ([no audio cog support](#no-audio)) |
73+
74+
### No Audio
75+
76+
Images with a `-noaudio` tag suffix exclude dependencies for the [Audio cog](https://docs.discord.red/en/stable/cog_guides/audio.html), which means that it **will not work**.
77+
78+
Dropping the Audio cog's requirements results in a significant reduction in image size (>200MB, ~33%):
79+
80+
```
81+
REPOSITORY TAG SIZE
82+
ghcr.io/rhomelab/red-discordbot latest 633MB
83+
ghcr.io/rhomelab/red-discordbot latest-noaudio 423MB
84+
```
7085

7186
## Environment Variables
7287

docker-compose-example.yml

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
1-
version: '3.8'
1+
name: redbot
22
services:
3-
red-bot:
4-
image: ghcr.io/rhomelab/red-discordbot:latest
5-
container_name: RedBot
6-
restart: always
7-
# command: "" # Optional, default empty, e.g. --owner <OWNER>
8-
environment:
9-
INSTANCE_NAME: "RedBot"
10-
PREFIX: "^"
11-
TOKEN: "yourBotToken"
12-
# RPC_ENABLED: "false" # Optional, default false
13-
# RPC_PORT: "6133" # Optional, default 6133
14-
# TEAM_MEMBERS_ARE_OWNERS: "false" # Optional, default false
15-
# PIP_REQUIREMENTS: "" # Optional, space-separated list of pip requirements, default empty
16-
volumes:
17-
- /opt/redbot:/redbot/data
3+
red-bot:
4+
image: ghcr.io/rhomelab/red-discordbot:latest
5+
restart: always
6+
# command: "" # Optional, default empty, e.g. --owner <OWNER>
7+
environment:
8+
INSTANCE_NAME: "RedBot"
9+
PREFIX: "^"
10+
TOKEN: "yourBotToken"
11+
# RPC_ENABLED: "false" # Optional, default false
12+
# RPC_PORT: "6133" # Optional, default 6133
13+
# TEAM_MEMBERS_ARE_OWNERS: "false" # Optional, default false
14+
# PIP_REQUIREMENTS: "" # Optional, space-separated list of pip requirements, default empty
15+
volumes:
16+
- /opt/redbot:/redbot/data

0 commit comments

Comments
 (0)