FROM alpine:3.12

ENV CYCLOSUI_RELEASE=2.0.0

RUN apk add wget npm
# COPY ./patches/*.patch /tmp
RUN mkdir -p /opt/apps/cyclos-ui && \
    cd /opt/apps/cyclos-ui && \
    wget "https://github.com/cyclosproject/cyclos4-ui/archive/${CYCLOSUI_RELEASE}.tar.gz" && \
    tar -xzf "${CYCLOSUI_RELEASE}.tar.gz" && \
    rm "${CYCLOSUI_RELEASE}.tar.gz" && \
    mv cyclos4-ui-"${CYCLOSUI_RELEASE}"/* cyclos4-ui-"${CYCLOSUI_RELEASE}"/.[a-z]* . && \
    rmdir cyclos4-ui-"${CYCLOSUI_RELEASE}" && \
    # cat /tmp/*.patch | patch -p1 && \
    # mkdir -p /etc/cyclos-ui /var/lib/cyclos-ui && \
    # ln -sf /var/lib/cyclos-ui /opt/apps/cyclos-ui/storage
    true

RUN cd /opt/apps/cyclos-ui && \
    npm install

RUN cd /opt/apps/cyclos-ui && \
    npm run generate

WORKDIR /opt/apps/cyclos-ui