FROM python:3-slim

# set a directory for the app
RUN groupadd app && useradd -m -g app app



# install dependencies
WORKDIR /srv
RUN pip3 install setuptools gunicorn
COPY login-mecanics/requirements.txt /srv/webinterface/requirements.txt
RUN pip3 install --no-cache-dir -r webinterface/requirements.txt


# copy all the files to the container
COPY app.py /srv
COPY login-mecanics /srv/webinterface
COPY static /srv/static
COPY templates/layout.html /srv/webinterface/templates
COPY models/__init__.py models/system.py models/gtfs_work.py models/gtfs_static.py /srv/webinterface/models
RUN chown -R app:app /srv


USER app
# define the port number the container should expose
EXPOSE 8000

# run the command
ENTRYPOINT ["gunicorn"]
CMD ["-b", "0.0.0.0:8000", "app:iapp"]
