FROM python:3.9

RUN useradd -m -g nogroup server
USER server

WORKDIR /home/server
ENV FLASK_APP=main.py

# Perform the install of requirements first to avoid re-installing on every code change
COPY requirements.txt /home/server/
RUN pip install -r /home/server/requirements.txt

COPY *.py /home/server/

# CMD ["python", "/home/server/main.py"]

CMD ["/home/server/.local/bin/gunicorn", "--config", "/home/server/gunicorn.conf.py", "main:app"]