diff --git a/docker/docker-compose.prod.yml b/docker/docker-compose.prod.yml index 66cfdc5..1c1ea30 100644 --- a/docker/docker-compose.prod.yml +++ b/docker/docker-compose.prod.yml @@ -3,13 +3,14 @@ version: "2" services: app: image: pathogen/neptune - build: ./docker + build: ./docker/prod volumes: - ${PORTAINER_GIT_DIR}:/code + - ${PORTAINER_GIT_DIR}/docker/prod/uwsgi.ini:/conf/uwsgi.ini - ${NEPTUNE_LOCAL_SETTINGS}:/code/app/local_settings.py - ${NEPTUNE_DATABASE_FILE}:/code/db.sqlite3 ports: - - "${NEPTUNE_PORT}:8000" + - "${NEPTUNE_PORT}:8000" # uwsgi socket env_file: - ../stack.env diff --git a/docker/prod/Dockerfile b/docker/prod/Dockerfile new file mode 100644 index 0000000..c8386d1 --- /dev/null +++ b/docker/prod/Dockerfile @@ -0,0 +1,21 @@ +# syntax=docker/dockerfile:1 +FROM python:3 + +RUN useradd -d /code pathogen +RUN mkdir /code +RUN chown pathogen:pathogen /code + +RUN mkdir /conf +RUN chown pathogen:pathogen /conf + +RUN mkdir /venv +RUN chown pathogen:pathogen /venv + +USER pathogen +ENV PYTHONDONTWRITEBYTECODE=1 +ENV PYTHONUNBUFFERED=1 +WORKDIR /code +COPY requirements.prod.txt /code/ +RUN python -m venv /venv +RUN . /venv/bin/activate && pip install -r requirements.prod.txt +CMD . /venv/bin/activate && uwsgi --ini /conf/uwsgi.ini \ No newline at end of file diff --git a/docker/requirements.prod.txt b/docker/prod/requirements.prod.txt similarity index 94% rename from docker/requirements.prod.txt rename to docker/prod/requirements.prod.txt index 9ea9856..e48344f 100644 --- a/docker/requirements.prod.txt +++ b/docker/prod/requirements.prod.txt @@ -6,3 +6,4 @@ opensearch-py stripe django-rest-framework numpy +uwsgi diff --git a/docker/prod/uwsgi.ini b/docker/prod/uwsgi.ini new file mode 100644 index 0000000..d70a784 --- /dev/null +++ b/docker/prod/uwsgi.ini @@ -0,0 +1,13 @@ +[uwsgi] +chdir=/code +module=app.wsgi:application +env=DJANGO_SETTINGS_MODULE=app.settings +master=1 +pidfile=/tmp/project-master.pid +socket=0.0.0.0:8000 +processes=5 +harakiri=20 +max-requests=5000 +vacuum=1 +home=/venv +