FROM python:3.8-slim-buster
WORKDIR /app
COPY requirements.txt requirements.txt
RUN pip3 install -r requirements.txt
COPY . .

ARG user=appuser
ARG group=appuser
ARG uid=1000
ARG gid=1000
RUN groupadd -g ${gid} ${group}
RUN useradd -u ${uid} -g ${group} -s /bin/sh -m ${user}

RUN chown -R ${user} .
RUN chmod 777 templates
RUN chmod 444 templates/*
RUN chmod 444 flag.txt

# Switch to user
USER ${uid}:${gid}

CMD [ "python3", "-m" , "flask", "run", "--host=0.0.0.0"]
