FROM node:alpine

USER root

ENV WORKING_DIR /app/AutoTest-Platform
# Provides cached layer for node_modules
COPY frontend ${WORKING_DIR}/frontend

RUN sh -c "echo 'Asia/Shanghai' > /etc/timezone" \
    && cd ${WORKING_DIR}/frontend \
    && npm install -g cnpm --registry=https://registry.npm.taobao.org \
    && cnpm install phantomjs-prebuilt@2.1.16 --ignore-scripts \
    && cnpm rebuild node-sass \
    && cnpm install

ENTRYPOINT cd ${WORKING_DIR}/frontend; npm run build