+# build stage
+FROM node:lts-alpine as build-stage
+
+WORKDIR /app
+
+COPY package*.json ./
+RUN yarn install --frozen-lockfile
+
+COPY . .
+RUN yarn build
+
+# Multi arch build support
FROM alpine as qemu
ARG QEMU_VERSION="v4.2.0-7"
RUN wget https://github.com/multiarch/qemu-user-static/releases/download/${QEMU_VERSION}/qemu-arm-static && chmod +x qemu-arm-static
+# production stage
FROM arm32v7/alpine:3.11
COPY --from=qemu qemu-arm-static /usr/bin/
-COPY ./ /www/
ENV USER darkhttpd
ENV GROUP darkhttpd
ENV GID 911
ENV UID 911
+ENV PORT 8080
RUN addgroup -S ${GROUP} -g ${GID} && adduser -D -S -u ${UID} ${USER} ${GROUP} && \
- apk add -U darkhttpd && \
+ apk add -U --no-cache darkhttpd su-exec && \
rm /usr/bin/qemu-arm-static
-USER darkhttpd
+COPY --from=build-stage --chown=${USER}:${GROUP} /app/dist /www/
+COPY --from=build-stage --chown=${USER}:${GROUP} /app/dist/assets /www/default-assets
+COPY entrypoint.sh /entrypoint.sh
-ENTRYPOINT ["darkhttpd","/www/","--no-listing"]
+EXPOSE ${PORT}
+VOLUME /www/assets
+ENTRYPOINT ["/bin/sh", "/entrypoint.sh"]