-
Notifications
You must be signed in to change notification settings - Fork 0
/
docker-compose-codecarbon.yml
110 lines (102 loc) · 4.7 KB
/
docker-compose-codecarbon.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
services:
# Ollama service
codecarbon_ollama:
# Build the Ollama image from the Dockerfile.ollama
build:
context: .
dockerfile: Dockerfile.ollama
container_name: codecarbon_ollama-server
# Security options to enhance container security
security_opt:
- no-new-privileges:true
cap_drop:
- ALL
cap_add:
- NET_BIND_SERVICE
# Expose port 11434 for the Ollama service
ports:
- "11434:11434"
# Mount a volume for model persistence
codecarbon_carbonserver:
depends_on:
- codecarbon_postgres # Ensure postgres service is started before carbonserver
build:
context: ./carbonserver # Build the Docker image from the carbonserver directory
dockerfile: Dockerfile.codecarbon # Specify the Dockerfile to use, you need to create this file
volumes:
- ./carbonserver:/carbonserver # Mount the carbonserver directory to the container
ports:
- "8008:8000" # Map port 8008 on the host to port 8000 in the container
environment:
CODECARBON_LOG_LEVEL: DEBUG # Set the log level to DEBUG
DATABASE_URL: "postgresql://${DATABASE_USER:-codecarbon-user}:${DATABASE_PASS:-supersecret}@${DATABASE_HOST:-codecarbon_postgres}:${DATABASE_PORT:-5432}/${DATABASE_NAME:-codecarbon_db}" # Database connection string
networks:
- codecarbon_net # Connect to the codecarbon_net network
codecarbon_postgres:
container_name: ${DATABASE_HOST:-codecarbon_postgres} # Set the container name
image: postgres:13 # Use the postgres:13 image
environment:
HOSTNAME: ${DATABASE_HOST:-codecarbon_postgres} # Set the hostname
POSTGRES_DB: ${DATABASE_NAME:-codecarbon_db} # Set the database name
POSTGRES_USER: ${DATABASE_USER:-codecarbon-user} # Set the database user
POSTGRES_PASSWORD: ${DATABASE_PASS:-supersecret} # Set the database password
ports:
- "5480:5432" # Map port 5480 on the host to port 5432 in the container
volumes:
- codecarbon_postgres_data:/var/lib/postgresql/data:rw # Persist data in a named volume
networks:
- codecarbon_net # Connect to the codecarbon_net network
restart: unless-stopped # Restart policy
codecarbon_pgadmin:
container_name: codecarbon_pgadmin # Set the container name
image: dpage/pgadmin4 # Use the dpage/pgadmin4 image
environment:
PGADMIN_DEFAULT_EMAIL: ${PGADMIN_DEFAULT_EMAIL:-test@test.com} # Set the default email for pgAdmin
PGADMIN_DEFAULT_PASSWORD: ${PGADMIN_DEFAULT_PASSWORD:-test} # Set the default password for pgAdmin
ports:
- "${PGADMIN_PORT:-5080}:80" # Map the specified port on the host to port 80 in the container
volumes:
- codecarbon_pgadmin:/root/.pgadmin # Persist pgAdmin data in a named volume
- ./carbonserver/docker/pgpassfile:/pgadmin4/pgpassfile # Mount pgpassfile for pgAdmin
- ./carbonserver/docker/pgadmin-servers.json:/pgadmin4/servers.json # Mount servers.json for pgAdmin
networks:
- codecarbon_net # Connect to the codecarbon_net network
restart: unless-stopped # Restart policy
codecarbon_prometheus:
image: prom/prometheus:latest # Use the latest Prometheus image
ports:
- "9090:9090" # Map port 9090 on the host to port 9090 in the container
volumes:
- ./docker/prometheus.yml:/etc/prometheus/prometheus.yml # Mount the Prometheus configuration file
depends_on:
- codecarbon_prometheus-pushgateway # Ensure prometheus-pushgateway service is started before prometheus
networks:
- codecarbon_net # Connect to the codecarbon_net network
codecarbon_prometheus-pushgateway:
image: prom/pushgateway # Use the prom/pushgateway image
ports:
- "9091:9091" # Map port 9091 on the host to port 9091 in the container
networks:
- codecarbon_net # Connect to the codecarbon_net network
codecarbon_my_app:
build:
context: . # Build the Docker image from the current directory
dockerfile: ./Dockerfile # Specify the Dockerfile to use
ports:
- "7860:7860" # Map port 7860 on the host to port 7860 in the container
environment:
AT_API_KEY: ${AT_API_KEY} # Set the API key environment variable
depends_on:
- codecarbon_carbonserver # Ensure carbonserver service is started before my_app
- codecarbon_postgres # Ensure postgres service is started before my_app
networks:
- codecarbon_net # Connect to the codecarbon_net network
volumes:
ollama_models:
codecarbon_postgres_data:
name: codecarbon_postgres_data # Name the volume for postgres data
codecarbon_pgadmin:
name: codecarbon_pgadmin_data # Name the volume for pgAdmin data
networks:
codecarbon_net:
name: codecarbon_network # Name the network