Skip to content

Commit

Permalink
time to rewrite the workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
No767 committed Aug 7, 2024
1 parent 9d9e732 commit a1f46ac
Show file tree
Hide file tree
Showing 6 changed files with 111 additions and 18 deletions.
20 changes: 20 additions & 0 deletions docker/docker-compose.dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: rodhaj_dev

# For development purposes, it is recommended in order to start the bot normally and using the Dev Reloader system
services:
database:
container_name: rodhaj_postgres
build:
context: ./pg
dockerfile: Dockerfile
environment:
POSTGRES_PASSWORD: ${DB_PASSWORD}
POSTGRES_DB: ${DB_DATABASE_NAME}
POSTGRES_USER: ${DB_USERNAME}
volumes:
- database:/var/lib/postgresql/data
ports:
- 5432:5432

volumes:
database:
64 changes: 64 additions & 0 deletions docker/docker-compose.prod..yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: rodhaj_prod

services:
rodhaj:
container_name: rodhaj
image: ghcr.io/transprogrammer/rodhaj:latest
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'
restart: always

database:
container_name: rodhaj_postgres
build:
context: ./pg
dockerfile: Dockerfile
environment:
POSTGRES_PASSWORD: ${DB_PASSWORD}
POSTGRES_DB: ${DB_DATABASE_NAME}
POSTGRES_USER: ${DB_USERNAME}
POSTGRES_INITDB_ARGS: '--data-checksums'
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
interval: 5m
start_interval: 30s
start_period: 5m
restart: always

rodhaj-prometheus:
container_name: rodhaj_prometheus
ports:
- 9090:9090
image: prom/prometheus:latest
volumes:
- ./prometheus.yml:/etc/prometheus/prometheus.yml
- prometheus-data:/prometheus

# first login uses admin/admin
# add data source for http://immich-prometheus:9090 to get started
rodhaj-grafana:
container_name: rodhaj_grafana
command: ['./run.sh', '-disable-reporting']
ports:
- 3000:3000
image: grafana/grafana-enterprise:11.1.3-ubuntu
volumes:
- grafana-data:/var/lib/grafana

volumes:
database:
prometheus-data:
grafana-data:
25 changes: 17 additions & 8 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,38 @@ services:
container_name: rodhaj
image: ghcr.io/transprogrammer/rodhaj:latest
volumes:
# Do not edit the next line. If you want to change the media storage location on your system, edit the value of UPLOAD_LOCATION in the .env file
# 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:3001
- 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'
restart: always

database:
container_name: rodhaj_postgres
image: rodhaj/postgres:latest
build:
context: ./pg
dockerfile: Dockerfile
environment:
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
POSTGRES_USER: ${POSTGRES_USER}
POSTGRES_PASSWORD: ${DB_PASSWORD}
POSTGRES_DB: ${DB_DATABASE_NAME}
POSTGRES_USER: ${DB_USERNAME}
POSTGRES_INITDB_ARGS: '--data-checksums'
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
- ${DB_DATA_LOCATION}:/var/lib/postgresql/data
- database:/var/lib/postgresql/data
healthcheck:
test: pg_isready --dbname='${POSTGRES_DB}' --username='${POSTGRES_USER}' || exit 1; Chksum="$$(psql --dbname='${POSTGRES_DB}' --username='${POSTGERS_USER}' --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
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
interval: 5m
start_interval: 30s
start_period: 5m
restart: always
restart: always

volumes:
database:
9 changes: 1 addition & 8 deletions docker/example.env
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,10 @@
# The configuration can be found under the config-example.yml
CONFIG_LOCATION=./config.yml

# The location where your database files are stored
DB_DATA_LOCATION=./postgres

# Connection secret for the rodhaj user. You should change it to a random password
RODHAJ_PASSWORD=rodhaj

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


# The values below this line do not need to be changed
###################################################################################
POSTGRES_USER=postgres
POSTGRES_DB=postgres
POSTGRES_DB=rodhaj
3 changes: 1 addition & 2 deletions docker/pg/init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,5 @@
set -e

psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" <<-EOSQL
CREATE ROLE rodhaj WITH LOGIN PASSWORD '$RODHAJ_PASSWORD';
CREATE DATABASE rodhaj OWNER rodhaj;
CREATE EXTENSION IF NOT EXISTS pg_trgm;
EOSQL
8 changes: 8 additions & 0 deletions docker/prometheus.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
global:
scrape_interval: 15s
evaluation_interval: 15s

scrape_configs:
- job_name: rodhaj
static_configs:
- targets: ['rodhaj:8555']

0 comments on commit a1f46ac

Please sign in to comment.