Skip to content

Commit

Permalink
feat(db): add PostgreSQL to compose & actions
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulYakow committed Feb 13, 2024
1 parent 00bacc3 commit 7f6f473
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Deprecated
name: Manual Deploy
on:
workflow_dispatch:
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ jobs:
echo TG_TOKEN=${{ secrets.TG_TOKEN }} >> ${{ env.ENV_FILE_PATH }} && \
echo WEBHOOK_URL=${{ secrets.WEBHOOK_URL }} >> ${{ env.ENV_FILE_PATH }} && \
echo WEBHOOK_PORT=${{ secrets.WEBHOOK_PORT }} >> ${{ env.ENV_FILE_PATH }} && \
echo PG_DB=${{ secrets.PG_DB }} >> ${{ env.ENV_FILE_PATH }} && \
echo PG_USER=${{ secrets.PG_USER }} >> ${{ env.ENV_FILE_PATH }} && \
echo PG_PASSWORD=${{ secrets.PG_PASSWORD }} >> ${{ env.ENV_FILE_PATH }} && \
echo PG_PORT=${{ secrets.PG_PORT }} >> ${{ env.ENV_FILE_PATH }} && \
chmod 600 ${{ env.ENV_FILE_PATH }}"
- name: Restart container
Expand Down
30 changes: 30 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ services:
image: ${IMAGE_ID}
pull_policy: always
restart: unless-stopped
depends_on:
postgres:
condition: service_healthy
environment:
TG_TOKEN: ${TG_TOKEN}
WEBHOOK_URL: ${WEBHOOK_URL}
Expand All @@ -18,3 +21,30 @@ services:
delay: 5s
max_attempts: 3
window: 20s

postgres:
image: postgres:16.2-alpine3.19
container_name: bot-postgres
restart: unless-stopped
environment:
POSTGRES_DB: ${PG_DB}
POSTGRES_USER: ${PG_USER}
POSTGRES_PASSWORD: ${PG_PASSWORD}
PGDATA: "/var/lib/postgresql/data/pgdata"
volumes:
- test-bot_postgres:/var/lib/postgresql/data
ports:
- ${PG_PORT}:5432
healthcheck:
test: ["CMD-SHELL", 'pg_isready -U ${PG_USER} -d ${PG_DB}']
interval: 10s
timeout: 5s
retries: 5
start_period: 10s
deploy:
resources:
limits:
cpus: '1'
memory: 4G
volumes:
test-bot_postgres:

0 comments on commit 7f6f473

Please sign in to comment.