Skip to content

Commit

Permalink
New structure docker files, update makefile. New main.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
dev-lymar committed Sep 25, 2024
1 parent e2c33ee commit 4bd13fa
Show file tree
Hide file tree
Showing 12 changed files with 113 additions and 223 deletions.
6 changes: 3 additions & 3 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ pip-wheel-metadata/
.eggs/

# Exclude Docker Compose files (if not needed inside the container)
docker-compose.yml
docker-compose.dev.yml
docker-compose.prod.yml
docker/docker-compose.yml
docker/docker-compose.dev.yml
docker/docker-compose.prod.yml

# Exclude various images and pictures if they are not required for assembly
img/
Expand Down
17 changes: 10 additions & 7 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
uses: docker/build-push-action@v3
with:
push: true
tags: ${{ secrets.DOCKER_USERNAME }}/hamster_bot:v1.8.3
tags: ${{ secrets.DOCKER_USERNAME }}/hamster_bot:v1.8.5

deploy:
runs-on: ubuntu-latest
Expand All @@ -50,7 +50,7 @@ jobs:
username: ${{ secrets.USERNAME }}
port: ${{ secrets.PORT }}
key: ${{ secrets.SSHKEY }}
source: "redis.conf,docker-compose.prod.yml"
source: "redis.conf,Makefile,docker/docker-compose.yml,docker/docker-compose.prod.yml"
target: "/home/${{ secrets.USERNAME }}/Hamster-generator"

- name: Execute deployment commands
Expand All @@ -62,8 +62,11 @@ jobs:
key: ${{ secrets.SSHKEY }}
script: |
cd /home/ubuntu/Hamster-generator
ls -la
sed -i 's/IMAGE_TAG=.*/IMAGE_TAG=v1.8.5/' .env.prod
make prod-down
make prod-up
create-release:
runs-on: ubuntu-latest
Expand All @@ -76,10 +79,10 @@ jobs:
- name: Create GitHub Release
uses: ncipollo/release-action@v1
with:
tag: v1.8.3
name: "Release v1.8.3"
tag: v1.8.5
name: "Release v1.8.5"
body: |
Dockerhub deploy. New workflow. Message to telegram. Final release | 🏖️
Final release | 🏖️
token: ${{ secrets.GITHUB_TOKEN }}

send_message:
Expand Down
21 changes: 0 additions & 21 deletions Dockerfile.dev

This file was deleted.

10 changes: 8 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,13 @@ run_bot:
python3 -m bot.main

run_dev_db_docker:
docker-compose -f docker-compose.dev.yml up postgres redis
docker-compose -f ./docker/docker-compose.yml -f ./docker/docker-compose.dev.yml --env-file .env.prod up postgres redis

run_dev_bot_docker:
docker-compose -f docker-compose.dev.yml up bot
docker-compose -f ./docker/docker-compose.yml -f ./docker/docker-compose.dev.yml --env-file .env.prod up bot

prod-up:
docker-compose -f docker-compose.yml -f docker-compose.prod.yml --env-file .env.prod up -d

prod-down:
docker-compose -f docker-compose.yml -f docker-compose.prod.yml --env-file .env.prod down
67 changes: 0 additions & 67 deletions docker-compose.dev.yml

This file was deleted.

72 changes: 0 additions & 72 deletions docker-compose.prod.yml

This file was deleted.

16 changes: 8 additions & 8 deletions Dockerfile → docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@ FROM python:3.12.2-slim

RUN apt-get update && apt-get install -y postgresql-client && rm -rf /var/lib/apt/lists/*

WORKDIR /assistant
WORKDIR /hamster

COPY requirements.txt requirements.txt
COPY ../requirements.txt requirements.txt

RUN pip install --upgrade pip \
&& pip install -r requirements.txt

COPY app app
COPY bot bot
COPY alembic alembic
COPY alembic.ini alembic.ini
COPY db db
COPY config config
COPY ../app app
COPY ../bot bot
COPY ../alembic alembic
COPY ../alembic.ini alembic.ini
COPY ../db db
COPY ../config config
12 changes: 12 additions & 0 deletions docker/Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM python:3.12.2-slim

RUN apt-get update && apt-get install -y postgresql-client && rm -rf /var/lib/apt/lists/*

WORKDIR /hamster

COPY ../requirements-dev.txt requirements-dev.txt

RUN pip install --upgrade pip \
&& pip install -r requirements-dev.txt

COPY .. .
31 changes: 31 additions & 0 deletions docker/docker-compose.dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
services:
app:
build:
context: ../
dockerfile: ./docker/Dockerfile.dev
env_file:
- ../.env.dev
volumes:
- .:/hamster
command: python3 -m app.main
depends_on:
- postgres
- redis
networks:
- app-network

bot:
build:
context: ../
dockerfile: ./docker/Dockerfile.dev
env_file:
- ../.env.dev
volumes:
- ../:/hamster
- ../images_data:/hamster/bot/images
command: python3 -m bot.main
depends_on:
- postgres
- redis
networks:
- app-network
40 changes: 40 additions & 0 deletions docker/docker-compose.prod.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
services:
migrate:
image: lymarvolodymyr/hamster_bot:${IMAGE_TAG}
env_file:
- ../.env.prod
command: alembic upgrade head
depends_on:
- postgres
networks:
- app-network

app:
image: lymarvolodymyr/hamster_bot:${IMAGE_TAG}
env_file:
- ../.env.prod
command: python3 -m app.main
volumes:
- ./proxies.txt:/hamster/proxies.txt
- ./logs/app:/hamster/logs/app
depends_on:
- migrate
- postgres
- redis
networks:
- app-network

bot:
image: lymarvolodymyr/hamster_bot:${IMAGE_TAG}
env_file:
- ../.env.prod
command: python3 -m bot.main
volumes:
- ./images_data:/hamster/bot/images
- ./logs/bot:/hamster/logs/bot
depends_on:
- migrate
- postgres
- redis
networks:
- app-network
Loading

0 comments on commit 4bd13fa

Please sign in to comment.