Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
65063fa
chore: Small improvements in the docker-compose setup
natkam Sep 18, 2025
0cdcc30
fix: Fix the initial SQL data import for local docker-compose setup
natkam Oct 15, 2025
2615da6
fix: added psycog2 package to init container and set grader network
florian-jaeger Oct 17, 2025
802130b
fix: Remove postgres-specific syntax from the initial data file
natkam Oct 17, 2025
d104499
cleaup: Remove psycopg from Dockerfile (not needed, after all)
natkam Oct 17, 2025
fc53025
fix: Fix database initialisation in docker compose for sqlite and pos…
natkam Oct 17, 2025
e8f7002
fix: update docker compose docs
natkam Oct 17, 2025
98f6664
fix: Fix a comment
natkam Oct 17, 2025
aa80eed
chore: Use uv to install python packages in containers in Docker Comp…
natkam Oct 22, 2025
eb8feb3
chore: Make the various init bash scripts for containers more consistent
natkam Oct 22, 2025
144f180
chore: Also use uv in jupyterhub Dockerfile
natkam Oct 23, 2025
21f78ce
cleanup: Remove a redundant `expose` from docker compose file
natkam Oct 23, 2025
ebbc077
fix: Remove submission data from the initial db import
natkam Oct 23, 2025
b72014a
fix: Simplify python deps installation in Dockerfile-Service
natkam Oct 24, 2025
b767d84
fix: Only load one assignment as initial db data in docker compose setup
natkam Oct 29, 2025
2f57d5e
fix: Set the initial data assignment deadline to a future date
natkam Nov 6, 2025
3dc7923
fix: Small adjustment in the init assignment data
natkam Nov 6, 2025
ebe8fa2
chore: Add initial 'source' repo for docker compose setup
natkam Nov 6, 2025
13b92d2
chore: Add initial 'release' repo for docker compose setup
natkam Nov 6, 2025
bb96007
chore: Make initial repos available in the docker compose setup
natkam Nov 6, 2025
0483f56
fix: Fix celery worker container command
natkam Nov 6, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions docs/source/installation/docker.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ the containers together with their services.

Run the following command:
```bash
DATABASE_TYPE=sqlite docker compose up --build -d
docker compose up --build -d
```

This command builds the images and starts the containers in detached mode. It sets SQLite as its database that is integrated in `Grader Service`.
Expand All @@ -43,5 +43,3 @@ To stop and remove the containers, run:
```bash
docker compose -f docker-compose.yml -f docker-compose-postgres.yml down -v
```


22 changes: 13 additions & 9 deletions examples/docker_compose/Dockerfile-DBInit
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
FROM postgres

# Install git
# Install python
RUN apt-get update && \
apt-get install -y python3 python3-venv && \
apt-get install -y python3 && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

# Install uv
COPY --from=ghcr.io/astral-sh/uv:0.9.3 /uv /uvx /bin/

WORKDIR /app

# Copy necessary files and folders
# Install python dependencies, only copying necessary files
COPY ./pyproject.toml MANIFEST.in ./
COPY ./grader_service ./grader_service
# Create a virtual environment
RUN python3 -m venv /venv
RUN --mount=type=cache,target=/root/.cache/uv \
uv sync --no-dev

# Activate venv and install the package
RUN /venv/bin/pip install .
# Copy the project files and install the package itself
COPY ./grader_service ./grader_service
RUN --mount=type=cache,target=/root/.cache/uv \
uv pip install .

CMD ["sh", "-c", "/app/init-db.sh"]
CMD ["sh", "-c", "/app/init-db-postgres.sh"]
10 changes: 6 additions & 4 deletions examples/docker_compose/Dockerfile-Hub
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@ RUN apt-get update && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

# Install uv
COPY --from=ghcr.io/astral-sh/uv:0.9.3 /uv /uvx /bin/

WORKDIR /app

ENV JUPYTERHUB_CRYPT_KEY=e3f92a0d5e37446c7e894a2ef6c6ec3bcb4aa3c38d2a442eb567adf780597aa0

RUN pip install grader_labextension

RUN python3 -m pip install dockerspawner oauthenticator
RUN --mount=type=cache,target=/root/.cache/uv \
uv pip install grader_labextension dockerspawner oauthenticator

