From 89efc4f9543cc1bc5442404ad6f97a03f46007c8 Mon Sep 17 00:00:00 2001 From: andrewkassab Date: Fri, 13 Sep 2024 19:24:26 -0700 Subject: [PATCH] added run script and updated dockerfile --- Dockerfile | 12 ++++++++---- requirements.txt | 3 ++- scripts/run.sh | 9 +++++++++ 3 files changed, 19 insertions(+), 5 deletions(-) create mode 100644 scripts/run.sh diff --git a/Dockerfile b/Dockerfile index 7abb675..f3537bd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,6 +5,7 @@ ENV PYTHONUNBUFFERED 1 COPY ./requirements.txt /tmp/requirements.txt COPY ./requirements.dev.txt /tmp/requirements.dev.txt +COPY ./scripts /scripts COPY ./app /app WORKDIR /app EXPOSE 8000 @@ -14,7 +15,7 @@ RUN python -m venv /py && \ /py/bin/pip install --upgrade pip && \ apk add --update --no-cache postgresql-client jpeg-dev && \ apk add --update --no-cache --virtual .tmp-build-deps \ - build-base postgresql-dev musl-dev zlib zlib-dev && \ + build-base postgresql-dev musl-dev zlib zlib-dev linux-headers && \ /py/bin/pip install -r /tmp/requirements.txt && \ if [ $DEV = "true" ]; \ then /py/bin/pip install -r /tmp/requirements.dev.txt ; \ @@ -28,8 +29,11 @@ RUN python -m venv /py && \ mkdir -p /vol/web/media && \ mkdir -p /vol/web/static && \ chown -R django-user:django-user /vol && \ - chmod -R 755 /vol + chmod -R 755 /vol && \ + chmod -R +x /scripts -ENV PATH="/py/bin:$PATH" +ENV PATH="/scripts:py/bin:$PATH" -USER django-user \ No newline at end of file +USER django-user + +CMD ["run.sh"] diff --git a/requirements.txt b/requirements.txt index 35aade3..f0b4b5e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,4 +2,5 @@ Django>=3.2.4,<3.3 djangorestframework>=3.12.4,<3.13 psycopg2>=2.8.6,<2.11 drf-spectacular>=0.15.1,<0.16 -Pillow>=8.2.0,<8.3.0 \ No newline at end of file +Pillow>=8.2.0,<8.3.0 +uwsgi>=2.0.19,<2.1 diff --git a/scripts/run.sh b/scripts/run.sh new file mode 100644 index 0000000..9fac716 --- /dev/null +++ b/scripts/run.sh @@ -0,0 +1,9 @@ +#!/bin/sh + +set -e + +python manage.py wait_for_db +python manage.py collectstatic --noinput +python manage.py migrate + +uwsgi --socket :9000 --workers 4 --master --enable-threads --module app.wsgi