March 30, 2024, 11:46 a.m. | Felipe Arcaro

DEV Community dev.to




TL;DR


Here's the docker-compose.yml file to dockerize a Flask application, a Mongo database and a schedule service:



version: '3.8'

services:
app:
container_name: my_app_${ENV}
build:
context: .
ports:
- 8001:8001
depends_on:
- mongo_db
networks:
- my_network
command: ["flask", "run", "--host", "0.0.0.0", "--port", "8001"]
env_file: .env

schedule_service:
container_name: schedule_service_${ENV}
build:
context: ./scheduler
volumes:
- ./common:/app/common
- ./db:/app/db
networks:
- my_networknetwork
command: ["python", "-u", "scheduler.py"]
env_file: .env

mongo_db:
container_name: mongo_db_${ENV}
image: mongo:4.4.18
restart: always
ports:
- 27017:27017
volumes:
- ./DB-STORAGE/mongo-db-$ENV:/data/db
- ./db/init-mongo.sh:/docker-entrypoint-initdb.d/init-mongo.sh
networks: …

app application build command context database docker docker-compose file flask networks python service services

Founding AI Engineer, Agents

@ Occam AI | New York

AI Engineer Intern, Agents

@ Occam AI | US

AI Research Scientist

@ Vara | Berlin, Germany and Remote

Data Architect

@ University of Texas at Austin | Austin, TX

Data ETL Engineer

@ University of Texas at Austin | Austin, TX

Lead GNSS Data Scientist

@ Lurra Systems | Melbourne