version: '3.8' services: # Flask application service app: image: my-flask-app # Use the image built for your Flask app build: context: . # Build from Dockerfile in current directory ports: - "8000:8000" # Map host port 7860 to container port 7860 depends_on: - db # Ensure the db service is started before the app environment: - FLASK_ENV=development - DATABASE_URL=postgresql://user:password@db:5432/mydatabase # Connection URL for PostgreSQL networks: - my_network # Connect to the custom network # PostgreSQL database service db: image: postgres:13 # Use the official PostgreSQL image environment: POSTGRES_USER: user POSTGRES_PASSWORD: password POSTGRES_DB: mydatabase ports: - "5432:5432" # Map host port 5432 to container port 5432 networks: - my_network # Connect to the custom network networks: my_network: driver: bridge