From 456402c5e5baa9f8a3e55674f427173286226463 Mon Sep 17 00:00:00 2001 From: TDLaouer Date: Sun, 13 Jul 2025 18:57:25 +0200 Subject: [PATCH] add entrypoint --- Dockerfile | 8 +++++++- entrypoint.sh | 16 ++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 entrypoint.sh diff --git a/Dockerfile b/Dockerfile index 22393a5..1d2aad5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,4 +9,10 @@ RUN pip install --upgrade pip COPY ./requirements.txt . RUN pip install -r requirements.txt -COPY . . \ No newline at end of file +COPY ./entrypoint.sh . +RUN sed -i 's/\r$//g' /usr/src/app/entrypoint.sh +RUN chmod +x /usr/src/app/entrypoint.sh + +COPY . . + +ENTRYPOINT ["/usr/src/app/entrypoint.sh"] \ No newline at end of file diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100644 index 0000000..b097c1b --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,16 @@ + +if [ "$DATABASE" = "postgres" ] +then + echo "Waiting for postgres..." + + while ! nc -z $SQL_HOST $SQL_PORT; do + sleep 0.1 + done + + echo "PostgreSQL started" +fi + +python manage.py flush --no-input +python manage.py migrate + +exec "$@" \ No newline at end of file