diff --git a/.docker_image_version b/.docker_image_version deleted file mode 100644 index bcab45af..00000000 --- a/.docker_image_version +++ /dev/null @@ -1 +0,0 @@ -0.0.3 diff --git a/.env b/.env new file mode 100644 index 00000000..802700b6 --- /dev/null +++ b/.env @@ -0,0 +1 @@ +TAG=0.0.3 diff --git a/.github/workflows/cicd.yaml b/.github/workflows/cicd.yaml index 72203458..a4708162 100644 --- a/.github/workflows/cicd.yaml +++ b/.github/workflows/cicd.yaml @@ -40,35 +40,35 @@ jobs: - name: Ensure Docker image version is not referencing an existing release id: docker-image-version-check run: | - if ! [[ -s .docker_image_version ]]; then - echo 'Error: No .docker_image_version file found.' + if ! [[ -s .env ]]; then + echo 'Error: No .env file found.' exit 1 fi - if [[ $(sed '/^\s*$/d' .docker_image_version | wc -l) -ge 2 ]]; then - echo 'Error: .docker_image_version should contain only one line.' + if ! [[ grep -qE '^TAG=' .env ]]; then + echo 'Error: .env must contain a TAG variable.' exit 1 fi - SEMVER="$(cat .docker_image_version)" + source .env # Fail if any previous Docker image version value matches the one in # this PR (excluding the current image version). - for commit in $(git --no-pager log --first-parent --format=%H -- .docker_image_version | tail -n +2); do - if git --no-pager grep -hF "${SEMVER}" $commit -- .docker_image_version | grep -qx ${SEMVER}; then - echo 'Error: The version in .docker_image_version matches an' + for commit in $(git --no-pager log --first-parent --format=%H -- .env | tail -n +2); do + if git --no-pager grep -hF "${TAG}" $commit -- .env | grep -qx ${TAG}; then + echo 'Error: The version in .env matches an' echo ' earlier version on main. Please update the value in' - echo ' .docker_image_version to a new version.' + echo ' .env to a new version.' exit 1 fi done - if git show-ref --tags --verify --quiet "refs/tags/v${SEMVER}"; then - echo "Error: The tag 'v${SEMVER}' is already a GitHub release.' - echo ' Please update the version in .docker_image_version' + if git show-ref --tags --verify --quiet "refs/tags/v${TAG}"; then + echo "Error: The tag 'v${TAG}' is already a GitHub release.' + echo ' Please update the version in .env' exit 1 else - echo "SEMVER=${SEMVER}" >> "${GITHUB_OUTPUT}" + echo "TAG=${TAG}" >> "${GITHUB_OUTPUT}" fi - name: Set Docker image metadata @@ -79,7 +79,7 @@ jobs: tags: | type=ref,event=branch type=ref,event=pr - type=semver,pattern=${{ steps.docker-image-version-check.outputs.SEMVER }} + type=semver,pattern=${{ steps.docker-image-version-check.outputs.TAG }} - name: Log into GitHub container registry uses: docker/login-action@v3 diff --git a/README.md b/README.md index 005b6c6c..54677be6 100644 --- a/README.md +++ b/README.md @@ -46,9 +46,9 @@ The use cases supported by the three demos are summarized in conceptual block di ### STEP 1: Run the demo - Copy and paste the command for the demo you want to see: - - 🚨simple AC charging station ⚡: `curl -o docker-compose.yml https://raw.githubusercontent.com/everest/everest-demo/main/docker-compose.yml && docker compose -p everest up` - - 🚨ISO 15118 DC charging ⚡: `curl -o docker-compose.yml https://raw.githubusercontent.com/everest/everest-demo/main/docker-compose.iso15118-dc.yml && docker compose -p everest-dc up` - - 🚨 two EVSE charging ⚡: `curl -o docker-compose.yml https://raw.githubusercontent.com/everest/everest-demo/main/docker-compose.two-evse.yml && docker compose -p everest-two-evse up` + - 🚨 AC Charging ⚡: `curl https://raw.githubusercontent.com/everest/everest-demo/main/demo-ac.sh | bash` + - 🚨 ISO 15118 DC Charging ⚡: `curl https://raw.githubusercontent.com/everest/everest-demo/main/demo-iso15118-2-dc.sh | bash` + - 🚨 Two EVSE Charging ⚡: `curl https://raw.githubusercontent.com/everest/everest-demo/main/demo-two-evse.sh | bash` ### STEP 2: Interact with the demo - Open the `nodered` flows to understand the module flows at http://127.0.0.1:1880 diff --git a/demo-ac.sh b/demo-ac.sh new file mode 100755 index 00000000..3441ca91 --- /dev/null +++ b/demo-ac.sh @@ -0,0 +1,34 @@ +#!/usr/bin/env bash + +DEMO_COMPOSE_FILE_NAME='docker-compose.yml' +DEMO_DIR="$(mktemp -d)" + +delete_temporary_directory() { rm -rf "${DEMO_DIR}"; } +trap delete_temporary_directory EXIT + +if [[ ! "${DEMO_DIR}" || ! -d "${DEMO_DIR}" ]]; then + echo 'Error: Failed to create a temporary directory for the demo.' + exit 1 +fi + +download_demo_file() { + local -r repo_file_path="$1" + local -r repo_raw_url='https://raw.githubusercontent.com/everest/everest-demo/main' + local -r destination_path="${DEMO_DIR}/${repo_file_path}" + + mkdir -p "$(dirname ${destination_path})" + curl -s -o "${destination_path}" "${repo_raw_url}/${repo_file_path}" + if [[ "$?" != 0 ]]; then + echo "Error: Failed to retrieve \"${repo_file_path}\" from the demo" + echo 'repository. If this issue persists, please report this as an' + echo 'issue in the EVerest project:' + echo ' https://github.com/EVerest/EVerest/issues' + exit 1 + fi +} + +download_demo_file "${DEMO_COMPOSE_FILE_NAME}" +download_demo_file .env + +docker compose --project-name everest-ac-demo \ + --file "${DEMO_DIR}/${DEMO_COMPOSE_FILE_NAME}" up diff --git a/demo-admin-panel.sh b/demo-admin-panel.sh new file mode 100755 index 00000000..7103d440 --- /dev/null +++ b/demo-admin-panel.sh @@ -0,0 +1,34 @@ +#!/usr/bin/env bash + +DEMO_COMPOSE_FILE_NAME='docker-compose.admin-panel.yml' +DEMO_DIR="$(mktemp -d)" + +delete_temporary_directory() { rm -rf "${DEMO_DIR}"; } +trap delete_temporary_directory EXIT + +if [[ ! "${DEMO_DIR}" || ! -d "${DEMO_DIR}" ]]; then + echo 'Error: Failed to create a temporary directory for the demo.' + exit 1 +fi + +download_demo_file() { + local -r repo_file_path="$1" + local -r repo_raw_url='https://raw.githubusercontent.com/everest/everest-demo/main' + local -r destination_path="${DEMO_DIR}/${repo_file_path}" + + mkdir -p "$(dirname ${destination_path})" + curl -s -o "${destination_path}" "${repo_raw_url}/${repo_file_path}" + if [[ "$?" != 0 ]]; then + echo "Error: Failed to retrieve \"${repo_file_path}\" from the demo" + echo 'repository. If this issue persists, please report this as an' + echo 'issue in the EVerest project:' + echo ' https://github.com/EVerest/EVerest/issues' + exit 1 + fi +} + +download_demo_file "${DEMO_COMPOSE_FILE_NAME}" +download_demo_file .env + +docker compose --project-name everest-ac-demo \ + --file "${DEMO_DIR}/${DEMO_COMPOSE_FILE_NAME}" up diff --git a/demo-iso15118-2-dc.sh b/demo-iso15118-2-dc.sh new file mode 100755 index 00000000..3dcbcd5a --- /dev/null +++ b/demo-iso15118-2-dc.sh @@ -0,0 +1,34 @@ +#!/usr/bin/env bash + +DEMO_COMPOSE_FILE_NAME='docker-compose.iso15118-dc.yml' +DEMO_DIR="$(mktemp -d)" + +delete_temporary_directory() { rm -rf "${DEMO_DIR}"; } +trap delete_temporary_directory EXIT + +if [[ ! "${DEMO_DIR}" || ! -d "${DEMO_DIR}" ]]; then + echo 'Error: Failed to create a temporary directory for the demo.' + exit 1 +fi + +download_demo_file() { + local -r repo_file_path="$1" + local -r repo_raw_url='https://raw.githubusercontent.com/everest/everest-demo/main' + local -r destination_path="${DEMO_DIR}/${repo_file_path}" + + mkdir -p "$(dirname ${destination_path})" + curl -s -o "${destination_path}" "${repo_raw_url}/${repo_file_path}" + if [[ "$?" != 0 ]]; then + echo "Error: Failed to retrieve \"${repo_file_path}\" from the demo" + echo 'repository. If this issue persists, please report this as an' + echo 'issue in the EVerest project:' + echo ' https://github.com/EVerest/EVerest/issues' + exit 1 + fi +} + +download_demo_file "${DEMO_COMPOSE_FILE_NAME}" +download_demo_file .env + +docker compose --project-name everest-ac-demo \ + --file "${DEMO_DIR}/${DEMO_COMPOSE_FILE_NAME}" up diff --git a/demo-two-evse.sh b/demo-two-evse.sh new file mode 100755 index 00000000..dbf94a96 --- /dev/null +++ b/demo-two-evse.sh @@ -0,0 +1,34 @@ +#!/usr/bin/env bash + +DEMO_COMPOSE_FILE_NAME='docker-compose.two-evse.yml' +DEMO_DIR="$(mktemp -d)" + +delete_temporary_directory() { rm -rf "${DEMO_DIR}"; } +trap delete_temporary_directory EXIT + +if [[ ! "${DEMO_DIR}" || ! -d "${DEMO_DIR}" ]]; then + echo 'Error: Failed to create a temporary directory for the demo.' + exit 1 +fi + +download_demo_file() { + local -r repo_file_path="$1" + local -r repo_raw_url='https://raw.githubusercontent.com/everest/everest-demo/main' + local -r destination_path="${DEMO_DIR}/${repo_file_path}" + + mkdir -p "$(dirname ${destination_path})" + curl -s -o "${destination_path}" "${repo_raw_url}/${repo_file_path}" + if [[ "$?" != 0 ]]; then + echo "Error: Failed to retrieve \"${repo_file_path}\" from the demo" + echo 'repository. If this issue persists, please report this as an' + echo 'issue in the EVerest project:' + echo ' https://github.com/EVerest/EVerest/issues' + exit 1 + fi +} + +download_demo_file "${DEMO_COMPOSE_FILE_NAME}" +download_demo_file .env + +docker compose --project-name everest-ac-demo \ + --file "${DEMO_DIR}/${DEMO_COMPOSE_FILE_NAME}" up diff --git a/docker-compose.admin-panel.yml b/docker-compose.admin-panel.yml index 64033aa3..303db3d2 100644 --- a/docker-compose.admin-panel.yml +++ b/docker-compose.admin-panel.yml @@ -2,12 +2,12 @@ version: "3.6" services: mqtt-server: - image: ghcr.io/everest/everest-demo/mqtt-server:0.0.3 + image: ghcr.io/everest/everest-demo/mqtt-server:${TAG} logging: driver: none manager: - image: ghcr.io/everest/everest-demo/manager:0.0.3 + image: ghcr.io/everest/everest-demo/manager:${TAG} depends_on: - mqtt-server environment: diff --git a/docker-compose.build.yml b/docker-compose.build.yml index bbc974e5..7a8536f7 100644 --- a/docker-compose.build.yml +++ b/docker-compose.build.yml @@ -2,13 +2,13 @@ version: "3.6" services: mqtt-server: - image: ghcr.io/everest/everest-demo/mqtt-server:0.0.3 + image: ghcr.io/everest/everest-demo/mqtt-server:${TAG} build: mosquitto logging: driver: none manager: - image: ghcr.io/everest/everest-demo/manager:0.0.3 + image: ghcr.io/everest/everest-demo/manager:${TAG} build: manager depends_on: - mqtt-server @@ -19,7 +19,7 @@ services: - net.ipv6.conf.all.disable_ipv6=0 node-red: - image: ghcr.io/everest/everest-demo/nodered:0.0.3 + image: ghcr.io/everest/everest-demo/nodered:${TAG} build: nodered depends_on: - mqtt-server diff --git a/docker-compose.iso15118-dc.yml b/docker-compose.iso15118-dc.yml index aaf7ba40..43b2108e 100644 --- a/docker-compose.iso15118-dc.yml +++ b/docker-compose.iso15118-dc.yml @@ -2,14 +2,14 @@ version: "3.6" services: mqtt-server: - image: ghcr.io/everest/everest-demo/mqtt-server:0.0.3 + image: ghcr.io/everest/everest-demo/mqtt-server:${TAG} logging: driver: none ports: - 1883:1883 manager: - image: ghcr.io/everest/everest-demo/manager:0.0.3 + image: ghcr.io/everest/everest-demo/manager:${TAG} depends_on: - mqtt-server environment: @@ -19,7 +19,7 @@ services: - net.ipv6.conf.all.disable_ipv6=0 node-red: - image: ghcr.io/everest/everest-demo/nodered:0.0.3 + image: ghcr.io/everest/everest-demo/nodered:${TAG} depends_on: - mqtt-server environment: diff --git a/docker-compose.two-evse.yml b/docker-compose.two-evse.yml index 1eb687a1..3174bb86 100644 --- a/docker-compose.two-evse.yml +++ b/docker-compose.two-evse.yml @@ -2,12 +2,12 @@ version: "3.6" services: mqtt-server: - image: ghcr.io/everest/everest-demo/mqtt-server:0.0.3 + image: ghcr.io/everest/everest-demo/mqtt-server:${TAG} logging: driver: none manager: - image: ghcr.io/everest/everest-demo/manager:0.0.3 + image: ghcr.io/everest/everest-demo/manager:${TAG} depends_on: - mqtt-server environment: @@ -17,7 +17,7 @@ services: - net.ipv6.conf.all.disable_ipv6=0 node-red: - image: ghcr.io/everest/everest-demo/nodered:0.0.3 + image: ghcr.io/everest/everest-demo/nodered:${TAG} depends_on: - mqtt-server environment: diff --git a/docker-compose.yml b/docker-compose.yml index 2fc81c83..26ad2393 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,12 +2,12 @@ version: "3.6" services: mqtt-server: - image: ghcr.io/everest/everest-demo/mqtt-server:0.0.3 + image: ghcr.io/everest/everest-demo/mqtt-server:${TAG} logging: driver: none manager: - image: ghcr.io/everest/everest-demo/manager:0.0.3 + image: ghcr.io/everest/everest-demo/manager:${TAG} depends_on: - mqtt-server environment: @@ -17,7 +17,7 @@ services: - net.ipv6.conf.all.disable_ipv6=0 node-red: - image: ghcr.io/everest/everest-demo/nodered:0.0.3 + image: ghcr.io/everest/everest-demo/nodered:${TAG} depends_on: - mqtt-server environment: