Skip to content

Commit 6ad9be4

Browse files
committed
chore: Small improvements in the docker-compose setup
- remove the network used by all containers (dc creates it by default) - set default DATABASE_TYPE to sqlite => simpler dc up commands - change restart policy to unless-stopped => containers don't restart after system restart (which was annoying in local development)
1 parent a1c496c commit 6ad9be4

File tree

4 files changed

+10
-37
lines changed

4 files changed

+10
-37
lines changed

docs/source/installation/docker.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ the containers together with their services.
1717

1818
Run the following command:
1919
```bash
20-
DATABASE_TYPE=sqlite docker compose up --build -d
20+
docker compose up --build -d
2121
```
2222

2323
This command builds the images and starts the containers in detached mode. It sets SQLite as its database that is integrated in `Grader Service`.
@@ -36,12 +36,10 @@ defined in a separate `docker-compose-postgres.yml` file.
3636

3737
Run the following command:
3838
```bash
39-
DATABASE_TYPE=postgres docker compose -f docker-compose.yml -f docker-compose-postgres.yml up -d
39+
docker compose -f docker-compose.yml -f docker-compose-postgres.yml up -d
4040
```
4141

4242
To stop and remove the containers, run:
4343
```bash
4444
docker compose -f docker-compose.yml -f docker-compose-postgres.yml down -v
4545
```
46-
47-

examples/docker_compose/README.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ the containers together with their services.
1616

1717
Run the following command:
1818
```bash
19-
DATABASE_TYPE=sqlite docker compose up --build -d
19+
docker compose up --build -d
2020
```
2121

2222
This command builds the images and starts the containers in detached mode. It sets SQLite as its database that is integrated in `Grader Service`.
@@ -35,12 +35,10 @@ defined in a separate `docker-compose-postgres.yml` file.
3535

3636
Run the following command:
3737
```bash
38-
DATABASE_TYPE=postgres docker compose -f docker-compose.yml -f docker-compose-postgres.yml up -d
38+
docker compose -f docker-compose.yml -f docker-compose-postgres.yml up -d
3939
```
4040

4141
To stop and remove the containers, run:
4242
```bash
4343
docker compose -f docker-compose.yml -f docker-compose-postgres.yml down -v
4444
```
45-
46-

examples/docker_compose/docker-compose-postgres.yml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,18 @@ services:
1010
- ./grader_service_config.py:/app/grader_service_config.py
1111
- ./data_only.sql:/app/data_only.sql
1212
- ./init-db.sh:/app/init-db.sh
13-
networks:
14-
- network
1513
depends_on:
1614
postgres:
1715
condition: service_healthy
1816

1917
postgres:
2018
image: postgres
21-
restart: always
19+
restart: unless-stopped
2220
environment:
2321
# required for using postgres image
2422
POSTGRES_PASSWORD: postgres
2523
POSTGRES_DB: grader
26-
networks:
27-
- network
2824
healthcheck:
2925
test: [ "CMD", "pg_isready", "-U", "postgres" ]
3026
interval: 5s
31-
retries: 5
27+
retries: 5

examples/docker_compose/docker-compose.yml

Lines changed: 4 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,13 @@ services:
99
- ./grader_service_config.py:/app/grader_service_config.py
1010
- service_dir:/app/service_dir
1111
environment:
12-
DATABASE_TYPE: ${DATABASE_TYPE}
12+
DATABASE_TYPE: ${DATABASE_TYPE:-sqlite}
1313
RABBITMQ_GRADER_SERVICE_USERNAME: grader_user
1414
RABBITMQ_GRADER_SERVICE_PASSWORD: grader_password
15-
restart: always
15+
restart: unless-stopped
1616
depends_on:
1717
init-volume:
1818
condition: service_completed_successfully
19-
networks:
20-
- network
2119
expose:
2220
- "4010"
2321

@@ -29,18 +27,14 @@ services:
2927
- /var/run/docker.sock:/var/run/docker.sock:rw
3028
- ./jupyterhub_config.py:/app/jupyterhub_config.py
3129
- ./data-hub:/data
32-
restart: always
30+
restart: unless-stopped
3331
depends_on:
3432
- service
35-
networks:
36-
- network
3733
ports:
3834
- "8080:8080"
3935

4036
rabbitmq:
4137
image: rabbitmq:latest
42-
networks:
43-
- network
4438
environment:
4539
RABBITMQ_DEFAULT_VHOST: grader
4640
RABBITMQ_DEFAULT_USER: grader_user
@@ -54,12 +48,6 @@ services:
5448
build:
5549
context: ../..
5650
dockerfile: examples/docker_compose/Dockerfile-Service
57-
networks:
58-
- network
59-
command:
60-
- "grader-worker"
61-
- "-f"
62-
- "/app/grader_service_config.py"
6351
volumes:
6452
- ./grader_service_config.py:/app/grader_service_config.py
6553
- service_dir:/app/service_dir
@@ -68,7 +56,7 @@ services:
6856
environment:
6957
RABBITMQ_GRADER_SERVICE_USERNAME: grader_user
7058
RABBITMQ_GRADER_SERVICE_PASSWORD: grader_password
71-
DATABASE_TYPE: ${DATABASE_TYPE}
59+
DATABASE_TYPE: ${DATABASE_TYPE:-sqlite}
7260

7361
init-volume:
7462
build:
@@ -77,14 +65,7 @@ services:
7765
volumes:
7866
- ./service_dir:/local_service_dir
7967
- service_dir:/volume_service_dir
80-
networks:
81-
- network
82-
8368

8469
volumes:
8570
jupyterhub-data:
8671
service_dir:
87-
88-
networks:
89-
network:
90-
driver: bridge

0 commit comments

Comments
 (0)