From: Jérôme Benoit Date: Sat, 27 Aug 2022 19:41:12 +0000 (+0200) Subject: Add dashboard to the docker image build X-Git-Tag: v1.1.68~13 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=67623aa62669b072125219bb51cb46321a7342a9;p=e-mobility-charging-stations-simulator.git Add dashboard to the docker image build Signed-off-by: Jérôme Benoit --- diff --git a/build-requirements.js b/build-requirements.js index ebcd5ef0..7f36a487 100644 --- a/build-requirements.js +++ b/build-requirements.js @@ -4,12 +4,21 @@ const SemVer = require('semver'); const enginesNodeVersion = require('./package.json').engines.node; -if (SemVer.satisfies(process.version, enginesNodeVersion) === false) { - console.error( - chalk.red( - `Required node version ${enginesNodeVersion} not satisfied with current version ${process.version}.` - ) - ); - // eslint-disable-next-line no-process-exit - process.exit(1); +/** + * + */ +function checkNodeVersion() { + if (SemVer.satisfies(process.version, enginesNodeVersion) === false) { + console.error( + chalk.red( + `Required node version ${enginesNodeVersion} not satisfied with current version ${process.version}.` + ) + ); + // eslint-disable-next-line no-process-exit + process.exit(1); + } } + +checkNodeVersion(); + +module.exports = { checkNodeVersion }; diff --git a/docker/Dockerfile b/docker/Dockerfile index c5ac91aa..9843d05b 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,20 +1,25 @@ FROM node:lts-alpine as builder -WORKDIR /usr/builder - -COPY package.json package-lock.json prepare.js ./ - -RUN npm set progress=false && npm config set depth 0 && npm cache clean --force RUN apk add --no-cache --virtual .gyp \ build-base \ - python3 \ - && npm install \ - && apk del .gyp -COPY tsconfig.json rollup.config.mjs ./ + python3 + +# 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 +RUN npm set progress=false && npm config set depth 0 && npm cache clean --force && npm install +RUN npm run build + +# 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 +RUN apk del .gyp + FROM node:lts-alpine ARG STACK_TRACE_LIMIT @@ -24,11 +29,13 @@ WORKDIR /usr/app ENV NODE_OPTIONS="--stack-trace-limit=${STACK_TRACE_LIMIT} --max-old-space-size=${MAX_OLD_SPACE_SIZE}" +COPY --from=builder /usr/builder/webui ./webui COPY --from=builder /usr/builder/node_modules ./node_modules 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.cjs"] -CMD /autoconfig.sh && node -r source-map-support/register dist/start.cjs +CMD /autoconfig.sh && /start.sh diff --git a/docker/autoconfig.sh b/docker/autoconfig.sh old mode 100644 new mode 100755 diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index 1f21f639..c9065cda 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -12,3 +12,5 @@ services: MAX_OLD_SPACE_SIZE: 1024 networks: - ev_network + ports: + - "3030:3030" diff --git a/docker/start.sh b/docker/start.sh new file mode 100755 index 00000000..caf30846 --- /dev/null +++ b/docker/start.sh @@ -0,0 +1,4 @@ +#!/usr/bin/env sh + +node -r source-map-support/register dist/start.cjs & +node webui/start.js