forked from shivalkarrahul/docker-python-flask
-
Notifications
You must be signed in to change notification settings - Fork 0
/
docker-compose.yml
32 lines (28 loc) · 1.32 KB
/
docker-compose.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
version: '3' # Specifies the Docker Compose file version
services:
# Flask application service
app:
build: flask # Build the 'app' service using the Dockerfile in the 'flask' directory
volumes:
- app:/app # Mount the 'app' volume to the '/app' directory in the container
ports:
- "8000:8000" # Expose port 8000 on the host and map it to port 8000 in the container
links:
- redis:redis # Link the 'app' service to the 'redis' service by hostname
depends_on:
- redis # Ensure the 'redis' service starts before the 'app' service
# Redis service for caching and storing hit counts
redis:
image: "redis:alpine" # Use the lightweight Alpine version of the Redis image
expose:
- "6379" # Expose port 6379 for communication within the Docker network (not externally)
# Nginx reverse proxy service
proxy:
build: nginx # Build the 'proxy' service using the Dockerfile in the 'nginx' directory
restart: always # Automatically restart the container if it stops or crashes
ports:
- 80:80 # Map port 80 on the host to port 80 in the container for HTTP traffic
depends_on:
- app # Ensure the 'app' service is running before starting the 'proxy' service
volumes:
app: # Define the 'app' volume that is shared with the 'app' service to persist data