FROM python:3.7.2-stretch

RUN apt-get update && \
    apt-get install -yqq \
    openssh-client git build-essential nginx

COPY ./ssh_private_key /root/.ssh/id_rsa
RUN chmod 600 /root/.ssh/id_rsa
RUN ssh-keyscan github.com >> /root/.ssh/known_hosts

WORKDIR /var/www

COPY ./requirements.txt .
RUN pip install -r requirements.txt

COPY . .
RUN pip install -e .
RUN shred -u ./ssh_private_key /root/.ssh/id_rsa

ARG BEBO_ENV=local
ENV BEBO_ENV=$BEBO_ENV
ARG BEBO_VERSION=master
ENV BEBO_VERSION=$BEBO_VERSION

RUN rm /etc/nginx/sites-enabled/default
COPY etc/${BEBO_ENV}/* /etc/nginx/conf.d

EXPOSE 8000

CMD ["./start.sh"]
