Changeset View
Changeset View
Standalone View
Standalone View
dockerfiles/swh-storage/entrypoint.sh
#!/bin/bash | #!/bin/bash | ||||
set -e | set -e | ||||
if [[ -d /src ]] ; then | if [[ -d /src ]] ; then | ||||
for srcrepo in /src/swh-* ; do | for srcrepo in /src/swh-* ; do | ||||
pushd $srcrepo | pushd $srcrepo | ||||
pip install -e . | pip install -e . | ||||
popd | popd | ||||
done | done | ||||
fi | fi | ||||
echo "${PGHOST}:5432:${POSTGRES_DB}:${PGUSER}:${POSTGRES_PASSWORD}" > ~/.pgpass | echo "${PGHOST}:5432:${POSTGRES_DB}:${PGUSER}:${POSTGRES_PASSWORD}" > ~/.pgpass | ||||
cat > ~/.pg_service.conf <<EOF | cat > ~/.pg_service.conf <<EOF | ||||
[swh] | [swh] | ||||
dbname=${POSTGRES_DB} | dbname=${POSTGRES_DB} | ||||
host=${PGHOST} | host=${PGHOST} | ||||
port=5432 | port=5432 | ||||
user=${PGUSER} | user=${PGUSER} | ||||
EOF | EOF | ||||
chmod 0600 ~/.pgpass | chmod 0600 ~/.pgpass | ||||
case "$1" in | case "$1" in | ||||
"shell") | "shell") | ||||
exec bash -i | exec bash -i | ||||
;; | ;; | ||||
*) | *) | ||||
echo Waiting for postgresql to start | echo Waiting for postgresql to start | ||||
until psql service=swh -c "select 1" > /dev/null 2> /dev/null; do sleep 0.1; done | until psql service=swh -c "select 1" > /dev/null 2> /dev/null; do sleep 0.1; done | ||||
echo Setup the database | echo Setup the database | ||||
PGPASSWORD=${POSTGRES_PASSWORD} swh-db-init storage \ | PGPASSWORD=${POSTGRES_PASSWORD} swh-db-init storage \ | ||||
--db-name ${POSTGRES_DB} | --db-name ${POSTGRES_DB} | ||||
echo Starting the swh-storage API server | echo Starting the swh-storage API server | ||||
exec python -m swh.storage.api.server /storage.yml | exec python -m swh.storage.api.server /storage.yml | ||||
;; | ;; | ||||
esac | esac |