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 e63d01f4..572dbe62 100644 --- a/.github/workflows/cicd.yaml +++ b/.github/workflows/cicd.yaml @@ -1,14 +1,14 @@ name: cicd on: + pull_request: + branches: + - main push: branches: - - 'build_pkg_**' + - main tags: - - 'v*' - pull_request: - branches: - - 'main' + - 'v[0-9]+.[0-9]+.[0-9]+' jobs: docker-build-and-push-images: @@ -21,27 +21,72 @@ jobs: strategy: matrix: include: - - image: ghcr.io/us-joet/everest-demo/manager + - host_namespace: ghcr.io/everest/everest-demo + image_name: manager context: ./manager - - image: ghcr.io/us-joet/everest-demo/mqtt-server + - host_namespace: ghcr.io/everest/everest-demo + image_name: mqtt-server context: ./mosquitto - - image: ghcr.io/us-joet/everest-demo/nodered + - host_namespace: ghcr.io/everest/everest-demo + image_name: nodered context: ./nodered 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 + shell: bash + run: | + if ! [[ -s '.env' ]]; then + echo 'Error: No .env file found.' + exit 1 + fi + + if ! grep -qE '^TAG=' .env; then + echo 'Error: .env must contain a TAG variable.' + exit 1 + fi + + 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 -- .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 ' .env to a new version.' + exit 1 + fi + 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 ' Please update the version in .env' + exit 1 + else + 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 with: - images: ${{ matrix.image }} + images: ${{ matrix.host_namespace }}/${{ matrix.image_name }} 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.outputs.TAG }} - name: Log into GitHub container registry if: github.event_name != 'pull_request' @@ -58,3 +103,5 @@ jobs: push: ${{ github.event_name != 'pull_request' }} 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 }} diff --git a/README.md b/README.md index 005b6c6c..935c6bd7 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 @@ -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`. 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 fc88d207..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/shankari/everest-demo/mqtt-server:0.0.1 + image: ghcr.io/everest/everest-demo/mqtt-server:${TAG} logging: driver: none manager: - image: ghcr.io/shankari/everest-demo/manager:0.0.2 + 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 d9cdc603..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/shankari/everest-demo/mqtt-server:0.0.1 + image: ghcr.io/everest/everest-demo/mqtt-server:${TAG} build: mosquitto logging: driver: none manager: - image: ghcr.io/shankari/everest-demo/manager:0.0.2 + 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/shankari/everest-demo/nodered:0.0.1 + 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 037d9c1b..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/shankari/everest-demo/mqtt-server:0.0.1 + image: ghcr.io/everest/everest-demo/mqtt-server:${TAG} logging: driver: none ports: - 1883:1883 manager: - image: ghcr.io/shankari/everest-demo/manager:0.0.2 + 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/shankari/everest-demo/nodered:0.0.1 + 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 a62df243..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/shankari/everest-demo/mqtt-server:0.0.1 + image: ghcr.io/everest/everest-demo/mqtt-server:${TAG} logging: driver: none manager: - image: ghcr.io/shankari/everest-demo/manager:0.0.2 + 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/shankari/everest-demo/nodered:0.0.1 + image: ghcr.io/everest/everest-demo/nodered:${TAG} depends_on: - mqtt-server environment: diff --git a/docker-compose.yml b/docker-compose.yml index a18c517c..26ad2393 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:${TAG} logging: driver: none manager: - image: ghcr.io/shankari/everest-demo/manager:0.0.2 + 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/shankari/everest-demo/nodered:0.0.1 + image: ghcr.io/everest/everest-demo/nodered:${TAG} 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