fix(simulator): detect string emptiness properly without helper usage
[e-mobility-charging-stations-simulator.git] / docker / Dockerfile
index 6b5e897f470d5b4be9bbf95e13622a625ae7a871..080c56d025f41495e373f2555c08458ae7244cd3 100644 (file)
@@ -1,23 +1,46 @@
-FROM node:alpine as builder
+FROM node:lts-alpine as builder
 
+# Build simulator
 WORKDIR /usr/builder
+COPY .npmrc package.json package-lock.json tsconfig.json rollup.config.mjs prepare.js build-requirements.js ./
+COPY src ./src
+COPY docker/config.json ./src/assets/config.json
+COPY docker/authorization-tags.json ./src/assets/authorization-tags.json
+RUN set -ex \
+  && apk add --no-cache --virtual .gyp build-base python3 \
+  && npm set progress=false \
+  && npm config set depth 0 \
+  && npm cache clean --force \
+  && npm clean-install \
+  && npm run build \
+  && apk del .gyp
 
-COPY package.json package-lock.json ./
+# Build simulator dashboard
+WORKDIR /usr/builder/webui
+COPY ui/web ./
+RUN set -ex \
+  && npm set progress=false \
+  && npm config set depth 0 \
+  && npm cache clean --force \
+  && npm clean-install \
+  && npm run build
 
-RUN npm set progress=false && npm config set depth 0 && npm cache clean --force
-RUN npm install
+FROM node:lts-alpine
 
-FROM node:alpine
+ARG STACK_TRACE_LIMIT=1024
+ARG MAX_OLD_SPACE_SIZE=768
 
-WORKDIR /usr/app
+ENV NODE_OPTIONS="--stack-trace-limit=${STACK_TRACE_LIMIT} --max-old-space-size=${MAX_OLD_SPACE_SIZE}"
 
+WORKDIR /usr/app
+COPY --from=builder /usr/builder/webui ./webui
 COPY --from=builder /usr/builder/node_modules ./node_modules
-COPY NOTICE LICENSE ./
-COPY src ./src
-COPY *.json ./
-COPY docker/config.json ./src/assets/config.json
+COPY --from=builder /usr/builder/dist ./dist
+COPY README.md LICENSE ./
+COPY docker/start.sh /start.sh
 COPY docker/autoconfig.sh /autoconfig.sh
-RUN chmod +x /autoconfig.sh
+RUN set -ex \
+  && chmod +x /start.sh \
+  && chmod +x /autoconfig.sh
 
-#CMD ["node", "src/start.js"]
-CMD /autoconfig.sh && node src/start.js
+CMD /autoconfig.sh && /start.sh