Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@
# Logs
**/*.log

# YAML configuration
**/*.yaml
**/*.yml

# Cache files
**/__pycache__
**/*.py[cod]
**/*$py.class
**/*$py.class
7 changes: 0 additions & 7 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
####################################################################################################
## Final image
####################################################################################################
FROM python:3.13-slim-bookworm

ENV DEBIAN_FRONTEND=noninteractive
Expand All @@ -9,16 +6,12 @@ RUN apt-get update \
&& apt-get install -y --no-install-recommends \
bash \
git \
netcat-traditional \
tini \
gcc \
libc6-dev \
&& apt-get clean

WORKDIR /rodhaj
COPY /bot /rodhaj/bot/
COPY /docker/start.sh /rodhaj/start.sh
COPY /docker/wait-for /rodhaj/wait-for
COPY /requirements.txt /rodhaj/requirements.txt

RUN adduser --disabled-password --gecos "" rodhaj \
Expand Down
2 changes: 2 additions & 0 deletions docker/docker-compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ services:
POSTGRES_USER: ${DB_USERNAME}
volumes:
- database:/var/lib/postgresql/data
env_file:
- .env
ports:
- 5432:5432

Expand Down
16 changes: 9 additions & 7 deletions docker/docker-compose.prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@ services:
volumes:
# Do not edit the next line. If you want to change the path of the configuration file, please edit the CONFIG_LOCATION variable
- ${CONFIG_LOCATION}:/rodhaj/bot/config.yml
env_file:
- .env
ports:
- 8555:8555
depends_on:
- database
command: sh -c '/rodhaj/wait-for database:5432 -- echo "[Wait-for] PostgreSQL is fully up. Starting Rodhaj." && /rodhaj/start.sh'
database:
condition: service_healthy
restart: true
env_file:
- .env
restart: always

database:
Expand All @@ -29,7 +30,6 @@ services:
ports:
- 5432:5432
volumes:
# Do not edit the next line. If you want to change the database storage location on your system, edit the value of DB_DATA_LOCATION in the .env file
- database:/var/lib/postgresql/data
healthcheck:
test: pg_isready --dbname='${DB_DATABASE_NAME}' --username='${DB_USERNAME}' || exit 1; Chksum="$$(psql --dbname='${DB_DATABASE_NAME}' --username='${DB_USERNAME}' --tuples-only --no-align --command='SELECT COALESCE(SUM(checksum_failures), 0) FROM pg_stat_database')"; echo "checksum failure count is $$Chksum"; [ "$$Chksum" = '0' ] || exit 1
Expand All @@ -43,8 +43,10 @@ services:
ports:
- 9090:9090
image: prom/prometheus:latest
env_file:
- .env
volumes:
- ./prometheus.yml:/etc/prometheus/prometheus.yml
- ${PROMETHEUS_CONFIG_LOCATION}:/etc/prometheus/prometheus.yml
- prometheus-data:/prometheus

# first login uses admin/admin
Expand All @@ -61,4 +63,4 @@ services:
volumes:
database:
prometheus-data:
grafana-data:
grafana-data:
13 changes: 6 additions & 7 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ services:
volumes:
# Do not edit the next line. If you want to change the path of the configuration file, please edit the CONFIG_LOCATION variable
- ${CONFIG_LOCATION}:/rodhaj/bot/config.yml
env_file:
- .env
ports:
- 8555:8555
depends_on:
- database
# Oftentimes if Rodhaj started too early (aka starting without this script), then it would entirely not run the migrations and error out
command: sh -c '/rodhaj/wait-for database:5432 -- echo "[Wait-for] PostgreSQL is fully up. Starting Rodhaj." && /rodhaj/start.sh'
database:
condition: service_healthy
restart: true
env_file:
- .env
restart: always

database:
Expand All @@ -30,7 +30,6 @@ services:
ports:
- 5432:5432
volumes:
# Do not edit the next line. If you want to change the database storage location on your system, edit the value of DB_DATA_LOCATION in the .env file
- database:/var/lib/postgresql/data
healthcheck:
test: pg_isready --dbname='${DB_DATABASE_NAME}' --username='${DB_USERNAME}' || exit 1; Chksum="$$(psql --dbname='${DB_DATABASE_NAME}' --username='${DB_USERNAME}' --tuples-only --no-align --command='SELECT COALESCE(SUM(checksum_failures), 0) FROM pg_stat_database')"; echo "checksum failure count is $$Chksum"; [ "$$Chksum" = '0' ] || exit 1
Expand All @@ -40,4 +39,4 @@ services:
restart: always

volumes:
database:
database:
11 changes: 8 additions & 3 deletions docker/example.env
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
# The location of where Rodhaj's configuration is stored.
# The configuration can be found under the config-example.yml
# MUST be absolute path
CONFIG_LOCATION=./config.yml

# Location for prometheus configuration
# MUST be absolute path
PROMETHEUS_CONFIG_LOCATION=./prometheus.yml

# Connection secret for the postgres. You should change it to a random password
POSTGRES_PASSWORD=postgres
DB_PASSWORD=postgres

# The values below this line do not need to be changed
###################################################################################
POSTGRES_USER=postgres
POSTGRES_DB=rodhaj
DB_USERNAME=postgres
DB_DATABASE_NAME=rodhaj
191 changes: 0 additions & 191 deletions docker/wait-for

This file was deleted.

32 changes: 32 additions & 0 deletions taskfile.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
version: '3'

tasks:
dev-up:
preconditions:
- test -f docker/docker-compose.dev.yml
cmds:
- docker compose -f docker/docker-compose.dev.yml up -d

dev-stop:
preconditions:
- test -f docker/docker-compose.dev.yml
cmds:
- docker compose -f docker/docker-compose.dev.yml stop

start:
preconditions:
- test -f bot/config.yml
cmds:
- python bot/launcher.py
silent: true

check:
cmds:
- ruff check bot --fix --exit-non-zero-on-fix
- ruff format bot
silent: true

fmt:
cmds:
- ruff format server
silent: true