diff --git a/deposit.env b/deposit.env new file mode 100644 --- /dev/null +++ b/deposit.env @@ -0,0 +1,3 @@ +POSTGRES_DB=softwareheritage-deposit +POSTGRES_PASSWORD=testpassword +PGUSER=postgres diff --git a/docker-compose.yml b/docker-compose.yml --- a/docker-compose.yml +++ b/docker-compose.yml @@ -114,6 +114,22 @@ - swh-storage - swh-idx-storage + swh-deposit-db: + image: postgres:10 + env_file: ./deposit.env + + swh-deposit: + build: ./dockerfiles/swh-deposit + image: swh/deposit + ports: + - 5006:5006 + depends_on: + - swh-deposit-db + - swh-scheduler-api + env_file: ./deposit.env + environment: + PGHOST: swh-deposit-db + # Lister Celery workers swh-listers-db: diff --git a/dockerfiles/swh-deposit/Dockerfile b/dockerfiles/swh-deposit/Dockerfile new file mode 100644 --- /dev/null +++ b/dockerfiles/swh-deposit/Dockerfile @@ -0,0 +1,16 @@ +FROM python:3 + +RUN export DEBIAN_FRONTEND=noninteractive && \ + apt-get update && apt-get upgrade -y && \ + apt-get install -y libsystemd-dev postgresql-client && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* + +RUN pip install swh-deposit gunicorn +RUN pip install psycopg2-binary # to make pip silent +COPY server.yml /etc/softwareheritage/deposit/ +COPY private.yml /etc/softwareheritage/deposit/ + +COPY entrypoint.sh / +EXPOSE 5006 +ENTRYPOINT ["/entrypoint.sh"] diff --git a/dockerfiles/swh-deposit/entrypoint.sh b/dockerfiles/swh-deposit/entrypoint.sh new file mode 100755 --- /dev/null +++ b/dockerfiles/swh-deposit/entrypoint.sh @@ -0,0 +1,40 @@ +#!/bin/bash + +set -ex + +if [[ -d /src ]] ; then + pwd + for src_repo in /src/swh-* ; do + pushd $src_repo + echo "Installing ${src_repo}" + pip install -e . + popd + done +fi + +echo "${PGHOST}:5432:${POSTGRES_DB}:${PGUSER}:${POSTGRES_PASSWORD}" > ~/.pgpass +cat > ~/.pg_service.conf < /dev/null 2> /dev/null; do sleep 0.1; done + + echo "Migrating db" + django-admin migrate --settings=swh.deposit.settings.production + + echo "starting swh-deposit server" + exec gunicorn --bind 0.0.0.0:5006 \ + --reload \ + --log-level DEBUG \ + swh.deposit.wsgi +fi diff --git a/dockerfiles/swh-deposit/loader.yml b/dockerfiles/swh-deposit/loader.yml new file mode 100644 --- /dev/null +++ b/dockerfiles/swh-deposit/loader.yml @@ -0,0 +1 @@ +extraction_dir: /tmp/deposit/loader/ diff --git a/dockerfiles/swh-deposit/private.yml b/dockerfiles/swh-deposit/private.yml new file mode 100644 --- /dev/null +++ b/dockerfiles/swh-deposit/private.yml @@ -0,0 +1,8 @@ +secret_key: prod-in-docker +db: + host: swh-deposit-db + port: 5432 + name: softwareheritage-deposit + user: postgres + password: testpassword +media_root: /tmp/swh-deposit/uploads diff --git a/dockerfiles/swh-deposit/server.yml b/dockerfiles/swh-deposit/server.yml new file mode 100644 --- /dev/null +++ b/dockerfiles/swh-deposit/server.yml @@ -0,0 +1,13 @@ +scheduler: + cls: remote + args: + url: http://swh-scheduler:5008 + +allowed_hosts: + - "*" + +tool: + name: 'swh-deposit' + version: '0.0.1' + configuration: + sword_version: 2 diff --git a/dockerfiles/swh-web/entrypoint.sh b/dockerfiles/swh-web/entrypoint.sh --- a/dockerfiles/swh-web/entrypoint.sh +++ b/dockerfiles/swh-web/entrypoint.sh @@ -4,6 +4,7 @@ if [[ -d /src ]] ; then for srcrepo in /src/swh-* ; do + pushd $srcrepo echo installing $srcrepo pip install -e . popd