Skip to content

Commit

Permalink
Basic Docker image
Browse files Browse the repository at this point in the history
  • Loading branch information
DowerX committed Jan 19, 2025
1 parent 22888f8 commit c9f277d
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 0 deletions.
36 changes: 36 additions & 0 deletions docker/Dockerfile.release
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
FROM debian:bookworm-slim AS build

RUN apt update && apt install -y --no-install-recommends \
python3 python3-dev python3-venv build-essential ca-certificates

RUN useradd -u 1000 -U -m red
USER red
WORKDIR /home/red

RUN bash -c \
'python3 -m venv .redenv && \
source .redenv/bin/activate && \
pip install Red-DiscordBot && \
rm -rf .cache && \
redbot-setup \
--no-prompt \
--instance-name RedBot \
--data-path /home/red/data \
--overwrite-existing-instance \
--backend json'

FROM debian:bookworm-slim

RUN apt update && apt install -y --no-install-recommends \
python3 python3-venv openjdk-17-jre-headless ca-certificates

RUN useradd -u 1000 -U -m red
USER red
WORKDIR /home/red

COPY --chown=red:red --from=build /home/red /home/red

COPY --chown=red:red start.sh /home/red/start.sh
RUN chmod +x /home/red/start.sh && mkdir /home/red/data

ENTRYPOINT [ "/home/red/start.sh" ]
14 changes: 14 additions & 0 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
services:
red-bot:
image: red-bot
build:
context: .
dockerfile: Dockerfile.release
tags:
- red-bot
env_file: .env
volumes:
- data:/home/red/data

volumes:
data:
26 changes: 26 additions & 0 deletions docker/start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash

set -e

source .redenv/bin/activate

PREFIX="${PREFIX:-!}"

[ -z "$OWNER" ] && echo "Set the OWNER!" && exit 1
[ -z "$TOKEN" ] && echo "Set the TOKEN!" && exit 1

if [ -z "$(ls -A data)" ]; then
redbot-setup \
--no-prompt \
--instance-name RedBot \
--data-path /home/red/data \
--overwrite-existing-instance \
--backend json
fi

redbot RedBot \
--no-prompt \
--token "${TOKEN}" \
--owner "${OWNER}" \
--prefix "${PREFIX}" \
--mentionable
3 changes: 3 additions & 0 deletions docker/template.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
TOKEN=
OWNER=
PREFIX=!

0 comments on commit c9f277d

Please sign in to comment.