CMD ["jupyterhub", "-f", "/app/jupyterhub_config.py"]
CMD ["jupyterhub", "-f", "/app/jupyterhub_config.py"]
19 changes: 13 additions & 6 deletions examples/docker_compose/Dockerfile-Service
Original file line number Diff line number Diff line change
@@ -1,19 +1,26 @@
FROM python:3.13-slim

# Install git
# Install git and sqlite
RUN apt-get update && \
apt-get install -y git && \
apt-get install -y git sqlite3 && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

# Install uv
COPY --from=ghcr.io/astral-sh/uv:0.9.3 /uv /uvx /bin/
ENV UV_SYSTEM_PYTHON=true

WORKDIR /app

# Copy necessary files and folders
# Install python dependencies, only copying necessary files
COPY ./pyproject.toml MANIFEST.in ./
COPY ./grader_service ./grader_service
RUN --mount=type=cache,target=/root/.cache/uv \
uv sync

RUN pip install .
RUN pip install numpy ipykernel
# Copy the project files and install the package itself
COPY ./grader_service ./grader_service
RUN --mount=type=cache,target=/root/.cache/uv \
uv pip install .

# Set default branch to main and default user
RUN git config --global init.defaultBranch main && \
Expand Down
4 changes: 1 addition & 3 deletions examples/docker_compose/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ the containers together with their services.

Run the following command:
```bash
DATABASE_TYPE=sqlite docker compose up --build -d
docker compose up --build -d
```

This command builds the images and starts the containers in detached mode. It sets SQLite as its database that is integrated in `Grader Service`.
Expand All @@ -42,5 +42,3 @@ To stop and remove the containers, run:
```bash
docker compose -f docker-compose.yml -f docker-compose-postgres.yml down -v
```


57 changes: 15 additions & 42 deletions examples/docker_compose/data_only.sql

Large diffs are not rendered by default.

16 changes: 9 additions & 7 deletions examples/docker_compose/docker-compose-postgres.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
services:

service:
command: [] # Use the default CMD from Dockerfile-Service, i.e. just run grader-service

db-init:
build:
context: ../..
Expand All @@ -8,24 +12,22 @@ services:
DATABASE_TYPE: postgres
volumes:
- ./grader_service_config.py:/app/grader_service_config.py
- service_dir:/app/service_dir
- ./data_only.sql:/app/data_only.sql
- ./init-db.sh:/app/init-db.sh
networks:
- network
- ./init-db-postgres.sh:/app/init-db-postgres.sh
- ./init_repos:/app/init_repos
depends_on:
postgres:
condition: service_healthy

postgres:
image: postgres
restart: always
restart: unless-stopped
environment:
# required for using postgres image
POSTGRES_PASSWORD: postgres
POSTGRES_DB: grader
networks:
- network
healthcheck:
test: [ "CMD", "pg_isready", "-U", "postgres" ]
interval: 5s
retries: 5
retries: 5
32 changes: 11 additions & 21 deletions examples/docker_compose/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,24 @@ services:
build:
context: ../..
dockerfile: examples/docker_compose/Dockerfile-Service
command: bash -c "
/app/init-db.sh
&& grader-service -f /app/grader_service_config.py
"
volumes:
- ./grader_service_config.py:/app/grader_service_config.py
- service_dir:/app/service_dir
- ./init-db.sh:/app/init-db.sh
- ./data_only.sql:/app/data_only.sql
- ./init_repos:/app/init_repos
environment:
DATABASE_TYPE: ${DATABASE_TYPE}
DATABASE_TYPE: ${DATABASE_TYPE:-sqlite}
RABBITMQ_GRADER_SERVICE_USERNAME: grader_user
RABBITMQ_GRADER_SERVICE_PASSWORD: grader_password
restart: always
restart: unless-stopped
depends_on:
init-volume:
condition: service_completed_successfully
networks:
- network
expose:
- "4010"

hub:
build:
Expand All @@ -29,18 +32,14 @@ services:
- /var/run/docker.sock:/var/run/docker.sock:rw
- ./jupyterhub_config.py:/app/jupyterhub_config.py
- ./data-hub:/data
restart: always
restart: unless-stopped
depends_on:
- service
networks:
- network
ports:
- "8080:8080"

