Skip to content

Commit f643604

Browse files
committed
Fix code
1 parent 4b4636a commit f643604

8 files changed

+62
-216
lines changed

.dockerignore

+5-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@
44
# Logs
55
**/*.log
66

7+
# YAML configuration
8+
**/*.yaml
9+
**/*.yml
10+
711
# Cache files
812
**/__pycache__
913
**/*.py[cod]
10-
**/*$py.class
14+
**/*$py.class

docker/Dockerfile

-7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
####################################################################################################
2-
## Final image
3-
####################################################################################################
41
FROM python:3.13-slim-bookworm
52

63
ENV DEBIAN_FRONTEND=noninteractive
@@ -9,16 +6,12 @@ RUN apt-get update \
96
&& apt-get install -y --no-install-recommends \
107
bash \
118
git \
12-
netcat-traditional \
139
tini \
14-
gcc \
15-
libc6-dev \
1610
&& apt-get clean
1711

1812
WORKDIR /rodhaj
1913
COPY /bot /rodhaj/bot/
2014
COPY /docker/start.sh /rodhaj/start.sh
21-
COPY /docker/wait-for /rodhaj/wait-for
2215
COPY /requirements.txt /rodhaj/requirements.txt
2316

2417
RUN adduser --disabled-password --gecos "" rodhaj \

docker/docker-compose.dev.yml

+2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ services:
1313
POSTGRES_USER: ${DB_USERNAME}
1414
volumes:
1515
- database:/var/lib/postgresql/data
16+
env_file:
17+
- .env
1618
ports:
1719
- 5432:5432
1820

docker/docker-compose.prod.yml

+9-7
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,14 @@ services:
77
volumes:
88
# Do not edit the next line. If you want to change the path of the configuration file, please edit the CONFIG_LOCATION variable
99
- ${CONFIG_LOCATION}:/rodhaj/bot/config.yml
10-
env_file:
11-
- .env
1210
ports:
1311
- 8555:8555
1412
depends_on:
15-
- database
16-
command: sh -c '/rodhaj/wait-for database:5432 -- echo "[Wait-for] PostgreSQL is fully up. Starting Rodhaj." && /rodhaj/start.sh'
13+
database:
14+
condition: service_healthy
15+
restart: true
16+
env_file:
17+
- .env
1718
restart: always
1819

1920
database:
@@ -29,7 +30,6 @@ services:
2930
ports:
3031
- 5432:5432
3132
volumes:
32-
# 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
3333
- database:/var/lib/postgresql/data
3434
healthcheck:
3535
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
@@ -43,8 +43,10 @@ services:
4343
ports:
4444
- 9090:9090
4545
image: prom/prometheus:latest
46+
env_file:
47+
- .env
4648
volumes:
47-
- ./prometheus.yml:/etc/prometheus/prometheus.yml
49+
- ${PROMETHEUS_CONFIG_LOCATION}:/etc/prometheus/prometheus.yml
4850
- prometheus-data:/prometheus
4951

5052
# first login uses admin/admin
@@ -61,4 +63,4 @@ services:
6163
volumes:
6264
database:
6365
prometheus-data:
64-
grafana-data:
66+
grafana-data:

docker/docker-compose.yml

+6-7
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@ services:
77
volumes:
88
# Do not edit the next line. If you want to change the path of the configuration file, please edit the CONFIG_LOCATION variable
99
- ${CONFIG_LOCATION}:/rodhaj/bot/config.yml
10-
env_file:
11-
- .env
1210
ports:
1311
- 8555:8555
1412
depends_on:
15-
- database
16-
# Oftentimes if Rodhaj started too early (aka starting without this script), then it would entirely not run the migrations and error out
17-
command: sh -c '/rodhaj/wait-for database:5432 -- echo "[Wait-for] PostgreSQL is fully up. Starting Rodhaj." && /rodhaj/start.sh'
13+
database:
14+
condition: service_healthy
15+
restart: true
16+
env_file:
17+
- .env
1818
restart: always
1919

2020
database:
@@ -30,7 +30,6 @@ services:
3030
ports:
3131
- 5432:5432
3232
volumes:
33-
# 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
3433
- database:/var/lib/postgresql/data
3534
healthcheck:
3635
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
@@ -40,4 +39,4 @@ services:
4039
restart: always
4140

4241
volumes:
43-
database:
42+
database:

docker/example.env

+8-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
# The location of where Rodhaj's configuration is stored.
22
# The configuration can be found under the config-example.yml
3+
# MUST be absolute path
34
CONFIG_LOCATION=./config.yml
45

6+
# Location for prometheus configuration
7+
# MUST be absolute path
8+
PROMETHEUS_CONFIG_LOCATION=./prometheus.yml
9+
510
# Connection secret for the postgres. You should change it to a random password
6-
POSTGRES_PASSWORD=postgres
11+
DB_PASSWORD=postgres
712

813
# The values below this line do not need to be changed
914
###################################################################################
10-
POSTGRES_USER=postgres
11-
POSTGRES_DB=rodhaj
15+
DB_USERNAME=postgres
16+
DB_DATABASE_NAME=rodhaj

docker/wait-for

-191
This file was deleted.

taskfile.yml

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
version: '3'
2+
3+
tasks:
4+
dev-up:
5+
preconditions:
6+
- test -f docker/docker-compose.dev.yml
7+
cmds:
8+
- docker compose -f docker/docker-compose.dev.yml up -d
9+
10+
dev-stop:
11+
preconditions:
12+
- test -f docker/docker-compose.dev.yml
13+
cmds:
14+
- docker compose -f docker/docker-compose.dev.yml stop
15+
16+
start:
17+
preconditions:
18+
- test -f bot/config.yml
19+
cmds:
20+
- python bot/launcher.py
21+
silent: true
22+
23+
check:
24+
cmds:
25+
- ruff check bot --fix --exit-non-zero-on-fix
26+
- ruff format bot
27+
silent: true
28+
29+
fmt:
30+
cmds:
31+
- ruff format server
32+
silent: true

0 commit comments

Comments
 (0)