diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 000000000..0890af733 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,12 @@ +.idea +.git +schema.pdf +LICENCE +Dockerfile.python +*.md +.gitignore +Dockerfile* +compose.yaml +.env +*.md +*.sh \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 000000000..2eea525d8 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.env \ No newline at end of file diff --git a/Dockerfile.python b/Dockerfile.python new file mode 100644 index 000000000..1bbf3b474 --- /dev/null +++ b/Dockerfile.python @@ -0,0 +1,10 @@ +FROM python:3.12-slim + +WORKDIR /app + +COPY . . + +RUN pip install -r requirements.txt + +# Запускаем приложение с помощью uvicorn, делая его доступным по сети +CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "5000"] diff --git a/compose.yaml b/compose.yaml new file mode 100644 index 000000000..feb2b94f8 --- /dev/null +++ b/compose.yaml @@ -0,0 +1,45 @@ +include: + - proxy.yaml +services: + web: + build: + context: . + dockerfile: Dockerfile.python + restart: always + ports: + - "5000:5000" + environment: + - DB_HOST=db + - DB_USER=${MYSQL_USER} + - DB_PASSWORD=${MYSQL_PASSWORD} + - DB_NAME=${MYSQL_DATABASE} + networks: + backend: + ipv4_address: 172.20.0.5 + depends_on: + db: + condition: service_healthy + container_name: python-web-app + + db: + image: mysql:8 + restart: always + environment: + MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD} + MYSQL_DATABASE: ${MYSQL_DATABASE} + MYSQL_USER: ${MYSQL_USER} + MYSQL_PASSWORD: ${MYSQL_PASSWORD} + networks: + backend: + ipv4_address: 172.20.0.10 + healthcheck: + test: ["CMD", "mysqladmin", "ping", "-h", "localhost"] + timeout: 20s + retries: 10 + container_name: mysql-db + volumes: + - mysql_data:/var/lib/mysql + - ./init.sql:/docker-entrypoint-initdb.d/init.sql + +volumes: + mysql_data: \ No newline at end of file diff --git a/docker-compose.sh b/docker-compose.sh new file mode 100755 index 000000000..6005899c4 --- /dev/null +++ b/docker-compose.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +sudo apt install snapd +sudo snap install docker +sudo apt install docker-compose + +cd /opt +git clone https://github.com/goosecompote/shvirtd-example-python +cd /opt/shvirtd-example-python +docker compose up -d