Feat: started CI/CD work

This commit is contained in:
2024-12-27 01:38:50 +03:00
parent 53bb09f41c
commit 3472c3fd71
5 changed files with 66 additions and 6 deletions

0
.woodpecker.yml Normal file
View File

17
Dockerfile Normal file
View File

@@ -0,0 +1,17 @@
FROM python:3.13.1-slim
WORKDIR /app
COPY poetry.lock pyproject.toml ./
RUN pip install poetry
RUN poetry config virtualenvs.create false
RUN poetry install --no-interaction --no-ansi
COPY .env .
COPY . .
ENV POSTGRES_PORT=5432
CMD ["python", "main.py"]

View File

@@ -1,10 +1,42 @@
services:
bot:
image: aboba:latest
deploy:
replicas: 1
restart_policy:
condition: on-failure
networks:
- bot_network
depends_on:
db:
condition: service_healthy
db:
image: postgres:alpine
restart: always
deploy:
replicas: 1
restart_policy:
condition: on-failure
environment:
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
POSTGRES_USER: ${POSTGRES_USER}
POSTGRES_DB: ${POSTGRES_DB}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-postgres}
POSTGRES_USER: ${POSTGRES_USER:-postgres}
POSTGRES_DB: ${POSTGRES_DB:-postgres}
ports:
- ${POSTGRES_PORT}:5432
- 5432
healthcheck:
test: ["CMD", "pg_isready"]
interval: 10s
timeout: 5s
retries: 10
networks:
- bot_network
volumes:
- postgres_data:/var/lib/postgresql/data
networks:
bot_network:
driver: overlay
volumes:
postgres_data:

View File

@@ -9,7 +9,7 @@ class Settings(BaseSettings):
postgres_password: SecretStr = Field('password', env="POSTGRES_PASSWORD")
postgres_db: str = Field('db', env="POSTGRES_DB")
postgres_host: str = Field('localhost', env="POSTGRES_HOST")
postgres_port: int = Field(15432, env="POSTGRES_PORT")
postgres_port: int = Field(5432, env="POSTGRES_PORT")
@property
def postgres_url(self) -> str:

11
supervisord.conf Normal file
View File

@@ -0,0 +1,11 @@
[supervisord]
nodaemon=false
[program:mybot]
command=python main.py
directory=/app
user=root
autostart=true
autorestart=true
stderr_logfile=/app/bot_err.log
stdout_logfile=/app/bot_out.log