{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Launch the Bot",
"type": "debugpy",
"request": "launch",
"cwd": "${workspaceFolder}/GeniusXBot/",
"program": "${workspaceFolder}/GeniusXBot/bot.py",
"console": "integratedTerminal"
},
{
"name": "Python: Attach to Docker Container",
"type": "debugpy",
"request": "attach",
"connect": {
"host": "localhost",
"port": 5678
},
"pathMappings": [
{
"localRoot": "${workspaceFolder}",
"remoteRoot": "/bot"
}
],
"justMyCode": false
}
]
}
FROM python:3.10-alpine
WORKDIR /bot
COPY pyproject.toml .
COPY poetry.lock .
RUN apk update
# Install Poetry
RUN apk add curl
RUN curl -sSL https://install.python-poetry.org | POETRY_VERSION=2.0.1 python3 -
# Install dependencies
RUN apk add gcc
RUN /root/.local/bin/poetry install
COPY . .
# Convert DOS line endings to Unix
RUN dos2unix /bot/*.sh
RUN chmod +x /bot/*.sh
# Expose debugpy port for debugging
EXPOSE 5678
# Run the bot
# CMD ["/root/.local/bin/poetry", "run", "python3", "./GeniusXBot/bot.py"]
CMD ["/root/.local/bin/poetry", "run", "python3", "-m", "debugpy", "--listen", "0.0.0.0:5678", "--wait-for-client", "./GeniusXBot/bot.py"]
services:
bot:
build: ./
image: gx-bot
container_name: gx-bot
environment:
DB_URL: "mysql+aiomysql://root:${DB_PASSWORD}@mysql/bot"
REDIS_URL: "redis://redis:6379/0"
ports:
- "5678:5678" # debugpy port
depends_on:
redis:
condition: service_healthy
mysql:
condition: service_healthy
volumes:
- ./:/bot
redis:
image: redis:7.4.3-alpine
container_name: gx-redis
healthcheck:
test: redis-cli ping | grep PONG
start_interval: 5s
start_period: 30s
interval: 1d
timeout: 5s
retries: 3
ports:
- "6379:6379"
volumes:
- gx-redis-data:/data
mysql:
image: mysql:8
container_name: gx-mysql
environment:
- MYSQL_ROOT_PASSWORD=${DB_PASSWORD}
- MYSQL_DATABASE=${DB_NAME}
healthcheck:
test: mysql -h 127.0.0.1 -uroot -p$$MYSQL_ROOT_PASSWORD -e 'SELECT 1' || exit 1 # It works
start_interval: 5s
start_period: 60s
interval: 1d
timeout: 5s
retries: 3
ports:
- "3306:3306"
volumes:
- gx-mysql-data:/var/lib/mysql
volumes:
gx-mysql-data:
gx-redis-data:
nc -zv localhost 5678
из WSL показывает, что подключение к localhost:5678 успешное.