Skip to content

Commit 74e4c51

Browse files
ElysaSrcmultun
authored andcommitted
dev: clean up dev docker-compose
- Move docker-compose overrides files to docker folder - Add scripts/osrd-compose.sh to start docker-compose with host overrides
1 parent feafb8b commit 74e4c51

7 files changed

+61
-111
lines changed

.github/workflows/editoast.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ jobs:
8383
ref: ${{ github.event.pull_request.head.sha }}
8484

8585
- name: Init database
86-
run: psql postgresql://postgres:password@localhost -f init_db.sql
86+
run: psql postgresql://postgres:password@localhost -f ./docker/init_db.sql
8787

8888
- name: Install lib posgresql & geos
8989
run: |

docker-compose-host.yml

-103
This file was deleted.

docker-compose.yml

+9-7
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
version: '3'
2+
23
volumes:
34
psql_data:
45
redis_data:
6+
57
services:
68
postgres:
79
image: postgis/postgis:15-3.4-alpine
@@ -13,7 +15,7 @@ services:
1315
POSTGRES_PASSWORD: "password"
1416
volumes:
1517
- "psql_data:/var/lib/postgresql/data"
16-
- "./init_db.sql:/docker-entrypoint-initdb.d/init.sql"
18+
- "./docker/init_db.sql:/docker-entrypoint-initdb.d/init.sql"
1719
healthcheck:
1820
test: ["CMD", "pg_isready", "-d", "postgres://osrd:password@postgres/osrd"]
1921
start_period: 4s
@@ -39,12 +41,12 @@ services:
3941
context: core
4042
dockerfile: Dockerfile
4143
restart: unless-stopped
42-
ports: ["8080:80"]
43-
command: "java -ea -jar /app/osrd_core.jar api -p 80"
44+
ports: ["8080:8080"]
45+
command: "java -ea -jar /app/osrd_core.jar api -p 8080"
4446
environment:
4547
MIDDLEWARE_BASE_URL: "http://osrd-editoast"
4648
healthcheck:
47-
test: ["CMD", "curl", "-f", "http://localhost/health"]
49+
test: ["CMD", "curl", "-f", "http://localhost:8080/health"]
4850
start_period: 4s
4951
interval: 5s
5052

@@ -58,8 +60,8 @@ services:
5860
NGINX_CONFIG: "nginx-dev.conf"
5961
OSRD_GIT_DESCRIBE: ${OSRD_GIT_DESCRIBE}
6062
environment:
61-
- OSRD_LOCAL_BACKEND=true
62-
- OSRD_EDITOAST_URL=http://localhost:8090
63+
OSRD_LOCAL_BACKEND: "true"
64+
OSRD_EDITOAST_URL: http://localhost:8090
6365
restart: unless-stopped
6466
ports: ["3000:80"]
6567
healthcheck:
@@ -82,7 +84,7 @@ services:
8284
EDITOAST_PORT: 80
8385
PSQL_HOST: "postgres"
8486
REDIS_URL: "redis://redis"
85-
OSRD_BACKEND_URL: "http://osrd-core"
87+
OSRD_BACKEND_URL: "http://osrd-core:8080"
8688
DATABASE_URL: "postgres://osrd:password@postgres/osrd"
8789
command:
8890
- /bin/sh

docker/docker-compose.host.yml

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
version: '3'
2+
3+
services:
4+
postgres:
5+
ports: []
6+
network_mode: host
7+
healthcheck:
8+
test: ["CMD", "pg_isready", "-d", "postgres://osrd:password@localhost:5432/osrd"]
9+
10+
redis:
11+
ports: []
12+
network_mode: host
13+
14+
core:
15+
ports: []
16+
network_mode: host
17+
environment:
18+
MIDDLEWARE_BASE_URL: "http://localhost:8090"
19+
20+
editoast:
21+
ports: []
22+
network_mode: host
23+
environment:
24+
PSQL_HOST: "localhost"
25+
EDITOAST_PORT: 8090
26+
OSRD_BACKEND_URL: "http://localhost:8080"
27+
REDIS_URL: "redis://localhost"
28+
DATABASE_URL: "postgres://osrd:password@localhost:5432/osrd"
29+
healthcheck:
30+
test: ["CMD", "curl", "-f", "http://localhost:8090/health"]
31+
32+
wait-healthy:
33+
depends_on:
34+
editoast: {condition: service_healthy}
35+
restart: "no"
36+
image: alpine:latest
37+
command: "true"

docker-compose-storybook.yml docker/docker-compose.storybook.yml

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
version: '3'
2+
23
services:
34
storybook:
45
image: osrd/storybook

init_db.sql docker/init_db.sql

File renamed without changes.

scripts/osrd-compose.sh

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/sh
2+
3+
# This script leverages the host override docker-compose file to run the OSRD stack.
4+
# By design, this script is not meant to be run on Windows since it relies exclusively on network_mode: host.
5+
6+
set -e
7+
8+
# We override the default docker-compose file with the "host" version in the docker folder
9+
docker compose \
10+
-p "osrd" \
11+
-f "docker-compose.yml" \
12+
-f "docker/docker-compose.host.yml" \
13+
"$@"

0 commit comments

Comments
 (0)