Skip to content

Commit bb96007

Browse files
committed
chore: Make initial repos available in the docker compose setup
1 parent 13b92d2 commit bb96007

File tree

4 files changed

+9
-2
lines changed

4 files changed

+9
-2
lines changed

examples/docker_compose/docker-compose-postgres.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,10 @@ services:
1212
DATABASE_TYPE: postgres
1313
volumes:
1414
- ./grader_service_config.py:/app/grader_service_config.py
15+
- service_dir:/app/service_dir
1516
- ./data_only.sql:/app/data_only.sql
1617
- ./init-db-postgres.sh:/app/init-db-postgres.sh
18+
- ./init_repos:/app/init_repos
1719
depends_on:
1820
postgres:
1921
condition: service_healthy

examples/docker_compose/docker-compose.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ services:
1414
- service_dir:/app/service_dir
1515
- ./init-db.sh:/app/init-db.sh
1616
- ./data_only.sql:/app/data_only.sql
17+
- ./init_repos:/app/init_repos
1718
environment:
1819
DATABASE_TYPE: ${DATABASE_TYPE:-sqlite}
1920
RABBITMQ_GRADER_SERVICE_USERNAME: grader_user
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
#!/usr/bin/env bash
22
set -e
33

4-
echo "Initialize a PostgreSQL database: run migrations and load initial data."
4+
echo "Initialize a PostgreSQL database: run migrations, load initial data, and create initial repos."
55

66
/app/.venv/bin/grader-service-migrate -f /app/grader_service_config.py
77
# Try to load the initial data. This will fail on the first error (e.g. if the data already exists)
88
# and roll back the transaction.
99
if ! psql -v ON_ERROR_STOP=1 -h postgres -U postgres -d grader --single-transaction -f /app/data_only.sql; then
1010
echo "Initial data import failed; probably the database already exists and contains the data."
1111
fi
12+
13+
cp -r /app/init_repos/* /app/service_dir/git

examples/docker_compose/init-db.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env bash
22
set -e
33

4-
echo "Initialize an sqlite database: run migrations and load initial data."
4+
echo "Initialize an sqlite database: run migrations, load initial data, and create initial repos."
55

66
grader-service-migrate -f /app/grader_service_config.py
77
# Insert some initial data into the database. The import will fail if the data already
@@ -10,3 +10,5 @@ grader-service-migrate -f /app/grader_service_config.py
1010
if ! sqlite3 /app/service_dir/grader.db < /app/data_only.sql 2>/dev/null; then
1111
echo "Initial data import failed; probably the database already exists and contains the data."
1212
fi
13+
14+
cp -r /app/init_repos/* /app/service_dir/git

0 commit comments

Comments
 (0)