From c6c5b1b9717455dcbfc6a55f8bfbb264f1e4d769 Mon Sep 17 00:00:00 2001 From: Daniel Moore <9156191+drmrd@users.noreply.github.com> Date: Wed, 29 Nov 2023 17:51:38 -0500 Subject: [PATCH 01/14] Specify Docker image version tag in a config file Signed-off-by: Daniel Moore <9156191+drmrd@users.noreply.github.com> --- .docker_image_version | 1 + .github/workflows/cicd.yaml | 30 +++++++++++++++++++++--------- 2 files changed, 22 insertions(+), 9 deletions(-) create mode 100644 .docker_image_version diff --git a/.docker_image_version b/.docker_image_version new file mode 100644 index 00000000..bcab45af --- /dev/null +++ b/.docker_image_version @@ -0,0 +1 @@ +0.0.3 diff --git a/.github/workflows/cicd.yaml b/.github/workflows/cicd.yaml index e63d01f4..4a860602 100644 --- a/.github/workflows/cicd.yaml +++ b/.github/workflows/cicd.yaml @@ -1,11 +1,6 @@ name: cicd on: - push: - branches: - - 'build_pkg_**' - tags: - - 'v*' pull_request: branches: - 'main' @@ -31,6 +26,25 @@ jobs: steps: - name: Checkout uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - 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.' + exit 1 + fi + + SEMVER="$(cat .docker_images_version)" + 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' + exit 1 + else + echo "SEMVER=${SEMVER}" >> "${GITHUB_OUTPUT}" + fi - name: Set Docker image metadata id: meta @@ -40,11 +54,9 @@ jobs: tags: | type=ref,event=branch type=ref,event=pr - type=semver,pattern={{version}} - type=semver,pattern={{major}}.{{minor}} + type=semver,pattern=${{ steps.docker-image-version-check.SEMVER }} - name: Log into GitHub container registry - if: github.event_name != 'pull_request' uses: docker/login-action@v3 with: registry: ghcr.io @@ -55,6 +67,6 @@ jobs: uses: docker/build-push-action@v5 with: context: ${{ matrix.context }} - push: ${{ github.event_name != 'pull_request' }} + push: true tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} From 7a3d25201d4945aaa604c4e39a2ae6cff99636b4 Mon Sep 17 00:00:00 2001 From: Daniel Moore <9156191+drmrd@users.noreply.github.com> Date: Fri, 1 Dec 2023 14:53:02 -0500 Subject: [PATCH 02/14] Enable Docker image layer caching in CI/CD workflow Signed-off-by: Daniel Moore <9156191+drmrd@users.noreply.github.com> --- .github/workflows/cicd.yaml | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/.github/workflows/cicd.yaml b/.github/workflows/cicd.yaml index 4a860602..5e1a12d1 100644 --- a/.github/workflows/cicd.yaml +++ b/.github/workflows/cicd.yaml @@ -16,11 +16,14 @@ jobs: strategy: matrix: include: - - image: ghcr.io/us-joet/everest-demo/manager + - host_namespace: ghcr.io/us-joet/everest-demo + image_name: manager context: ./manager - - image: ghcr.io/us-joet/everest-demo/mqtt-server + - host_namespace: ghcr.io/us-joet/everest-demo + image_name: mqtt-server context: ./mosquitto - - image: ghcr.io/us-joet/everest-demo/nodered + - host_namespace: ghcr.io/us-joet/everest-demo + image_name: nodered context: ./nodered steps: @@ -50,11 +53,11 @@ jobs: id: meta uses: docker/metadata-action@v5 with: - images: ${{ matrix.image }} + images: ${{ matrix.host_namespace }}/${{ matrix.image_name }} tags: | type=ref,event=branch type=ref,event=pr - type=semver,pattern=${{ steps.docker-image-version-check.SEMVER }} + type=semver,pattern=${{ steps.docker-image-version-check.outputs.SEMVER }} - name: Log into GitHub container registry uses: docker/login-action@v3 @@ -70,3 +73,5 @@ jobs: push: true tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} + cache-from: type=gha,scope=${{ matrix.image_name }} + cache-to: type=gha,mode=max,scope=${{ matrix.image_name }} From dc3c719eb00937fbdbcf0c048c3d97949e3c5bbe Mon Sep 17 00:00:00 2001 From: Daniel Moore <9156191+drmrd@users.noreply.github.com> Date: Fri, 1 Dec 2023 16:46:53 -0500 Subject: [PATCH 03/14] Trigger workflow on merges to main and version tag creation Signed-off-by: Daniel Moore <9156191+drmrd@users.noreply.github.com> --- .github/workflows/cicd.yaml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/cicd.yaml b/.github/workflows/cicd.yaml index 5e1a12d1..fb2c9b1e 100644 --- a/.github/workflows/cicd.yaml +++ b/.github/workflows/cicd.yaml @@ -3,7 +3,12 @@ name: cicd on: pull_request: branches: - - 'main' + - main + push: + branches: + - main + tags: + - 'v[0-9]+.[0-9]+.[0-9]+' jobs: docker-build-and-push-images: From abc547c05d4fd48351438fab4130a9bfc9f43b73 Mon Sep 17 00:00:00 2001 From: Daniel Moore <9156191+drmrd@users.noreply.github.com> Date: Fri, 1 Dec 2023 19:04:54 -0500 Subject: [PATCH 04/14] Prevent new PRs from reusing old Docker image versions Signed-off-by: Daniel Moore <9156191+drmrd@users.noreply.github.com> --- .github/workflows/cicd.yaml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/.github/workflows/cicd.yaml b/.github/workflows/cicd.yaml index fb2c9b1e..407a43f7 100644 --- a/.github/workflows/cicd.yaml +++ b/.github/workflows/cicd.yaml @@ -45,7 +45,24 @@ jobs: 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.' + exit 1 + fi + SEMVER="$(cat .docker_images_version)" + + # 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' + echo ' earlier version on main. Please update the value in' + echo ' .docker_image_version 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' From f84ed1a6322031d2dc320abb4a3a04548bc05ec4 Mon Sep 17 00:00:00 2001 From: Daniel Moore <9156191+drmrd@users.noreply.github.com> Date: Fri, 1 Dec 2023 19:24:05 -0500 Subject: [PATCH 05/14] Update Docker images to use EVerest GHCR namespaces Signed-off-by: Daniel Moore <9156191+drmrd@users.noreply.github.com> --- docker-compose.admin-panel.yml | 4 ++-- docker-compose.build.yml | 6 +++--- docker-compose.iso15118-dc.yml | 6 +++--- docker-compose.two-evse.yml | 6 +++--- docker-compose.yml | 6 +++--- manager/Dockerfile | 2 +- mosquitto/Dockerfile | 2 +- nodered/Dockerfile | 2 +- 8 files changed, 17 insertions(+), 17 deletions(-) diff --git a/docker-compose.admin-panel.yml b/docker-compose.admin-panel.yml index fc88d207..3fc31bbe 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/shankari/everest-demo/mqtt-server:0.0.1 + image: ghcr.io/everest/everest-demo/mqtt-server:0.0.1 logging: driver: none manager: - image: ghcr.io/shankari/everest-demo/manager:0.0.2 + image: ghcr.io/everest/everest-demo/manager:0.0.2 depends_on: - mqtt-server environment: diff --git a/docker-compose.build.yml b/docker-compose.build.yml index d9cdc603..a2f70efc 100644 --- a/docker-compose.build.yml +++ b/docker-compose.build.yml @@ -2,13 +2,13 @@ version: "3.6" services: mqtt-server: - image: ghcr.io/shankari/everest-demo/mqtt-server:0.0.1 + image: ghcr.io/everest/everest-demo/mqtt-server:0.0.1 build: mosquitto logging: driver: none manager: - image: ghcr.io/shankari/everest-demo/manager:0.0.2 + image: ghcr.io/everest/everest-demo/manager:0.0.2 build: manager depends_on: - mqtt-server @@ -19,7 +19,7 @@ services: - net.ipv6.conf.all.disable_ipv6=0 node-red: - image: ghcr.io/shankari/everest-demo/nodered:0.0.1 + image: ghcr.io/everest/everest-demo/nodered:0.0.1 build: nodered depends_on: - mqtt-server diff --git a/docker-compose.iso15118-dc.yml b/docker-compose.iso15118-dc.yml index 037d9c1b..c3b3937b 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/shankari/everest-demo/mqtt-server:0.0.1 + image: ghcr.io/everest/everest-demo/mqtt-server:0.0.1 logging: driver: none ports: - 1883:1883 manager: - image: ghcr.io/shankari/everest-demo/manager:0.0.2 + image: ghcr.io/everest/everest-demo/manager:0.0.2 depends_on: - mqtt-server environment: @@ -19,7 +19,7 @@ services: - net.ipv6.conf.all.disable_ipv6=0 node-red: - image: ghcr.io/shankari/everest-demo/nodered:0.0.1 + image: ghcr.io/everest/everest-demo/nodered:0.0.1 depends_on: - mqtt-server environment: diff --git a/docker-compose.two-evse.yml b/docker-compose.two-evse.yml index a62df243..19665b78 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/shankari/everest-demo/mqtt-server:0.0.1 + image: ghcr.io/everest/everest-demo/mqtt-server:0.0.1 logging: driver: none manager: - image: ghcr.io/shankari/everest-demo/manager:0.0.2 + image: ghcr.io/everest/everest-demo/manager:0.0.2 depends_on: - mqtt-server environment: @@ -17,7 +17,7 @@ services: - net.ipv6.conf.all.disable_ipv6=0 node-red: - image: ghcr.io/shankari/everest-demo/nodered:0.0.1 + image: ghcr.io/everest/everest-demo/nodered:0.0.1 depends_on: - mqtt-server environment: diff --git a/docker-compose.yml b/docker-compose.yml index a18c517c..7d559db1 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,12 +2,12 @@ version: "3.6" services: mqtt-server: - image: ghcr.io/shankari/everest-demo/mqtt-server:0.0.1 + image: ghcr.io/everest/everest-demo/mqtt-server:0.0.1 logging: driver: none manager: - image: ghcr.io/shankari/everest-demo/manager:0.0.2 + image: ghcr.io/everest/everest-demo/manager:0.0.2 depends_on: - mqtt-server environment: @@ -17,7 +17,7 @@ services: - net.ipv6.conf.all.disable_ipv6=0 node-red: - image: ghcr.io/shankari/everest-demo/nodered:0.0.1 + image: ghcr.io/everest/everest-demo/nodered:0.0.1 depends_on: - mqtt-server environment: diff --git a/manager/Dockerfile b/manager/Dockerfile index cafda40d..4ef45fcd 100644 --- a/manager/Dockerfile +++ b/manager/Dockerfile @@ -21,4 +21,4 @@ RUN git clone https://github.com/EVerest/everest-core.git \ # Copy over the custom config *after* the compile COPY config-docker.json ./dist/share/everest/modules/OCPP/config-docker.json -LABEL org.opencontainers.image.source=https://github.com/us-joet/everest-demo +LABEL org.opencontainers.image.source=https://github.com/everest/everest-demo diff --git a/mosquitto/Dockerfile b/mosquitto/Dockerfile index 4d949266..6b760d10 100644 --- a/mosquitto/Dockerfile +++ b/mosquitto/Dockerfile @@ -2,4 +2,4 @@ FROM eclipse-mosquitto:2.0.10 COPY mosquitto.conf /mosquitto/config/mosquitto.conf -LABEL org.opencontainers.image.source=https://github.com/shankari/everest-demo +LABEL org.opencontainers.image.source=https://github.com/everest/everest-demo diff --git a/nodered/Dockerfile b/nodered/Dockerfile index 58b03edc..6e748b6b 100644 --- a/nodered/Dockerfile +++ b/nodered/Dockerfile @@ -6,4 +6,4 @@ RUN npm install node-red-contrib-ui-level COPY config /config -LABEL org.opencontainers.image.source=https://github.com/shankari/everest-demo +LABEL org.opencontainers.image.source=https://github.com/everest/everest-demo From 013d634333aab268d16133a3560b0115293c896c Mon Sep 17 00:00:00 2001 From: Daniel Moore <9156191+drmrd@users.noreply.github.com> Date: Fri, 1 Dec 2023 19:34:58 -0500 Subject: [PATCH 06/14] Update to the new Docker image version in Compose files Signed-off-by: Daniel Moore <9156191+drmrd@users.noreply.github.com> --- docker-compose.admin-panel.yml | 4 ++-- docker-compose.build.yml | 6 +++--- docker-compose.iso15118-dc.yml | 6 +++--- docker-compose.two-evse.yml | 6 +++--- docker-compose.yml | 6 +++--- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/docker-compose.admin-panel.yml b/docker-compose.admin-panel.yml index 3fc31bbe..64033aa3 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.1 + image: ghcr.io/everest/everest-demo/mqtt-server:0.0.3 logging: driver: none manager: - image: ghcr.io/everest/everest-demo/manager:0.0.2 + image: ghcr.io/everest/everest-demo/manager:0.0.3 depends_on: - mqtt-server environment: diff --git a/docker-compose.build.yml b/docker-compose.build.yml index a2f70efc..bbc974e5 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.1 + image: ghcr.io/everest/everest-demo/mqtt-server:0.0.3 build: mosquitto logging: driver: none manager: - image: ghcr.io/everest/everest-demo/manager:0.0.2 + image: ghcr.io/everest/everest-demo/manager:0.0.3 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.1 + image: ghcr.io/everest/everest-demo/nodered:0.0.3 build: nodered depends_on: - mqtt-server diff --git a/docker-compose.iso15118-dc.yml b/docker-compose.iso15118-dc.yml index c3b3937b..aaf7ba40 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.1 + image: ghcr.io/everest/everest-demo/mqtt-server:0.0.3 logging: driver: none ports: - 1883:1883 manager: - image: ghcr.io/everest/everest-demo/manager:0.0.2 + image: ghcr.io/everest/everest-demo/manager:0.0.3 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.1 + image: ghcr.io/everest/everest-demo/nodered:0.0.3 depends_on: - mqtt-server environment: diff --git a/docker-compose.two-evse.yml b/docker-compose.two-evse.yml index 19665b78..1eb687a1 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.1 + image: ghcr.io/everest/everest-demo/mqtt-server:0.0.3 logging: driver: none manager: - image: ghcr.io/everest/everest-demo/manager:0.0.2 + image: ghcr.io/everest/everest-demo/manager:0.0.3 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.1 + image: ghcr.io/everest/everest-demo/nodered:0.0.3 depends_on: - mqtt-server environment: diff --git a/docker-compose.yml b/docker-compose.yml index 7d559db1..2fc81c83 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.1 + image: ghcr.io/everest/everest-demo/mqtt-server:0.0.3 logging: driver: none manager: - image: ghcr.io/everest/everest-demo/manager:0.0.2 + image: ghcr.io/everest/everest-demo/manager:0.0.3 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.1 + image: ghcr.io/everest/everest-demo/nodered:0.0.3 depends_on: - mqtt-server environment: From b85cf5c48454e2ccb14d2c38bb576059ddbcc11d Mon Sep 17 00:00:00 2001 From: Daniel Moore <9156191+drmrd@users.noreply.github.com> Date: Mon, 4 Dec 2023 10:55:35 -0500 Subject: [PATCH 07/14] Correct a typo in the workflow Signed-off-by: Daniel Moore <9156191+drmrd@users.noreply.github.com> --- .github/workflows/cicd.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cicd.yaml b/.github/workflows/cicd.yaml index 407a43f7..03d0d24e 100644 --- a/.github/workflows/cicd.yaml +++ b/.github/workflows/cicd.yaml @@ -50,7 +50,7 @@ jobs: exit 1 fi - SEMVER="$(cat .docker_images_version)" + SEMVER="$(cat .docker_image_version)" # Fail if any previous Docker image version value matches the one in # this PR (excluding the current image version). From 846d4cff083bcc4aa412c81dbbb91263f43c3e52 Mon Sep 17 00:00:00 2001 From: Daniel Moore <9156191+drmrd@users.noreply.github.com> Date: Mon, 4 Dec 2023 10:59:46 -0500 Subject: [PATCH 08/14] Update image namespaces Signed-off-by: Daniel Moore <9156191+drmrd@users.noreply.github.com> --- .github/workflows/cicd.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/cicd.yaml b/.github/workflows/cicd.yaml index 03d0d24e..72203458 100644 --- a/.github/workflows/cicd.yaml +++ b/.github/workflows/cicd.yaml @@ -21,13 +21,13 @@ jobs: strategy: matrix: include: - - host_namespace: ghcr.io/us-joet/everest-demo + - host_namespace: ghcr.io/everest/everest-demo image_name: manager context: ./manager - - host_namespace: ghcr.io/us-joet/everest-demo + - host_namespace: ghcr.io/everest/everest-demo image_name: mqtt-server context: ./mosquitto - - host_namespace: ghcr.io/us-joet/everest-demo + - host_namespace: ghcr.io/everest/everest-demo image_name: nodered context: ./nodered From f6afe9fc5c2239d256cc62d2956757cec3392ccb Mon Sep 17 00:00:00 2001 From: Daniel Moore <9156191+drmrd@users.noreply.github.com> Date: Mon, 4 Dec 2023 19:15:17 -0500 Subject: [PATCH 09/14] Migrate to using a .env file for Docker image versions Signed-off-by: Daniel Moore <9156191+drmrd@users.noreply.github.com> --- .docker_image_version | 1 - .env | 1 + .github/workflows/cicd.yaml | 28 ++++++++++++++-------------- README.md | 6 +++--- demo-ac.sh | 34 ++++++++++++++++++++++++++++++++++ demo-admin-panel.sh | 34 ++++++++++++++++++++++++++++++++++ demo-iso15118-2-dc.sh | 34 ++++++++++++++++++++++++++++++++++ demo-two-evse.sh | 34 ++++++++++++++++++++++++++++++++++ docker-compose.admin-panel.yml | 4 ++-- docker-compose.build.yml | 6 +++--- docker-compose.iso15118-dc.yml | 6 +++--- docker-compose.two-evse.yml | 6 +++--- docker-compose.yml | 6 +++--- 13 files changed, 168 insertions(+), 32 deletions(-) delete mode 100644 .docker_image_version create mode 100644 .env create mode 100755 demo-ac.sh create mode 100755 demo-admin-panel.sh create mode 100755 demo-iso15118-2-dc.sh create mode 100755 demo-two-evse.sh 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: From 2ea4fb594321cf7fd228a1f895958504a4338623 Mon Sep 17 00:00:00 2001 From: Daniel Moore <9156191+drmrd@users.noreply.github.com> Date: Mon, 4 Dec 2023 19:51:00 -0500 Subject: [PATCH 10/14] Work around Action Runner bug in workflow step See https://github.com/actions/runner/issues/1533 Signed-off-by: Daniel Moore <9156191+drmrd@users.noreply.github.com> --- .github/workflows/cicd.yaml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/cicd.yaml b/.github/workflows/cicd.yaml index a4708162..15b65335 100644 --- a/.github/workflows/cicd.yaml +++ b/.github/workflows/cicd.yaml @@ -39,13 +39,14 @@ jobs: - name: Ensure Docker image version is not referencing an existing release id: docker-image-version-check + shell: bash run: | - if ! [[ -s .env ]]; then + if ! [[ -s '.env' ]]; then echo 'Error: No .env file found.' exit 1 fi - if ! [[ grep -qE '^TAG=' .env ]]; then + if ! grep -qE '^TAG=' .env; then echo 'Error: .env must contain a TAG variable.' exit 1 fi @@ -64,7 +65,7 @@ jobs: done if git show-ref --tags --verify --quiet "refs/tags/v${TAG}"; then - echo "Error: The tag 'v${TAG}' is already a GitHub release.' + echo "Error: The tag 'v${TAG}' is already a GitHub release." echo ' Please update the version in .env' exit 1 else From 172a93608b0259a22b56f9dbd2678b973660008d Mon Sep 17 00:00:00 2001 From: Daniel Moore <9156191+drmrd@users.noreply.github.com> Date: Mon, 4 Dec 2023 20:09:13 -0500 Subject: [PATCH 11/14] Use QEMU and Docker Buildx in CI/CD workflow Signed-off-by: Daniel Moore <9156191+drmrd@users.noreply.github.com> --- .github/workflows/cicd.yaml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/cicd.yaml b/.github/workflows/cicd.yaml index 15b65335..6c11a508 100644 --- a/.github/workflows/cicd.yaml +++ b/.github/workflows/cicd.yaml @@ -72,6 +72,12 @@ jobs: echo "TAG=${TAG}" >> "${GITHUB_OUTPUT}" fi + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Set Docker image metadata id: meta uses: docker/metadata-action@v5 From 3aed68ca976e2465d6e36a385870d8da2caa9f34 Mon Sep 17 00:00:00 2001 From: Daniel Moore <9156191+drmrd@users.noreply.github.com> Date: Tue, 5 Dec 2023 10:19:16 -0500 Subject: [PATCH 12/14] Disable pushing images on PR updates Signed-off-by: Daniel Moore <9156191+drmrd@users.noreply.github.com> --- .github/workflows/cicd.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cicd.yaml b/.github/workflows/cicd.yaml index 6c11a508..8809ed6e 100644 --- a/.github/workflows/cicd.yaml +++ b/.github/workflows/cicd.yaml @@ -99,7 +99,7 @@ jobs: uses: docker/build-push-action@v5 with: context: ${{ matrix.context }} - push: true + push: ${{ github.event_name != 'pull_request' }} tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} cache-from: type=gha,scope=${{ matrix.image_name }} From 2e6c2d6aab354243bdcd07048559c07d8f8ce1c5 Mon Sep 17 00:00:00 2001 From: Daniel Moore <9156191+drmrd@users.noreply.github.com> Date: Tue, 5 Dec 2023 10:19:47 -0500 Subject: [PATCH 13/14] Add a brief blurb to the README regarding image tagging Signed-off-by: Daniel Moore <9156191+drmrd@users.noreply.github.com> --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 54677be6..935c6bd7 100644 --- a/README.md +++ b/README.md @@ -75,3 +75,6 @@ where `[prefix]` is `everest, everest-dc, everest-two-evse...` ## High level block diagram overview of EVerest capabilities From https://everest.github.io/nightly/general/01_framework.html ![image](https://everest.github.io/nightly/_images/quick-start-high-level-1.png) + +## Notes for Demo Contributors +Docker images defined in this repository are built during pull requests, on merges to `main`, and on pushes of semantic version tags. The labels for newly-built images are determined by the `TAG` environment variable specified in the root level `.env` file in this repository. The value of `TAG` is also used throughout the demo `docker-compose.*.yml`. From 11b87153191e99712e7bb22774b251f71024a0c2 Mon Sep 17 00:00:00 2001 From: Daniel Moore <9156191+drmrd@users.noreply.github.com> Date: Tue, 5 Dec 2023 10:21:56 -0500 Subject: [PATCH 14/14] Skip logging into GHCR during pull requests Signed-off-by: Daniel Moore <9156191+drmrd@users.noreply.github.com> --- .github/workflows/cicd.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/cicd.yaml b/.github/workflows/cicd.yaml index 8809ed6e..572dbe62 100644 --- a/.github/workflows/cicd.yaml +++ b/.github/workflows/cicd.yaml @@ -89,6 +89,7 @@ jobs: type=semver,pattern=${{ steps.docker-image-version-check.outputs.TAG }} - name: Log into GitHub container registry + if: github.event_name != 'pull_request' uses: docker/login-action@v3 with: registry: ghcr.io