FROM alpine:3.11.6

ENV PIP_INDEX_URL="https://nexus.bthlabs.pl/repository/pypi/simple/"
ENV YARN_REGISTRY="https://nexus.bthlabs.pl/repository/npm/"

ENV NODE_ENV=production
ENV NODE_PATH=/homehub_var/node_modules
ENV YARN_MODULES_FOLDER=/homehub_var/node_modules

RUN apk add build-base python3 python3-dev nodejs npm yarn

RUN mkdir /homehub_var /homehub_var/node_modules /homehub_var/virtualenv
RUN python3 -m venv /homehub_var/virtualenv
RUN /homehub_var/virtualenv/bin/pip install gunicorn==20.0.4 cookiecutter==1.7.2

COPY docker-entrypoint.sh /
COPY ops/cookiecutters/homehub-workspace/ /homehub-workspace/

RUN mkdir /homehub_workspace

WORKDIR /homehub_workspace

ENTRYPOINT ["/docker-entrypoint.sh"]

ENV PYTHONPATH="/homehub_workspace"

EXPOSE 3010
VOLUME ["/homehub_var", "/homehub_workspace"]

CMD ["/homehub_var/virtualenv/bin/gunicorn", "-c", "/homehub_workspace/gunicorn.conf.py", "homehub_backend.app:app"]
