FROM python:3.9.16-slim-buster

RUN pip3 install flask
RUN apt update
RUN apt install -y gcc
ENV FLASK_DEBUG=1

RUN mkdir /srv/cats
RUN useradd www
RUN echo "p455w0rd_v3ry_57r0n9_f0r_www-d4t4\np455w0rd_v3ry_57r0n9_f0r_www-d4t4" | passwd www
COPY vim_cats.png /srv/cats/vim_cats.png
COPY cats_gifs/* /srv/cats/
COPY index.html /srv/index.html
COPY .index.html.swp /srv/.index.html.swp
COPY server.py /srv/server.py
RUN chmod 777 /srv/* -R
COPY cat_status.c /opt/cat_status.c
RUN gcc /opt/cat_status.c -o /opt/cat_status
RUN chmod a+rx-w /opt/cat_status
RUN chmod u+s /opt/cat_status
COPY status.txt /opt/status.txt
RUN chmod 444 /opt/status.txt
COPY stage1 /stage1
COPY stage3 /you-done-this-stage3
COPY stage4 /root/stage4
WORKDIR /srv/
CMD su www -c 'export FLASK_DEBUG=1; python3 -m flask --app server run --host 0.0.0.0'
