FROM node:13.7.0-buster

RUN npm install npx \
   && apt update \
   && apt -y install redis

WORKDIR /main

COPY opentogethertube /main/opentogethertube

WORKDIR /main/opentogethertube
RUN true \
   && npm install \
   && npx sequelize-cli db:migrate

COPY development.env /main/opentogethertube/env/
RUN true \
   && for env in $(cat /main/opentogethertube/env/development.env); do eval "export $env"; done \
   && echo doing env \
   && env | grep API \
   && echo /doing env \
   && npm run build

CMD []
ENTRYPOINT ["bash", "-c", "true; set -e; redis-server /etc/redis/redis.conf; npm start"]
