FROM debian:latest
MAINTAINER madmaurice <madmaurice@zom.bi>, paul <paul@zom.bi>
EXPOSE 8080 443

ENV MYSQL_DB cytube
ENV MYSQL_HOST localhost
ENV MYSQL_USER root
ENV MYSQL_PASSWORD toor
ENV MYSQL_PORT 3306
ENV BASE_URL localhost
ENV COOKIE_SECRET Change_me
ENV YOUTUBE_API_KEY ""

RUN apt-get update &&\
    apt-get install --no-install-recommends -y \
       netcat \
       npm \
       nodejs \
       mariadb-client \
       ffmpeg \
       git \
       python \
       build-essential \
       wget \
       gettext \
       &&\
    apt-get clean -y &&\
    rm -rf /var/lib/apt/lists/*
RUN npm install -g n &&\
    n stable
# Babel version 7.7.4 is not compatible anymore.
# Therefore we alter the dependencies to refer to 7.4.* instead of 7.*
# Might not be required anymore in the future (01.12.2019)
    # sed -i -e '/babel/ s/\^/~/' package.json &&\
RUN git clone --branch "3.0" --single-branch --depth 1 http://github.com/calzoneman/sync /sync &&\
    cd sync &&\
    npm install &&\
    npm run build-server &&\
    npm run postinstall

COPY config.template.yaml /
COPY bootstrap.sh /

RUN chmod +x /bootstrap.sh

CMD ["/bootstrap.sh"]