rabbitmq:
image: rabbitmq:latest
networks:
- network
environment:
RABBITMQ_DEFAULT_VHOST: grader
RABBITMQ_DEFAULT_USER: grader_user
Expand All @@ -54,8 +53,6 @@ services:
build:
context: ../..
dockerfile: examples/docker_compose/Dockerfile-Service
networks:
- network
command:
- "grader-worker"
- "-f"
Expand All @@ -68,7 +65,7 @@ services:
environment:
RABBITMQ_GRADER_SERVICE_USERNAME: grader_user
RABBITMQ_GRADER_SERVICE_PASSWORD: grader_password
DATABASE_TYPE: ${DATABASE_TYPE}
DATABASE_TYPE: ${DATABASE_TYPE:-sqlite}

init-volume:
build:
Expand All @@ -77,14 +74,7 @@ services:
volumes:
- ./service_dir:/local_service_dir
- service_dir:/volume_service_dir
networks:
- network


volumes:
jupyterhub-data:
service_dir:

networks:
network:
driver: bridge
13 changes: 13 additions & 0 deletions examples/docker_compose/init-db-postgres.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env bash
set -e

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

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

cp -r /app/init_repos/* /app/service_dir/git
14 changes: 12 additions & 2 deletions examples/docker_compose/init-db.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
#!/usr/bin/env bash
set -e

/venv/bin/grader-service-migrate -f /app/grader_service_config.py
echo "Initialize an sqlite database: run migrations, load initial data, and create initial repos."

psql -h postgres -U postgres -d grader -f /app/data_only.sql
grader-service-migrate -f /app/grader_service_config.py
# Insert some initial data into the database. The import will fail if the data already
# has been inserted, so we ignore errors and just continue.
# Note: For debugging, remove the stderr redirection: `2>/dev/null`.
if ! sqlite3 /app/service_dir/grader.db < /app/data_only.sql 2>/dev/null; then
echo "Initial data import failed; probably the database already exists and contains the data."
fi

cp -r /app/init_repos/* /app/service_dir/git
5 changes: 4 additions & 1 deletion examples/docker_compose/init-service-dir.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#!/bin/sh
set -e

echo "Populate docker volume"

cp -r /local_service_dir/. /volume_service_dir
cp -r /local_service_dir/. /volume_service_dir
1 change: 1 addition & 0 deletions examples/docker_compose/init_repos/lect1/1/release/HEAD
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ref: refs/heads/main
4 changes: 4 additions & 0 deletions examples/docker_compose/init_repos/lect1/1/release/config
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[core]
repositoryformatversion = 0
filemode = true
bare = true
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Unnamed repository; edit this file 'description' to name the repository.
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/sh
#
# An example hook script to check the commit log message taken by
# applypatch from an e-mail message.
#
# The hook should exit with non-zero status after issuing an
# appropriate message if it wants to stop the commit. The hook is
# allowed to edit the commit message file.
#
# To enable this hook, rename this file to "applypatch-msg".

. git-sh-setup
commitmsg="$(git rev-parse --git-path hooks/commit-msg)"
test -x "$commitmsg" && exec "$commitmsg" ${1+"$@"}
:
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/sh
#
# An example hook script to check the commit log message.
# Called by "git commit" with one argument, the name of the file
# that has the commit message. The hook should exit with non-zero
# status after issuing an appropriate message if it wants to stop the
# commit. The hook is allowed to edit the commit message file.
#
# To enable this hook, rename this file to "commit-msg".

# Uncomment the below to add a Signed-off-by line to the message.
# Doing this in a hook is a bad idea in general, but the prepare-commit-msg
# hook is more suited to it.
#
# SOB=$(git var GIT_AUTHOR_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p')
# grep -qs "^$SOB" "$1" || echo "$SOB" >> "$1"

# This example catches duplicate Signed-off-by lines.

test "" = "$(grep '^Signed-off-by: ' "$1" |
sort | uniq -c | sed -e '/^[ ]*1[ ]/d')" || {
echo >&2 Duplicate Signed-off-by lines.
exit 1
}
Loading
Loading