From 977189c2631c55cceed0e3905ee05b53ea20c3e4 Mon Sep 17 00:00:00 2001 From: Jan Dittberner Date: Fri, 5 Jul 2019 21:23:24 +0200 Subject: [PATCH] Update and improve docker image This commit updates the docker image to be based on Debian 10 Buster. The startup script waits until the database container becomes available. Needed dependencies for building the PostgreSQL driver were added to the docker image. --- Dockerfile | 9 ++++++--- gnuviechadmin.sh | 13 +++++++++++++ 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index e268ca1..7846bf3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,12 +1,14 @@ -FROM debian:stretch -LABEL maintainer "Jan Dittberner " +FROM debian:buster +LABEL maintainer="Jan Dittberner " RUN apt-get update \ && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ + build-essential \ dumb-init \ gettext \ git \ libpq-dev \ + postgresql-client \ python3-dev \ python3-pip \ && apt-get clean \ @@ -20,11 +22,12 @@ ENV LANG=C.UTF-8 RUN python3 -m pip install -U pip && pip3 install pipenv -COPY gnuviechadmin.sh /srv/ COPY Pipfile Pipfile.lock /srv/gnuviechadmin/ RUN pipenv install --system --deploy --ignore-pipfile --dev +COPY gnuviechadmin.sh /srv/ + EXPOSE 8000 VOLUME /srv/gnuviechadmin diff --git a/gnuviechadmin.sh b/gnuviechadmin.sh index f5d74c2..7ea96c1 100755 --- a/gnuviechadmin.sh +++ b/gnuviechadmin.sh @@ -2,6 +2,19 @@ set -e +DB_HOST="${GVA_PGSQL_HOST:-db}" +DB_PORT="${GVA_PGSQL_PORT:-5432}" +DB_USER="${GVA_PGSQL_USER:-gnuviechadmin}" +DB_NAME="${GVA_PGSQL_DATABASE:-gnuviechadmin}" + +until pg_isready -q -h "${DB_HOST}" -p "${DB_PORT}" -U "${PG_USER}" -d "${DB_NAME}" +do + echo -n "." + sleep 1 +done + +echo "db is ready" + python3 manage.py compilemessages python3 manage.py collectstatic --noinput python3 manage.py migrate --noinput