From 9d50d113d523647f295f9e43cec8af7751fdd02f Mon Sep 17 00:00:00 2001 From: IgorVolochay Date: Sat, 8 Mar 2025 18:46:04 +0300 Subject: [PATCH] build: add dockerfile and docker-compose file for automatically build --- app/dockerfile | 11 +++++++++++ docker-compose.yml | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 app/dockerfile create mode 100644 docker-compose.yml diff --git a/app/dockerfile b/app/dockerfile new file mode 100644 index 0000000..281fd13 --- /dev/null +++ b/app/dockerfile @@ -0,0 +1,11 @@ +FROM python:3.9.21-alpine + +WORKDIR /app + +COPY . . + +RUN pip3 install -r requirements.txt + +EXPOSE 5000 + +CMD ["python3", "main.py"] \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..c21f383 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,34 @@ +version: '3.8' + +services: + mongodb: + image: mongodb/mongodb-community-server + container_name: tort-mongodb + restart: always + network_mode: bridge + environment: + MONGO_INITDB_ROOT_USERNAME: ${MONGO_USER} + MONGO_INITDB_ROOT_PASSWORD: ${MONGO_PASS} + ports: + - "127.0.0.1:${MONGO_PORT}:27017" + healthcheck: + test: ["CMD", "mongosh", "--username", "${MONGO_USER}", "--password", "${MONGO_PASS}", "--eval", "db.runCommand({ ping: 1 })"] + interval: 10s + timeout: 5s + retries: 2 + + backend: + build: + context: ./app + image: tort-backend:latest + depends_on: + mongodb: + condition: service_healthy + container_name: tort-backend + network_mode: "host" + environment: + MONGO_HOST: ${MONGO_HOST} + MONGO_PORT: ${MONGO_PORT} + MONGO_USER: ${MONGO_USER} + MONGO_PASS: ${MONGO_PASS} +