env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
- build-docker-image:
+ build-simulator-docker-image:
runs-on: ubuntu-latest
- name: Build docker image
+ name: Build simulator docker image
+ steps:
+ - uses: actions/checkout@v4
+ - name: Setup Docker Buildx
+ id: buildx
+ uses: docker/setup-buildx-action@v3
+ - name: Build docker image
+ run: |
+ cd docker
+ make SUBMODULES_INIT=false
+ build-dashboard-docker-image:
+ runs-on: ubuntu-latest
+ defaults:
+ run:
+ working-directory: ui/web
+ name: Build dashboard docker image
steps:
- uses: actions/checkout@v4
- name: Setup Docker Buildx
FROM node:lts-alpine AS builder
-# Build simulator and dashboard
+# Build simulator
WORKDIR /usr/builder
COPY . ./
RUN set -ex \
&& cp docker/config.json src/assets/config.json \
&& cp docker/idtags.json src/assets/idtags.json \
&& pnpm build \
- && apk del .gyp \
- && cd ui/web \
- && cp src/assets/config-template.json public/config.json \
- && pnpm build
+ && apk del .gyp
FROM node:lts-alpine
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/ui/web ./ui/web
COPY --from=builder /usr/builder/node_modules ./node_modules
COPY --from=builder /usr/builder/dist ./dist
COPY package.json README.md LICENSE ./
cp $emobility_install_dir/dist/assets/configs-docker/$emobility_server_type-$emobility_service_type-$emobility_landscape.json $emobility_install_dir/dist/assets/config.json
cp $emobility_install_dir/dist/assets/configs-docker/$emobility_server_type-$emobility_service_type-$emobility_landscape-idtags.json $emobility_install_dir/dist/assets/idtags.json
- cp $emobility_install_dir/dist/assets/configs-docker/$emobility_server_type-$emobility_service_type-$emobility_landscape-webui.json $emobility_install_dir/ui/web/public/config.json
else
echo "no emobility env defined, start with default configuration"
fi
},
"uiServer": {
"enabled": true,
+ "options": {
+ "host": "::"
+ },
"type": "ws",
"authentication": {
"enabled": true,
-version: '3.7'
networks:
ev_network:
driver: bridge
MAX_OLD_SPACE_SIZE: 768
networks:
- ev_network
- expose:
- - 8080
ports:
- - '3030:3030'
+ - 8080:8080
#!/usr/bin/env sh
-node dist/start.js &
-node ui/web/start.js
+node dist/start.js
- [Run](#run)
- [Compiles and run for production](#compiles-and-run-for-production)
- [Preview locally](#preview-locally)
+ - [Docker](#docker)
- [Development](#development)
- [Compiles and run for development](#compiles-and-run-for-development)
- [Formats files](#formats-files)
1. With the buttons on the top you can change UI server, start/stop the simulator, add new charging stations and refresh the content.
2. Each charging station is a row in the table with specific 'Actions' to execute on. Try 'Stop Charging Station' and refresh with the large blue button and see the status 'Started' turns from 'Yes' into 'No'.
+#### Docker
+
+In the [docker](./docker) folder:
+
+```shell
+make
+```
+
### Development
#### Compiles and run for development
--- /dev/null
+FROM node:lts-alpine AS builder
+
+# Build dashboard
+WORKDIR /usr/builder
+COPY . ./
+RUN set -ex \
+ && corepack enable \
+ && corepack prepare pnpm@latest --activate \
+ && pnpm set progress=false \
+ && pnpm config set depth 0 \
+ && pnpm install --ignore-scripts \
+ && cp docker/config.json public/config.json \
+ && pnpm build
+
+FROM node:lts-alpine
+
+WORKDIR /usr/app
+COPY --from=builder /usr/builder ./
+COPY docker/start.sh /start.sh
+COPY docker/autoconfig.sh /autoconfig.sh
+RUN set -ex \
+ && chmod +x /start.sh \
+ && chmod +x /autoconfig.sh
+
+CMD /autoconfig.sh && /start.sh
--- /dev/null
+PROJECT_NAME?=evse
+NAME:=e-mobility-charging-stations-dashboard
+SUBMODULES_INIT?=false
+DOCKER_ECR_ACCOUNT_ID?=166296450311
+DOCKER_ECR_REGION?=eu-west-3
+DOCKER_ECR_REGISTRY_NAME?=e-mobility-charging-stations-dashboard
+DOCKER_ECR_TAG?=latest
+
+.PHONY: all
+
+default: all
+
+submodule-update:
+ git submodule update --init --recursive
+
+submodules-init=
+ifeq '$(SUBMODULES_INIT)' 'true'
+ submodules-init += submodule-update
+endif
+
+$(NAME): $(submodules-init)
+ docker compose -p $(PROJECT_NAME) up -d
+
+$(NAME)-force: $(submodules-init)
+ docker compose -p $(PROJECT_NAME) up -d --build --force-recreate
+
+all: $(NAME)
+
+clean-images:
+ -docker rmi $(PROJECT_NAME)-$(NAME)
+
+clean-containers:
+ -docker compose -p $(PROJECT_NAME) down
+
+clean: clean-containers clean-images
+
+docker-tag-ecr:
+ docker tag $(PROJECT_NAME)-$(NAME) $(DOCKER_ECR_ACCOUNT_ID).dkr.ecr.$(DOCKER_ECR_REGION).amazonaws.com/$(DOCKER_ECR_REGISTRY_NAME):$(DOCKER_ECR_TAG)
+
+docker-push-ecr: $(NAME)-force docker-tag-ecr
+ aws ecr get-login-password --region $(DOCKER_ECR_REGION) | docker login --username AWS --password-stdin $(DOCKER_ECR_ACCOUNT_ID).dkr.ecr.$(DOCKER_ECR_REGION).amazonaws.com/$(DOCKER_ECR_REGISTRY_NAME)
+ docker push $(DOCKER_ECR_ACCOUNT_ID).dkr.ecr.$(DOCKER_ECR_REGION).amazonaws.com/$(DOCKER_ECR_REGISTRY_NAME):$(DOCKER_ECR_TAG)
+
+dist-clean-images:
+ docker image prune -a -f
+
+dist-clean-volumes:
+ docker volume prune -f
+
+dist-clean: clean-containers dist-clean-volumes dist-clean-images
--- /dev/null
+#!/usr/bin/env sh
+
+if ! [ -z $emobility_server_type ] && ! [ -z $emobility_service_type ]
+then
+ [ -z $emobility_install_dir ] && { echo "emobility installation directory env variable not found, exiting"; exit 1; }
+ [ -z $emobility_landscape ] && { echo "emobility landscape env variable not found, exiting"; exit 1; }
+ [ -z $emobility_server_type ] && { echo "emobility env server type variable not found, exiting"; exit 1; }
+ [ -z $emobility_service_type ] && { echo "emobility env service type variable not found, exiting"; exit 1; }
+
+ cp $emobility_install_dir/dist/assets/configs-docker/$emobility_server_type-$emobility_service_type-$emobility_landscape.json $emobility_install_dir/public/config.json
+else
+ echo "no emobility env defined, start with default configuration"
+fi
--- /dev/null
+{
+ "uiServer": {
+ "host": "localhost",
+ "port": 8080,
+ "protocol": "ui",
+ "version": "0.0.1",
+ "authentication": {
+ "enabled": true,
+ "type": "protocol-basic-auth",
+ "username": "admin",
+ "password": "admin"
+ }
+ }
+}
--- /dev/null
+networks:
+ ev_network:
+ driver: bridge
+services:
+ e-mobility-charging-stations-dashboard:
+ build:
+ context: ..
+ dockerfile: docker/Dockerfile
+ networks:
+ - ev_network
+ ports:
+ - 3030:3030
--- /dev/null
+#!/usr/bin/env sh
+
+node start.js
)
this.ws.onopen = () => {
useToast().success(
- `WebSocket to UI server '${this.uiServerConfiguration.host}' successfully opened`
+ `WebSocket to UI server '${this.uiServerConfiguration.host}:${this.uiServerConfiguration.port.toString()}' successfully opened`
)
}
this.ws.onmessage = this.responseHandler.bind(this)
this.ws.onerror = errorEvent => {
- useToast().error(`Error in WebSocket to UI server '${this.uiServerConfiguration.host}'`)
+ useToast().error(
+ `Error in WebSocket to UI server '${this.uiServerConfiguration.host}:${this.uiServerConfiguration.port.toString()}'`
+ )
console.error(
- `Error in WebSocket to UI server '${this.uiServerConfiguration.host}'`,
+ `Error in WebSocket to UI server '${this.uiServerConfiguration.host}:${this.uiServerConfiguration.port.toString()}'`,
errorEvent
)
}