From 19b115434fd935f2b21b262eccb166198fcacbca Mon Sep 17 00:00:00 2001 From: app Date: Sat, 24 Sep 2022 11:51:49 +0000 Subject: [PATCH 1/4] ++init.sh --- init.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/init.sh b/init.sh index 1a2354a..f40decd 100755 --- a/init.sh +++ b/init.sh @@ -1 +1,3 @@ python manage.py migrate + +gunicorn gmba_django.wsgi:application --bind [::]:8000 From bfe6fe610a61eafe8182ed03801ff1d782e87104 Mon Sep 17 00:00:00 2001 From: app Date: Sat, 24 Sep 2022 13:45:40 +0000 Subject: [PATCH 2/4] Test: disable contents of init.sh --- init.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/init.sh b/init.sh index f40decd..17138bd 100755 --- a/init.sh +++ b/init.sh @@ -1,3 +1,4 @@ -python manage.py migrate - -gunicorn gmba_django.wsgi:application --bind [::]:8000 +#!/bin/sh +#python manage.py migrate +# +#gunicorn gmba_django.wsgi:application --bind [::]:8000 From f88a037edcbdd92acbdd315c97cc54d98de3b024 Mon Sep 17 00:00:00 2001 From: app Date: Sun, 25 Sep 2022 10:19:08 +0000 Subject: [PATCH 3/4] First working version --- Dockerfile.prod | 27 +++++++++++++++++---------- init.sh | 2 +- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/Dockerfile.prod b/Dockerfile.prod index e04db25..cda9ffd 100644 --- a/Dockerfile.prod +++ b/Dockerfile.prod @@ -35,18 +35,21 @@ RUN pip wheel --no-cache-dir --no-deps --wheel-dir /usr/src/gmba_django/wheels - FROM python:3.9.6-alpine # create directory for the app user -RUN mkdir -p /data/app +RUN mkdir -p /home/app # create the app user RUN addgroup -S app && adduser -S app -G app # create the appropriate directories -ENV HOME=/data/app -ENV APP_HOME=/data/app/app +ENV HOME=/home/app +ENV APP_HOME=/home/app/gmba_django RUN mkdir $APP_HOME RUN mkdir $APP_HOME/static RUN mkdir $APP_HOME/media -WORKDIR $APP_HOME + +#ADD gmba_django /data/app + +#WORKDIR /data/app/gmba_django # install dependencies RUN apk update && apk add libpq @@ -55,15 +58,16 @@ COPY --from=builder /usr/src/gmba_django/requirements.txt . RUN pip install --no-cache /wheels/* # copy entrypoint.prod.sh -COPY ./entrypoint.prod.sh . +COPY ./entrypoint.prod.sh /entrypoint.prod.sh COPY ./init.sh /init.sh -RUN sed -i 's/\r$//g' $APP_HOME/entrypoint.prod.sh -RUN chmod +x $APP_HOME/entrypoint.prod.sh +RUN sed -i 's/\r$//g' /entrypoint.prod.sh +RUN chmod +x /entrypoint.prod.sh # copy project -COPY . $APP_HOME - +#COPY . $APP_HOME +ADD . /home/app/gmba_django +WORKDIR /home/app/gmba_django # chown all the files to the app user RUN chown -R app:app $APP_HOME @@ -74,5 +78,8 @@ USER app RUN python manage.py collectstatic --noinput # run entrypoint.prod.sh -ENTRYPOINT ["./entrypoint.prod.sh"] +ENTRYPOINT ["/entrypoint.prod.sh"] +EXPOSE 8000 + +CMD ["gunicorn", "--bind", "[::]:8000", "--chdir", "/home/app/gmba_django", "--workers", "3", "gmba_django.wsgi:application"] diff --git a/init.sh b/init.sh index 17138bd..a483ef3 100755 --- a/init.sh +++ b/init.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/ash #python manage.py migrate # #gunicorn gmba_django.wsgi:application --bind [::]:8000 From 0574694d3841dbdbe9a6a0ae6a1c72029c6f5407 Mon Sep 17 00:00:00 2001 From: app Date: Sun, 25 Sep 2022 14:20:51 +0000 Subject: [PATCH 4/4] Revert back --- Dockerfile.prod | 2 +- init.sh | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Dockerfile.prod b/Dockerfile.prod index cda9ffd..a67b632 100644 --- a/Dockerfile.prod +++ b/Dockerfile.prod @@ -75,7 +75,7 @@ RUN chown -R app:app $APP_HOME # change to the app user USER app -RUN python manage.py collectstatic --noinput +#RUN python manage.py collectstatic --noinput # run entrypoint.prod.sh ENTRYPOINT ["/entrypoint.prod.sh"] diff --git a/init.sh b/init.sh index a483ef3..74b9cbd 100755 --- a/init.sh +++ b/init.sh @@ -1,4 +1,6 @@ #!/bin/ash #python manage.py migrate + +python manage.py collectstatic --noinput # #gunicorn gmba_django.wsgi:application --bind [::]:8000