Add postman collection for UI HTPP server
[e-mobility-charging-stations-simulator.git] / docker / Dockerfile
index f881284818f77d46030e277c614a6f5dbd23e30f..2aae47f2c2a69f0b73154601ae4e3af8ffd743a0 100644 (file)
@@ -1,25 +1,41 @@
-FROM node:alpine as builder
+FROM node:lts-alpine as builder
 
-WORKDIR /usr/builder
+RUN apk add --no-cache --virtual .gyp \
+  build-base \
+  python3
 
-COPY package.json package-lock.json ./
+# Build simulator
+WORKDIR /usr/builder
+COPY 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 npm set progress=false && npm config set depth 0 && npm cache clean --force && npm install
+RUN npm run build
 
-RUN npm set progress=false && npm config set depth 0 && npm cache clean --force
-RUN npm install
+# Build simulator dashboard
+WORKDIR /usr/builder/webui
+COPY src/ui/web ./
+RUN npm set progress=false && npm config set depth 0 && npm cache clean --force && npm install
 RUN npm run build
 
-FROM node:alpine
+RUN apk del .gyp
 
-WORKDIR /usr/app
+FROM node:lts-alpine
 
+ARG STACK_TRACE_LIMIT
+ARG MAX_OLD_SPACE_SIZE
+
+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 dist ./dist
-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 /start.sh
 RUN chmod +x /autoconfig.sh
 
-#CMD ["node", "dist/start.js"]
-CMD /autoconfig.sh && node -r source-map-support/register dist/start.js
+CMD /autoconfig.sh && /start.sh