backend/Dockerfile
2022-10-31 11:55:04 +01:00

40 lines
987 B
Docker

FROM python:3.10.0-bullseye AS builder
# create user and group
RUN mkdir -p /home/app
RUN adduser app && adduser app app
WORKDIR /home/app
# install dependencies
RUN apt-get update && apt-get upgrade -y && \
apt-get install -y postgresql gcc python3-dev \
libgl1
#musl-dev libxml2-dev libxslt-dev
COPY ./requirements.txt .
RUN python3 -m pip install --upgrade pip && \
pip3 install -r requirements.txt && \
pip3 install psycopg2==2.9.4 && \
pip3 install gunicorn==20.1.0
COPY . .
RUN chown -R app:app /home/app
FROM builder AS backend
USER app
# run gunicorn
CMD ["gunicorn", "config.wsgi:application", "--bind", "0.0.0.0:8000"]
FROM builder AS worker
# install worker dependencies
RUN apt-get install -y texlive-xetex
# run celery worker
USER app
CMD ["celery", "-A", "config", "worker", "-l", "info"]
FROM builder AS websocket
# run daphne server
USER app
CMD ["daphne", "-b", "0.0.0.0", "-p", "8001", "config.asgi:application"]