FROM debian:bullseye-20200327

RUN apt update \
    && apt install -y \
        lsb-release \
        wget \
        apt-transport-https \
    && wget \
        -O /usr/share/keyrings/matrix-org-archive-keyring.gpg \
        https://packages.matrix.org/debian/matrix-org-archive-keyring.gpg \
    && echo \
        "deb [signed-by=/usr/share/keyrings/matrix-org-archive-keyring.gpg] https://packages.matrix.org/debian/ $(lsb_release -cs) main" \
        | tee /etc/apt/sources.list.d/matrix-org.list \
    && apt update \
    && apt install -y \
        matrix-synapse-py3

RUN apt install -y vim bash curl procps

RUN mkdir -p /var/www/riot.dangerousdemos.net \
    && cd /var/www/riot.dangerousdemos.net \
    && v=1.6.1 \
    && wget https://github.com/vector-im/riot-web/releases/download/v$v/riot-v$v.tar.gz \
    && tar -xzvf riot-v$v.tar.gz \
    && ln -s riot-v$v riot \
    && cd riot \
    && cp config.sample.json config.json

RUN apt update && apt install -y gnupg2 \
    && echo 'deb https://download.jitsi.org stable/' >> /etc/apt/sources.list.d/jitsi-stable.list \
    && wget -qO -  https://download.jitsi.org/jitsi-key.gpg.key | apt-key add - \
    && apt update  \
    && printf "jitsim.home.blapointe.com\n2\n\n" > /tmp/input \
    && apt -y install jitsi-meet < /tmp/input

RUN mkdir -p /mnt

COPY homeserver.yaml /etc/matrix-synapse/
COPY config.json /etc/riot/
COPY config.json /var/www/riot.dangerousdemos.net/riot/
COPY jitsim.home.blapointe.com.conf /etc/nginx/sites-enabled/

WORKDIR /main

COPY . .

CMD []
ENTRYPOINT ["bash", "./entrypoint.sh", "start"]
