diff --git a/docker-compose.yml b/docker-compose.yml index 015a314..feba92a 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,35 +1,66 @@ version: '2' services: + +# Graph storage + swh-storage-db: image: postgres:10 environment: POSTGRES_PASSWORD: testpassword POSTGRES_DB: swh-storage + swh-storage: build: ./dockerfiles/swh-storage image: swh/storage ports: - 5002:5002 depends_on: - swh-storage-db - swh-objstorage environment: POSTGRES_PASSWORD: testpassword POSTGRES_DB: swh-storage PGHOST: swh-storage-db PGUSER: postgres + +# Object storage + swh-objstorage: build: ./dockerfiles/swh-objstorage image: swh/objstorage ports: - 5003:5003 +# Indexer storage + + swh-idx-storage-db: + image: postgres:10 + environment: + POSTGRES_PASSWORD: testpassword + POSTGRES_DB: swh-idx-storage + + swh-idx-storage: + build: ./dockerfiles/swh-indexer-storage + image: swh/indexer-storage + ports: + - 5007:5007 + depends_on: + - swh-idx-storage-db + environment: + POSTGRES_PASSWORD: testpassword + POSTGRES_DB: swh-idx-storage + PGHOST: swh-idx-storage-db + PGUSER: postgres + +# Web interface + swh-web: build: ./dockerfiles/swh-web image: swh/web ports: - 5004:5004 depends_on: - swh-objstorage - swh-storage + - swh-idx-storage diff --git a/dockerfiles/swh-indexer-storage/Dockerfile b/dockerfiles/swh-indexer-storage/Dockerfile new file mode 100644 index 0000000..df54a38 --- /dev/null +++ b/dockerfiles/swh-indexer-storage/Dockerfile @@ -0,0 +1,14 @@ +FROM python:3 + +RUN export DEBIAN_FRONTEND=noninteractive && \ + apt-get update && \ + apt-get install -y \ + libsystemd-dev postgresql-client + +RUN pip install swh-indexer +COPY indexer_storage.yml / +COPY entrypoint.sh / + +ENTRYPOINT ["/entrypoint.sh"] + +EXPOSE 5002 diff --git a/dockerfiles/swh-indexer-storage/entrypoint.sh b/dockerfiles/swh-indexer-storage/entrypoint.sh new file mode 100755 index 0000000..b2eef7b --- /dev/null +++ b/dockerfiles/swh-indexer-storage/entrypoint.sh @@ -0,0 +1,40 @@ +#!/bin/bash + +set -e + +if [[ -d /src ]] ; then + for srcrepo in /src/swh-* ; do + pushd $srcrepo + pip install -e . + popd + done +fi + +echo "${PGHOST}:5432:${POSTGRES_DB}:${PGUSER}:${POSTGRES_PASSWORD}" > ~/.pgpass +cat > ~/.pg_service.conf <&1 > /dev/null; do sleep 0.1; done + + echo Setup the database + PGPASSWORD=${POSTGRES_PASSWORD} swh-db-init indexer \ + --db-name ${POSTGRES_DB} + + echo Starting the swh-indexer-storage API server + exec python -m swh.indexer.storage.api.server /indexer_storage.yml + ;; +esac diff --git a/dockerfiles/swh-indexer-storage/indexer_storage.yml b/dockerfiles/swh-indexer-storage/indexer_storage.yml new file mode 100644 index 0000000..d2f5276 --- /dev/null +++ b/dockerfiles/swh-indexer-storage/indexer_storage.yml @@ -0,0 +1,4 @@ +storage: + cls: local + args: + db: service=swh-indexer diff --git a/dockerfiles/swh-web/web.yml b/dockerfiles/swh-web/web.yml index 79712c3..581e8fe 100644 --- a/dockerfiles/swh-web/web.yml +++ b/dockerfiles/swh-web/web.yml @@ -1,19 +1,20 @@ storage: cls: remote args: url: http://swh-storage:5002/ timeout: 1 objstorage: cls: remote args: url: http://swh-objstorage:5003/ indexer_storage: - cls: memory - args: {} + cls: remote + args: + url: http://swh-idx-storage:5007/ allowed_hosts: - "*" debug: yes