From a0b1c478008cfd844036051a75b4f408f4865498 Mon Sep 17 00:00:00 2001 From: Nathan Tenney Date: Sun, 20 Apr 2025 19:14:23 -0700 Subject: [PATCH 01/29] Added section for web_users generation --- core/setup-platform.py | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/core/setup-platform.py b/core/setup-platform.py index c1613c0..c7aa62d 100755 --- a/core/setup-platform.py +++ b/core/setup-platform.py @@ -1,8 +1,10 @@ +import json import subprocess import os import sys import yaml + from shutil import copy from time import sleep from volttron.platform import set_home @@ -50,10 +52,11 @@ def get_platform_configurations(platform_config_path): config = yaml.safe_load(cin) agents = config["agents"] platform_cfg = config["config"] + web_users_params = config.get("web_users") print("Platform instance name set to: {}".format(platform_cfg.get("instance-name"))) - return config, agents, platform_cfg + return config, agents, platform_cfg, web_users_params def _install_required_deps(): @@ -361,12 +364,30 @@ def final_platform_configurations(): sleep(5) sys.exit(0) +def create_web_map(username, password, groups=None, return_json=False): + from passlib.hash import argon2 + groups = groups if isinstance(groups, list) else [groups] if groups else ['admin', 'vui'] + web_users_dict = { + username: { + "hashed_password": argon2.hash(password), + "groups": groups + } + } + return web_users_dict if not return_json else json.dumps(web_users_dict) + +def save_web_users_json_file(username, password, groups=None): + from pathlib import Path + with open(Path(VOLTTRON_HOME)/'web-users.json', 'w') as f: + json.dump(create_web_map(username, password, groups), f) + if __name__ == "__main__": set_home(VOLTTRON_HOME) - config_tmp, agents_tmp, platform_cfg_tmp = get_platform_configurations( + config_tmp, agents_tmp, platform_cfg_tmp, web_users = get_platform_configurations( get_platform_config_path() ) configure_platform(platform_cfg_tmp, config_tmp) install_agents(agents_tmp) + if web_users: + save_web_users_json_file(**web_users) final_platform_configurations() From b1e142b4f6bb88218c236b0e8a40b9bffb983d3e Mon Sep 17 00:00:00 2001 From: Nathan Tenney Date: Wed, 23 Apr 2025 21:21:43 -0700 Subject: [PATCH 02/29] Modified docker files to use git to clone volttron repo --- Dockerfile | 38 +++++++++++++++++++++++--------------- Dockerfile-dev | 32 ++++++++++++++++++++------------ 2 files changed, 43 insertions(+), 27 deletions(-) diff --git a/Dockerfile b/Dockerfile index 03e0fee..d81bae1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,13 +1,16 @@ ARG image_repo=rust ARG image_tag=bookworm -# + FROM ${image_repo}:${image_tag} AS volttron_base + +ARG volttron_repo=https://github.com/VOLTTRON/volttron.git +ARG volttron_git_branch=main # SHELL [ "bash", "-c" ] # ENV OS_TYPE=debian ENV DIST=bookworm -ENV VOLTTRON_GIT_BRANCH=main +ENV VOLTTRON_GIT_BRANCH=${volttron_git_branch} ENV VOLTTRON_USER_HOME=/home/volttron ENV VOLTTRON_HOME=${VOLTTRON_USER_HOME}/.volttron ENV CODE_ROOT=/code @@ -15,12 +18,12 @@ ENV VOLTTRON_ROOT=${CODE_ROOT}/volttron ENV VOLTTRON_USER=volttron ENV USER_PIP_BIN=${VOLTTRON_USER_HOME}/.local/bin ENV CONFIG=/home/volttron/configs +ENV TZ=UTC ENV LOCAL_USER_ID=1000 #ENV RMQ_ROOT=${VOLTTRON_USER_HOME}/rabbitmq_server #ENV RMQ_HOME=${RMQ_ROOT}/rabbitmq_server-3.7.7 # USER root -# RUN set -eux; apt-get update; apt-get install -y --no-install-recommends \ procps \ gosu \ @@ -45,23 +48,24 @@ RUN set -eux; apt-get update; apt-get install -y --no-install-recommends \ libffi-dev \ sqlite3 # -# Set timezone -RUN echo UTC > /etc/timezone - # Set default 'python' to 'python3' RUN update-alternatives --install /usr/bin/python python /usr/bin/python3 1 + # # Set global.break-system-packages to true to allow pip to install packages # RUN python3 -m pip config set global.break-system-packages true + # # Upgrade pip so that we get a pre-compiled wheel for 'cryptopgraphy', which is a dependency of Volttron # See https://cryptography.io/en/latest/faq/#installing-cryptography-fails-with-error-can-not-find-rust-compiler RUN pip install --upgrade pip + # # Install rust and cargo # RUN rustup default stable + # # Create a user called 'volttron' RUN id -u $VOLTTRON_USER &>/dev/null || adduser --disabled-password --gecos "" $VOLTTRON_USER @@ -74,17 +78,23 @@ RUN mkdir -p /code && chown $VOLTTRON_USER.$VOLTTRON_USER /code && \ # Creating volttron_core stage ############################################ FROM volttron_base AS volttron_core -# + +ARG volttron_repo=https://github.com/VOLTTRON/volttron.git +ARG volttron_git_branch=main + # copy over /core, i.e. the custom startup scripts for this image RUN mkdir /startup $VOLTTRON_HOME && \ chown $VOLTTRON_USER.$VOLTTRON_USER $VOLTTRON_HOME COPY --chown=volttron:volttron ./core /startup RUN chmod +x /startup/* + # # copy over volttron repo USER $VOLTTRON_USER -COPY --chown=volttron:volttron volttron /code/volttron -WORKDIR /code/volttron + +RUN git clone --branch ${volttron_git_branch} --single-branch ${volttron_repo} ${VOLTTRON_ROOT} +WORKDIR ${VOLTTRON_ROOT} + # # Set global.break-system-packages to true to allow pip to install packages # @@ -94,15 +104,13 @@ RUN python3 -m pip config set global.break-system-packages true # See https://cryptography.io/en/latest/faq/#installing-cryptography-fails-with-error-can-not-find-rust-compiler RUN pip install --upgrade pip +# +# Now install volttron required packages +# RUN pip install -e . --user RUN echo "package installed at `date`" -# copy default configs -#COPY --chown=volttron:volttron ./platform_config.yml /platform_config.yml -#COPY --chown=volttron:volttron ./configs /home/volttron/configs - - -## +# ############################################# ## RABBITMQ SPECIFIC INSTALLATION ############################################# diff --git a/Dockerfile-dev b/Dockerfile-dev index c06231c..d2f67d6 100644 --- a/Dockerfile-dev +++ b/Dockerfile-dev @@ -1,19 +1,25 @@ ARG image_repo=rust ARG image_tag=bookworm -# + FROM ${image_repo}:${image_tag} AS volttron_base + +ARG volttron_repo=https://github.com/VOLTTRON/volttron.git +ARG volttron_git_branch=develop # SHELL [ "bash", "-c" ] # ENV OS_TYPE=debian ENV DIST=bookworm -ENV VOLTTRON_GIT_BRANCH=develop +ENV VOLTTRON_GIT_BRANCH=${volttron_git_branch} ENV VOLTTRON_USER_HOME=/home/volttron ENV VOLTTRON_HOME=${VOLTTRON_USER_HOME}/.volttron ENV CODE_ROOT=/code ENV VOLTTRON_ROOT=${CODE_ROOT}/volttron ENV VOLTTRON_USER=volttron ENV USER_PIP_BIN=${VOLTTRON_USER_HOME}/.local/bin +ENV CONFIG=/home/volttron/configs +ENV TZ=UTC +ENV LOCAL_USER_ID=1000 #ENV RMQ_ROOT=${VOLTTRON_USER_HOME}/rabbitmq_server #ENV RMQ_HOME=${RMQ_ROOT}/rabbitmq_server-3.7.7 # @@ -72,15 +78,22 @@ RUN mkdir -p /code && chown $VOLTTRON_USER.$VOLTTRON_USER /code && \ # Creating volttron_core stage ############################################ FROM volttron_base AS volttron_core -# -# make the volttron home directory -RUN mkdir $VOLTTRON_HOME && \ + +ARG volttron_repo=https://github.com/VOLTTRON/volttron.git +ARG volttron_git_branch=develop + +# copy over /core, i.e. the custom startup scripts for this image +RUN mkdir /startup $VOLTTRON_HOME && \ chown $VOLTTRON_USER.$VOLTTRON_USER $VOLTTRON_HOME +COPY --chown=volttron:volttron ./core /startup +RUN chmod +x /startup/* + # # copy over volttron repo USER $VOLTTRON_USER -COPY --chown=volttron:volttron volttron /code/volttron -WORKDIR /code/volttron + +RUN git clone --branch ${volttron_git_branch} --single-branch ${volttron_repo} ${VOLTTRON_ROOT} +WORKDIR ${VOLTTRON_ROOT} # # Set global.break-system-packages to true to allow pip to install packages @@ -97,11 +110,6 @@ RUN pip install --upgrade pip RUN pip install -e . --user RUN echo "package installed at `date`" -# -# Copy the startup files instead of relying on a volume due to needing to use docker build to -# create the image rather than docker-compose build -# -COPY --chown=volttron:volttron core /startup # ############################################# ## RABBITMQ SPECIFIC INSTALLATION From 4ffe8fe9eb7ff93fad42c4f01a6e694032b3c1d8 Mon Sep 17 00:00:00 2001 From: Nathan Tenney Date: Wed, 23 Apr 2025 21:31:14 -0700 Subject: [PATCH 03/29] Removed entry to get the submodule --- .github/workflows/publish_develop_image.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/publish_develop_image.yml b/.github/workflows/publish_develop_image.yml index 8dab9d8..15092d5 100644 --- a/.github/workflows/publish_develop_image.yml +++ b/.github/workflows/publish_develop_image.yml @@ -26,9 +26,6 @@ jobs: - name: Check out the repo uses: actions/checkout@v4 - - name: Clone submodule - run: git submodule update --init --recursive - - name: Set up QEMU uses: docker/setup-qemu-action@v1 From 69bdde779eeb106c77a89442705f79b4ca566728 Mon Sep 17 00:00:00 2001 From: Nathan Tenney Date: Wed, 23 Apr 2025 21:33:01 -0700 Subject: [PATCH 04/29] Removed volttron submodule, and entry in actions to update it --- .gitmodules | 4 ---- volttron | 1 - 2 files changed, 5 deletions(-) delete mode 160000 volttron diff --git a/.gitmodules b/.gitmodules index b8dc76a..e69de29 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,4 +0,0 @@ -[submodule "volttron"] - path = volttron - url = https://github.com/volttron/volttron - branch = main diff --git a/volttron b/volttron deleted file mode 160000 index a537ca0..0000000 --- a/volttron +++ /dev/null @@ -1 +0,0 @@ -Subproject commit a537ca0d19fba2e6466d9d97698992d2fd664d60 From 78d5f7180f49593f862c99e2266d7f6ec4aebeff Mon Sep 17 00:00:00 2001 From: Nathan Tenney Date: Thu, 24 Apr 2025 01:36:19 -0700 Subject: [PATCH 05/29] Updated README.md file --- README.md | 33 +++++++++++---------------------- 1 file changed, 11 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index 710776a..accbc16 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,7 @@ docker-compose script with the updated image name that uses the tag as part of its name. # Example below -$ docker build -t eclipsevolttron/volttron: --build-arg install_rmq=false --no-cache . +$ docker buildx build -t eclipsevolttron/volttron: --build-arg install_rmq=false --no-cache . # Create and start the container that has runs Volttron $ docker-compose up @@ -154,32 +154,21 @@ To set up your environment for development, do the following: chmod a+x core/* ``` -1. Pull in volttron from the [official volttron repo](https://github.com/VOLTTRON/volttron) using the following git command: +1. Build the image locally: +* Using docker buildx (preferred) ```bash -# Clones https://github.com/VOLTTRON/volttron.git into the 'volttron' directory -git submodule update --init --recursive +docker buildx build -f Dockerfile-dev --no-cache --force-rm . ``` -Why are we doing this? This repo has a directory called 'volttron', which contains the volttron codebase. In other words, this repo contains another repo in a subfolder. -When you initially clone this repo, the 'volttron' directory is empty. This directory contains the volttron codebase used to create the volttron platform. +* Dockerfile will clone the volttron repository in the image from https://github.com/VOLTTRON/volttron.git + and defaults to the main branch. Dockerfile-dev defaults to the develop branch. Other than that, they are + identical. If you would like to use a different repository, or branch, you can set the following build + arguments (specified with the --build-arg flag): + - volttron_repo: The repository to clone. Use the https URL for the repo. + - volttron_git_branch: The branch or tag to clone. Defaults to main. -OPTIONAL: This repo uses a specific version of volttron based on the commit in the 'volttron' submodule. If you want to use the latest volttron from the `develop` -branch from the volttron repo, execute the following command (NOTE: this is not required): - -```bash -# Ensure that you are in the `volttron` folder -git pull origin develop -``` - -2. Build the image locally: - -* Using docker-compose (preferred) -```bash -docker-compose -f docker-compose-dev.yml build --no-cache --force-rm -``` - -3. Run the container: +2. Run the container: * Using docker-compose (preferred) ``` From 0d43ce9397207e7fc73ffaa0fd5fa36d56fc691b Mon Sep 17 00:00:00 2001 From: Nathan Tenney Date: Fri, 25 Apr 2025 00:11:24 -0700 Subject: [PATCH 06/29] Added environment variable for specifying the dockerfile --- .github/workflows/publish_develop_image.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/publish_develop_image.yml b/.github/workflows/publish_develop_image.yml index 15092d5..8aeb310 100644 --- a/.github/workflows/publish_develop_image.yml +++ b/.github/workflows/publish_develop_image.yml @@ -47,6 +47,7 @@ jobs: uses: docker/build-push-action@v2 with: context: . + file: ${{ env.DOCKERFILE || './Dockerfile' }} push: true tags: | ${{ env.IMAGE_BASE_NAME }}:develop From f140fe4f8f56a1f247bfa10efbc4d9c0ed5ed7d5 Mon Sep 17 00:00:00 2001 From: Nathan Tenney Date: Mon, 28 Apr 2025 13:18:46 -0700 Subject: [PATCH 07/29] Added example of using build arguments for the repo and branch --- README.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index accbc16..902e2ca 100644 --- a/README.md +++ b/README.md @@ -158,7 +158,7 @@ chmod a+x core/* * Using docker buildx (preferred) ```bash -docker buildx build -f Dockerfile-dev --no-cache --force-rm . +docker buildx build -f Dockerfile-dev --no-cache --force-rm -t user/inagename:tag . ``` * Dockerfile will clone the volttron repository in the image from https://github.com/VOLTTRON/volttron.git @@ -168,6 +168,10 @@ docker buildx build -f Dockerfile-dev --no-cache --force-rm . - volttron_repo: The repository to clone. Use the https URL for the repo. - volttron_git_branch: The branch or tag to clone. Defaults to main. +```bash +docker buildx build -f Dockerfile-dev --no-cache --force-rm --build-arg volttron_repo=https://github.com/myuser/volttron-docker-fork.git --build-arg volttron_git_branch=feature123 -t user/inagename:tag . +``` + 2. Run the container: * Using docker-compose (preferred) From 68a9cf57a684099cee47b7f831b25f68f311010d Mon Sep 17 00:00:00 2001 From: Nathan Tenney Date: Mon, 28 Apr 2025 13:22:38 -0700 Subject: [PATCH 08/29] Split comand line so that it is more readable --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 902e2ca..2a48bad 100644 --- a/README.md +++ b/README.md @@ -169,7 +169,9 @@ docker buildx build -f Dockerfile-dev --no-cache --force-rm -t user/inagename:ta - volttron_git_branch: The branch or tag to clone. Defaults to main. ```bash -docker buildx build -f Dockerfile-dev --no-cache --force-rm --build-arg volttron_repo=https://github.com/myuser/volttron-docker-fork.git --build-arg volttron_git_branch=feature123 -t user/inagename:tag . +docker buildx build -f Dockerfile-dev --no-cache --force-rm \ + --build-arg volttron_repo=https://github.com/myuser/volttron-docker-fork.git \ + --build-arg volttron_git_branch=feature123 -t user/inagename:tag . ``` 2. Run the container: From 4c0232f3a8caa86812a92c78b4740325bb1c878e Mon Sep 17 00:00:00 2001 From: Nathan Tenney Date: Wed, 14 May 2025 14:44:32 -0700 Subject: [PATCH 09/29] Added platforms to build arm64 and amd64 images --- .github/workflows/create_release.yml | 3 +++ .github/workflows/publish_develop_image.yml | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/create_release.yml b/.github/workflows/create_release.yml index 11e1ea7..35227ae 100644 --- a/.github/workflows/create_release.yml +++ b/.github/workflows/create_release.yml @@ -93,6 +93,8 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v1 + with: + platforms: linux/amd64,linux/arm64 # Ensure that the repo has the username and token added from the # official Volttron Dockerhub page at https://hub.docker.com/repository/docker/eclipsevolttron/volttron/general @@ -109,6 +111,7 @@ jobs: uses: docker/build-push-action@v2 with: context: . + platforms: linux/amd64,linux/arm64 push: true tags: | ${{ env.IMAGE_BASE_NAME }}:${{ env.VERSION }} diff --git a/.github/workflows/publish_develop_image.yml b/.github/workflows/publish_develop_image.yml index 8aeb310..184d86f 100644 --- a/.github/workflows/publish_develop_image.yml +++ b/.github/workflows/publish_develop_image.yml @@ -11,7 +11,7 @@ on: types: [opened, reopened, synchronize] env: # Image name on Volttron DockerHub account at https://hub.docker.com/orgs/eclipsevolttron - IMAGE_BASE_NAME: eclipsevolttron/volttron + IMAGE_BASE_NAME: ${{env.IMAGE_BASE_NAME || eclipsevolttron/volttron}} jobs: publish_develop_to_dhub: @@ -31,6 +31,8 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v1 + with: + platforms: linux/amd64,linux/arm64 # Ensure that the repo has the username and token added from the # official Volttron Dockerhub page at https://hub.docker.com/repository/docker/eclipsevolttron/volttron/general @@ -48,6 +50,7 @@ jobs: with: context: . file: ${{ env.DOCKERFILE || './Dockerfile' }} + platforms: linux/amd64,linux/arm64 push: true tags: | ${{ env.IMAGE_BASE_NAME }}:develop From 34cd374fefc3b0e837e24597379a85ee0df63a7c Mon Sep 17 00:00:00 2001 From: Nathan Tenney Date: Wed, 14 May 2025 14:49:06 -0700 Subject: [PATCH 10/29] Fix IMAGE_BASE_NAME --- .github/workflows/publish_develop_image.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish_develop_image.yml b/.github/workflows/publish_develop_image.yml index 184d86f..ba1c8bf 100644 --- a/.github/workflows/publish_develop_image.yml +++ b/.github/workflows/publish_develop_image.yml @@ -11,7 +11,7 @@ on: types: [opened, reopened, synchronize] env: # Image name on Volttron DockerHub account at https://hub.docker.com/orgs/eclipsevolttron - IMAGE_BASE_NAME: ${{env.IMAGE_BASE_NAME || eclipsevolttron/volttron}} + IMAGE_BASE_NAME: ${{env.IMAGE_BASE_NAME || 'eclipsevolttron/volttron'}} jobs: publish_develop_to_dhub: From 811e3766db83fbaa142d248ef40baa1d399aaa05 Mon Sep 17 00:00:00 2001 From: Nathan Tenney Date: Wed, 14 May 2025 14:56:02 -0700 Subject: [PATCH 11/29] Fix IMAGE_BASE_NAME part 2 --- .github/workflows/publish_develop_image.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish_develop_image.yml b/.github/workflows/publish_develop_image.yml index ba1c8bf..661193a 100644 --- a/.github/workflows/publish_develop_image.yml +++ b/.github/workflows/publish_develop_image.yml @@ -11,7 +11,7 @@ on: types: [opened, reopened, synchronize] env: # Image name on Volttron DockerHub account at https://hub.docker.com/orgs/eclipsevolttron - IMAGE_BASE_NAME: ${{env.IMAGE_BASE_NAME || 'eclipsevolttron/volttron'}} + IMAGE_BASE_NAME: ${{vars.IMAGE_BASE_NAME || 'eclipsevolttron/volttron'}} jobs: publish_develop_to_dhub: From 9c4b242775875c1d3663f14ae2bdd8a13160770a Mon Sep 17 00:00:00 2001 From: Nathan Tenney Date: Wed, 14 May 2025 16:03:30 -0700 Subject: [PATCH 12/29] Update the ubuntu version of the image used to run the build --- .github/workflows/create_release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/create_release.yml b/.github/workflows/create_release.yml index 35227ae..cdbf385 100644 --- a/.github/workflows/create_release.yml +++ b/.github/workflows/create_release.yml @@ -14,7 +14,7 @@ env: jobs: create_release_publish_to_dhub: - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 steps: - run: echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event." From 0f3983ee06ba9299e2303f575576368c2df2e6ec Mon Sep 17 00:00:00 2001 From: Nathan Tenney Date: Wed, 14 May 2025 18:02:42 -0700 Subject: [PATCH 13/29] Added build args for git repo and branch --- .github/workflows/publish_develop_image.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/publish_develop_image.yml b/.github/workflows/publish_develop_image.yml index 661193a..d93b697 100644 --- a/.github/workflows/publish_develop_image.yml +++ b/.github/workflows/publish_develop_image.yml @@ -12,6 +12,8 @@ on: env: # Image name on Volttron DockerHub account at https://hub.docker.com/orgs/eclipsevolttron IMAGE_BASE_NAME: ${{vars.IMAGE_BASE_NAME || 'eclipsevolttron/volttron'}} + VOLTTRON_GIT_REPO: ${{vars.VOLTTRON_GIT_REPO || 'https://github.com/VOLTTRON/volttron.git'}} + VOLTTRON_GIT_BRANCH: ${{vars.VOLTTRON_GIT_BRANCH || 'develop'}} jobs: publish_develop_to_dhub: @@ -51,6 +53,9 @@ jobs: context: . file: ${{ env.DOCKERFILE || './Dockerfile' }} platforms: linux/amd64,linux/arm64 + build-args: + volttron_git_branch: ${{ env.VOLTTRON_GIT_BRANCH }} + volttron_repo: ${{ env.VOLTTRON_GIT_REPO }} push: true tags: | ${{ env.IMAGE_BASE_NAME }}:develop From 9fd0476dcbcb4ec897a8d6d78522ed5779b65c10 Mon Sep 17 00:00:00 2001 From: Nathan Tenney Date: Wed, 14 May 2025 18:07:30 -0700 Subject: [PATCH 14/29] Fix for git repo and branch --- .github/workflows/publish_develop_image.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/publish_develop_image.yml b/.github/workflows/publish_develop_image.yml index d93b697..3436c08 100644 --- a/.github/workflows/publish_develop_image.yml +++ b/.github/workflows/publish_develop_image.yml @@ -53,9 +53,9 @@ jobs: context: . file: ${{ env.DOCKERFILE || './Dockerfile' }} platforms: linux/amd64,linux/arm64 - build-args: - volttron_git_branch: ${{ env.VOLTTRON_GIT_BRANCH }} - volttron_repo: ${{ env.VOLTTRON_GIT_REPO }} + build-args: | + volttron_git_branch=${{ env.VOLTTRON_GIT_BRANCH }} + volttron_repo=${{ env.VOLTTRON_GIT_REPO }} push: true tags: | ${{ env.IMAGE_BASE_NAME }}:develop From 7b4c0e3c703faf0b1f8447a1486ba896acf14591 Mon Sep 17 00:00:00 2001 From: Nathan Tenney Date: Wed, 14 May 2025 23:56:25 -0700 Subject: [PATCH 15/29] Added variable expansion for the docker image tag --- .github/workflows/publish_develop_image.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/publish_develop_image.yml b/.github/workflows/publish_develop_image.yml index 3436c08..18e553c 100644 --- a/.github/workflows/publish_develop_image.yml +++ b/.github/workflows/publish_develop_image.yml @@ -12,6 +12,7 @@ on: env: # Image name on Volttron DockerHub account at https://hub.docker.com/orgs/eclipsevolttron IMAGE_BASE_NAME: ${{vars.IMAGE_BASE_NAME || 'eclipsevolttron/volttron'}} + IMAGE_TAG: ${{vars.IMAGE_TAG || 'develop'}} VOLTTRON_GIT_REPO: ${{vars.VOLTTRON_GIT_REPO || 'https://github.com/VOLTTRON/volttron.git'}} VOLTTRON_GIT_BRANCH: ${{vars.VOLTTRON_GIT_BRANCH || 'develop'}} @@ -58,7 +59,7 @@ jobs: volttron_repo=${{ env.VOLTTRON_GIT_REPO }} push: true tags: | - ${{ env.IMAGE_BASE_NAME }}:develop + ${{ env.IMAGE_BASE_NAME }}:${{ env.IMAGE_TAG }} - name: Check image publish if: steps.docker_build.outputs.digest == '' From 3e2c523be4f6c5bae3a9381a05e978e1cb6647eb Mon Sep 17 00:00:00 2001 From: Nathan Tenney Date: Thu, 15 May 2025 07:21:59 -0700 Subject: [PATCH 16/29] Added changes from pre-commit hooks --- README.md | 8 ++++---- core/setup-platform.py | 15 +++++++++------ 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 2a48bad..45ba140 100644 --- a/README.md +++ b/README.md @@ -161,12 +161,12 @@ chmod a+x core/* docker buildx build -f Dockerfile-dev --no-cache --force-rm -t user/inagename:tag . ``` -* Dockerfile will clone the volttron repository in the image from https://github.com/VOLTTRON/volttron.git - and defaults to the main branch. Dockerfile-dev defaults to the develop branch. Other than that, they are - identical. If you would like to use a different repository, or branch, you can set the following build +* Dockerfile will clone the volttron repository in the image from https://github.com/VOLTTRON/volttron.git + and defaults to the main branch. Dockerfile-dev defaults to the develop branch. Other than that, they are + identical. If you would like to use a different repository, or branch, you can set the following build arguments (specified with the --build-arg flag): - volttron_repo: The repository to clone. Use the https URL for the repo. - - volttron_git_branch: The branch or tag to clone. Defaults to main. + - volttron_git_branch: The branch or tag to clone. Defaults to main. ```bash docker buildx build -f Dockerfile-dev --no-cache --force-rm \ diff --git a/core/setup-platform.py b/core/setup-platform.py index c7aa62d..fc74172 100755 --- a/core/setup-platform.py +++ b/core/setup-platform.py @@ -364,20 +364,23 @@ def final_platform_configurations(): sleep(5) sys.exit(0) + def create_web_map(username, password, groups=None, return_json=False): from passlib.hash import argon2 - groups = groups if isinstance(groups, list) else [groups] if groups else ['admin', 'vui'] + + groups = ( + groups if isinstance(groups, list) else [groups] if groups else ["admin", "vui"] + ) web_users_dict = { - username: { - "hashed_password": argon2.hash(password), - "groups": groups - } + username: {"hashed_password": argon2.hash(password), "groups": groups} } return web_users_dict if not return_json else json.dumps(web_users_dict) + def save_web_users_json_file(username, password, groups=None): from pathlib import Path - with open(Path(VOLTTRON_HOME)/'web-users.json', 'w') as f: + + with open(Path(VOLTTRON_HOME) / "web-users.json", "w") as f: json.dump(create_web_map(username, password, groups), f) From fe24b77fcc5b94eae424fc55cf2ee1be85d29d1b Mon Sep 17 00:00:00 2001 From: Nathan Tenney Date: Thu, 15 May 2025 09:41:25 -0700 Subject: [PATCH 17/29] Updated login action version --- .github/workflows/publish_develop_image.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish_develop_image.yml b/.github/workflows/publish_develop_image.yml index 18e553c..ffce649 100644 --- a/.github/workflows/publish_develop_image.yml +++ b/.github/workflows/publish_develop_image.yml @@ -42,7 +42,7 @@ jobs: # On instructions how to do this, see https://docs.github.com/en/actions/guides/publishing-docker-images # https://github.com/docker/login-action - name: Login to DockerHub - uses: docker/login-action@v1 + uses: docker/login-action@v3 with: username: ${{ secrets.DOCKER_USER }} password: ${{ secrets.DOCKER_API_TOKEN }} From 81a214a0e91687bd2c15349062dded35e9aa796c Mon Sep 17 00:00:00 2001 From: Nathan Tenney Date: Thu, 15 May 2025 10:04:23 -0700 Subject: [PATCH 18/29] Fixes for running the image tests --- .github/workflows/publish_develop_image.yml | 2 +- docker-compose-dev.yml | 2 +- docker-compose-test.yml | 1 + run-test-docker-image.sh | 6 +++--- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/workflows/publish_develop_image.yml b/.github/workflows/publish_develop_image.yml index ffce649..c1418df 100644 --- a/.github/workflows/publish_develop_image.yml +++ b/.github/workflows/publish_develop_image.yml @@ -44,7 +44,7 @@ jobs: - name: Login to DockerHub uses: docker/login-action@v3 with: - username: ${{ secrets.DOCKER_USER }} + username: ${{ var.DOCKER_USER }} password: ${{ secrets.DOCKER_API_TOKEN }} - name: Build and push diff --git a/docker-compose-dev.yml b/docker-compose-dev.yml index ef12cd2..3c5773d 100644 --- a/docker-compose-dev.yml +++ b/docker-compose-dev.yml @@ -8,7 +8,7 @@ services: dockerfile: Dockerfile-dev args: install_rmq: 'false' - image: eclipsevolttron/volttron:v-docker-dev-latest + image: eclipsevolttron/volttron:develop ports: # host_port:container_port # http port for volttron central diff --git a/docker-compose-test.yml b/docker-compose-test.yml index 57b8733..31ef0d3 100644 --- a/docker-compose-test.yml +++ b/docker-compose-test.yml @@ -16,6 +16,7 @@ services: environment: - CONFIG=/home/volttron/configs - LOCAL_USER_ID=1000 + - TZ=America/Los_Angeles volumes: volttron1-volume: diff --git a/run-test-docker-image.sh b/run-test-docker-image.sh index 506d241..023ead2 100755 --- a/run-test-docker-image.sh +++ b/run-test-docker-image.sh @@ -14,7 +14,7 @@ exit_cleanly() { exit_test() { echo -e "$1" docker logs --tail 25 volttron1 - docker-compose down + docker compose down exit_cleanly } @@ -62,7 +62,7 @@ attempts=5 echo "Will try at most ${attempts} attempts to start container..." while [ "${attempts}" -gt 0 ]; do echo "Attempt number ${attempts} to start container." - docker-compose --file docker-compose-test.yml up --detach + docker compose --file docker-compose-test.yml up --detach echo "Configuring and starting Volttron platform; this will take approximately several minutes........" sleep ${wait} docker ps --filter "name=volttron1" --filter "status=running" | grep 'volttron1' @@ -70,7 +70,7 @@ while [ "${attempts}" -gt 0 ]; do if [ "${tmp_code}" -eq 1 ]; then echo "Container failed to start." docker logs --tail 20 volttron1 - docker-compose down + docker compose down ((attempts=attempts-1)) else # Container was successfully created From b7af6a883cbcba5d7045fa3a90ce178dec993a01 Mon Sep 17 00:00:00 2001 From: Nathan Tenney Date: Thu, 15 May 2025 10:06:57 -0700 Subject: [PATCH 19/29] Fixed typo in move to using vars for docker_user --- .github/workflows/publish_develop_image.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish_develop_image.yml b/.github/workflows/publish_develop_image.yml index c1418df..4c84c44 100644 --- a/.github/workflows/publish_develop_image.yml +++ b/.github/workflows/publish_develop_image.yml @@ -44,7 +44,7 @@ jobs: - name: Login to DockerHub uses: docker/login-action@v3 with: - username: ${{ var.DOCKER_USER }} + username: ${{ vars.DOCKER_USER }} password: ${{ secrets.DOCKER_API_TOKEN }} - name: Build and push From 5403f118cdc8078506e0be102de8d0f5d4a3ef08 Mon Sep 17 00:00:00 2001 From: Nathan Tenney Date: Thu, 15 May 2025 21:47:29 -0700 Subject: [PATCH 20/29] Set the default docker image tag for publish_develop_image.yml action to test-build --- .github/workflows/publish_develop_image.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish_develop_image.yml b/.github/workflows/publish_develop_image.yml index 4c84c44..3f1d44f 100644 --- a/.github/workflows/publish_develop_image.yml +++ b/.github/workflows/publish_develop_image.yml @@ -12,7 +12,7 @@ on: env: # Image name on Volttron DockerHub account at https://hub.docker.com/orgs/eclipsevolttron IMAGE_BASE_NAME: ${{vars.IMAGE_BASE_NAME || 'eclipsevolttron/volttron'}} - IMAGE_TAG: ${{vars.IMAGE_TAG || 'develop'}} + IMAGE_TAG: ${{vars.IMAGE_TAG || 'test-build'}} VOLTTRON_GIT_REPO: ${{vars.VOLTTRON_GIT_REPO || 'https://github.com/VOLTTRON/volttron.git'}} VOLTTRON_GIT_BRANCH: ${{vars.VOLTTRON_GIT_BRANCH || 'develop'}} From f77e0f32fd958d64190bbe6031207bf77d318f89 Mon Sep 17 00:00:00 2001 From: Nathan Tenney Date: Thu, 15 May 2025 22:24:39 -0700 Subject: [PATCH 21/29] Testing variables --- .github/workflows/publish_develop_image.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish_develop_image.yml b/.github/workflows/publish_develop_image.yml index 3f1d44f..64f3ce2 100644 --- a/.github/workflows/publish_develop_image.yml +++ b/.github/workflows/publish_develop_image.yml @@ -12,7 +12,7 @@ on: env: # Image name on Volttron DockerHub account at https://hub.docker.com/orgs/eclipsevolttron IMAGE_BASE_NAME: ${{vars.IMAGE_BASE_NAME || 'eclipsevolttron/volttron'}} - IMAGE_TAG: ${{vars.IMAGE_TAG || 'test-build'}} + IMAGE_TAG: ${{env.IMAGE_TAG || 'test-build'}} VOLTTRON_GIT_REPO: ${{vars.VOLTTRON_GIT_REPO || 'https://github.com/VOLTTRON/volttron.git'}} VOLTTRON_GIT_BRANCH: ${{vars.VOLTTRON_GIT_BRANCH || 'develop'}} From 668910d1fe22e573dadcdd424dfeef46f3ea6a60 Mon Sep 17 00:00:00 2001 From: Nathan Tenney Date: Thu, 15 May 2025 23:15:34 -0700 Subject: [PATCH 22/29] testing setting the image tag based on the branch --- .github/workflows/publish_develop_image.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish_develop_image.yml b/.github/workflows/publish_develop_image.yml index 64f3ce2..49e84c4 100644 --- a/.github/workflows/publish_develop_image.yml +++ b/.github/workflows/publish_develop_image.yml @@ -12,7 +12,7 @@ on: env: # Image name on Volttron DockerHub account at https://hub.docker.com/orgs/eclipsevolttron IMAGE_BASE_NAME: ${{vars.IMAGE_BASE_NAME || 'eclipsevolttron/volttron'}} - IMAGE_TAG: ${{env.IMAGE_TAG || 'test-build'}} + IMAGE_TAG: ${{ vars.IMAGE_TAG || github.ref == 'refs/heads/develop' && 'develop || 'test-build'}} VOLTTRON_GIT_REPO: ${{vars.VOLTTRON_GIT_REPO || 'https://github.com/VOLTTRON/volttron.git'}} VOLTTRON_GIT_BRANCH: ${{vars.VOLTTRON_GIT_BRANCH || 'develop'}} From 8a2346eee3fecf19067322f5507011e217a7d6d0 Mon Sep 17 00:00:00 2001 From: Nathan Tenney Date: Thu, 15 May 2025 23:20:26 -0700 Subject: [PATCH 23/29] Fix typo --- .github/workflows/publish_develop_image.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish_develop_image.yml b/.github/workflows/publish_develop_image.yml index 49e84c4..f7dc437 100644 --- a/.github/workflows/publish_develop_image.yml +++ b/.github/workflows/publish_develop_image.yml @@ -12,7 +12,7 @@ on: env: # Image name on Volttron DockerHub account at https://hub.docker.com/orgs/eclipsevolttron IMAGE_BASE_NAME: ${{vars.IMAGE_BASE_NAME || 'eclipsevolttron/volttron'}} - IMAGE_TAG: ${{ vars.IMAGE_TAG || github.ref == 'refs/heads/develop' && 'develop || 'test-build'}} + IMAGE_TAG: ${{ vars.IMAGE_TAG || github.ref == 'refs/heads/develop' && 'develop' || 'test-build'}} VOLTTRON_GIT_REPO: ${{vars.VOLTTRON_GIT_REPO || 'https://github.com/VOLTTRON/volttron.git'}} VOLTTRON_GIT_BRANCH: ${{vars.VOLTTRON_GIT_BRANCH || 'develop'}} From 4a22893b164c4a1b90657bb5446027666e17da67 Mon Sep 17 00:00:00 2001 From: Nathan Tenney Date: Fri, 16 May 2025 11:12:40 -0700 Subject: [PATCH 24/29] Fixed image name in docker-copmpose.yml file. Additional clean up of README files. --- README.md | 26 +++++++++++++------------- README_DHUB.md | 2 +- docker-compose.yml | 2 +- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 45ba140..51fae4d 100644 --- a/README.md +++ b/README.md @@ -11,9 +11,9 @@ In conjunction with volume mounting of the directory, this ensures that file own # Prerequisites * Docker ^20.10.8 -* Docker-compose ^1.29.2 +* Docker compose ^1.29.2 -If you need to install docker and/or docker-compose AND you are running this image on an Ubuntu machine, you can use the script in this repo. From the root level, execute the following command: +If you need to install docker and/or docker compose AND you are running this image on an Ubuntu machine, you can use the script in this repo. From the root level, execute the following command: ```bash $ ./docker_install_ubuntu.sh @@ -26,29 +26,29 @@ To create the container and start using the platform on the container, run the f ``` # Build the image locally. Set to some tag. Then update the -docker-compose script with the updated image name that uses the tag as part of +docker compose script with the updated image name that uses the tag as part of its name. # Example below $ docker buildx build -t eclipsevolttron/volttron: --build-arg install_rmq=false --no-cache . # Create and start the container that has runs Volttron -$ docker-compose up +$ docker compose up # SSH into the container as the user 'volttron' $ docker exec -itu volttron volttron1 bash # Stop the container -$ docker-compose stop +$ docker compose stop # Start the container -$ docker-compose start +$ docker compose start -# To get a list of all containers created from docker-compose -$ docker-compose ps +# To get a list of all containers created from docker compose +$ docker compose ps # To stop and remove the container -$ docker-compose down +$ docker compose down ``` For Volttron instances using ZMQ message bus: @@ -139,9 +139,9 @@ Agents within the `platform_config.yml` file are created sequentially, it can ta # Development If you plan on extending or developing `platform_config.yml`, `configs/`, or the setup scripts in `core/`, build the -Docker image, "Dockerfile-dev", only once using `docker-compose -f docker-compose-dev.yml build --no-cache volttron1`. +Docker image, "Dockerfile-dev", only once using `docker compose -f docker-compose-dev.yml build --no-cache volttron1`. -Then start the container using `docker-compose -f docker-compose-dev.yml up`. When you want to make changes to "platform_config.yml", "configs/", or +Then start the container using `docker compose -f docker-compose-dev.yml up`. When you want to make changes to "platform_config.yml", "configs/", or "core/", simply make the changes and then rerun your container. You do not have to rebuild the image every time you make changes to those aforementioned files and folders because they are mounted into the container. The only time you should rebuild the image is when you make changes to the "volttron" source code since that is not mounted to the container but rather baked into the image during @@ -176,9 +176,9 @@ docker buildx build -f Dockerfile-dev --no-cache --force-rm \ 2. Run the container: -* Using docker-compose (preferred) +* Using docker compose (preferred) ``` -docker-compose -f docker-compose-dev.yml up +docker compose -f docker-compose-dev.yml up ``` ## Testing diff --git a/README_DHUB.md b/README_DHUB.md index 7d33ecb..2122514 100644 --- a/README_DHUB.md +++ b/README_DHUB.md @@ -83,7 +83,7 @@ eclipsevolttron/volttron:v3.0 If you don't want to type a long `docker run` command every time you run a container, you can wrap your command in a docker-compose script. See this example from (docker-compose.yml)[https://github.com/VOLTTRON/volttron-docker/blob/main/docker-compose.yml]. Note that you still need to ensure that the paths to the bind-mounts are properly constructed. After you create your docker-compose script, -run `docker-compose run` in the same directory that holds your script. +run `docker compose run` in the same directory that holds your script. ```shell version: '3.4' diff --git a/docker-compose.yml b/docker-compose.yml index 5893f76..15b3ee3 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -4,7 +4,7 @@ services: volttron1: container_name: volttron1 hostname: volttron1 - image: volttroncommunity/volttron:v9.0-zmq + image: eclipsevolttron/volttron:latest ports: # host_port:container_port # http port for volttron central From 7bf03c6c299448726e69b9f8b55a56d65c99e9b1 Mon Sep 17 00:00:00 2001 From: Nathan Tenney Date: Fri, 16 May 2025 11:25:29 -0700 Subject: [PATCH 25/29] Changed out dockerhub log in process --- .github/workflows/publish_develop_image.yml | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/.github/workflows/publish_develop_image.yml b/.github/workflows/publish_develop_image.yml index f7dc437..ec507ca 100644 --- a/.github/workflows/publish_develop_image.yml +++ b/.github/workflows/publish_develop_image.yml @@ -41,11 +41,24 @@ jobs: # official Volttron Dockerhub page at https://hub.docker.com/repository/docker/eclipsevolttron/volttron/general # On instructions how to do this, see https://docs.github.com/en/actions/guides/publishing-docker-images # https://github.com/docker/login-action +# - name: Login to DockerHub +# uses: docker/login-action@v3 +# with: +# username: ${{ vars.DOCKER_USER }} +# password: ${{ secrets.DOCKER_API_TOKEN }} - name: Login to DockerHub - uses: docker/login-action@v3 - with: - username: ${{ vars.DOCKER_USER }} - password: ${{ secrets.DOCKER_API_TOKEN }} + run: | + if [ -n "${{ vars.DOCKER_USER }}" -a -n "${{ secrets.DOCKER_API_TOKEN }}" ]; then + echo " " + echo "Connecting to docker" + + echo "${{ secrets.DOCKER_API_TOKEN }}" | docker login -u "${{ vars.DOCKER_USER }}" --password-stdin + status=$? + if [ $status -ne 0 ]; then + echo "Error: status $status" + exit 1 + fi + fi - name: Build and push id: docker_build From 7833e0b8358a17a50e499d1c970375b6c9ab08b7 Mon Sep 17 00:00:00 2001 From: Nathan Tenney Date: Fri, 16 May 2025 13:22:46 -0700 Subject: [PATCH 26/29] Changes due to pre-commit hooks --- .github/workflows/publish_develop_image.yml | 2 +- README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/publish_develop_image.yml b/.github/workflows/publish_develop_image.yml index ec507ca..85620b2 100644 --- a/.github/workflows/publish_develop_image.yml +++ b/.github/workflows/publish_develop_image.yml @@ -51,7 +51,7 @@ jobs: if [ -n "${{ vars.DOCKER_USER }}" -a -n "${{ secrets.DOCKER_API_TOKEN }}" ]; then echo " " echo "Connecting to docker" - + echo "${{ secrets.DOCKER_API_TOKEN }}" | docker login -u "${{ vars.DOCKER_USER }}" --password-stdin status=$? if [ $status -ne 0 ]; then diff --git a/README.md b/README.md index 51fae4d..f1b315c 100644 --- a/README.md +++ b/README.md @@ -44,7 +44,7 @@ $ docker compose stop # Start the container $ docker compose start -# To get a list of all containers created from docker compose +# To get a list of all containers created from docker compose $ docker compose ps # To stop and remove the container From dbf73451bf1c2db6062154b53881c4a5f17b06b9 Mon Sep 17 00:00:00 2001 From: Nathan Tenney Date: Fri, 16 May 2025 17:31:38 -0700 Subject: [PATCH 27/29] switched out docker build for run commands --- .github/workflows/publish_develop_image.yml | 58 ++++++++++++--------- 1 file changed, 34 insertions(+), 24 deletions(-) diff --git a/.github/workflows/publish_develop_image.yml b/.github/workflows/publish_develop_image.yml index 85620b2..27eeded 100644 --- a/.github/workflows/publish_develop_image.yml +++ b/.github/workflows/publish_develop_image.yml @@ -60,35 +60,45 @@ jobs: fi fi - - name: Build and push + - name: Build Image id: docker_build - uses: docker/build-push-action@v2 - with: - context: . - file: ${{ env.DOCKERFILE || './Dockerfile' }} - platforms: linux/amd64,linux/arm64 - build-args: | - volttron_git_branch=${{ env.VOLTTRON_GIT_BRANCH }} - volttron_repo=${{ env.VOLTTRON_GIT_REPO }} - push: true - tags: | - ${{ env.IMAGE_BASE_NAME }}:${{ env.IMAGE_TAG }} + run: | + echo "Building image" + echo "docker buildx build \ + --build-arg volttron_git_branch=${{ env.VOLTTRON_GIT_BRANCH }} \ + --build-arg volttron_repo=${{ env.VOLTTRON_GIT_REPO }} \ + --platform linux/amd64,linux/arm64 \ + -t ${{ env.IMAGE_BASE_NAME }}:${{ env.IMAGE_TAG }} \ + -f ${{ env.DOCKERFILE || './Dockerfile' }} --no-cache --force-rm ." + docker buildx build \ + --build-arg volttron_git_branch=${{ env.VOLTTRON_GIT_BRANCH }} \ + --build-arg volttron_repo=${{ env.VOLTTRON_GIT_REPO }} \ + --platform linux/amd64,linux/arm64 \ + -t ${{ env.IMAGE_BASE_NAME }}:${{ env.IMAGE_TAG }} \ + -f ${{ env.DOCKERFILE || './Dockerfile' }} --no-cache --force-rm . + status=$? + if [ $status -ne 0 ]; then + echo "Error: status $status" + exit 1 + fi + + - name: Push Image + id: docker_push + run: | + echo "Pushing image" + echo "docker push ${{ env.IMAGE_BASE_NAME }}:${{ env.IMAGE_TAG }}" + echo "digest=$(docker push ${{ env.IMAGE_BASE_NAME }}:${{ env.IMAGE_TAG }} | tail -n 1)\n" >> $GITHUB_OUTPUT + status=$? + if [ $status -ne 0 ]; then + echo "Error: status $status" + exit 1 + fi - name: Check image publish - if: steps.docker_build.outputs.digest == '' + if: steps.docker_push.outputs.digest == '' run: exit 1 - name: Image Digest - run: echo ${{ steps.docker_build.outputs.digest }} - - # https://github.com/marketplace/actions/docker-hub-description - # Currently doesn't work with personal access tokens; see https://github.com/peter-evans/dockerhub-description/issues/10 - # when fixed, uncomment this step -# - name: Update DockerHub repo README -# uses: peter-evans/dockerhub-description@v2 -# with: -# username: ${{ secrets.DOCKER_USER }} -# password: ${{ secrets.DOCKER_PASSWORD }} -# readme-filepath: ./README_DHUB.md + run: echo ${{ steps.docker_push.outputs.digest }} - run: echo "🍏 This job's status is ${{ job.status }}." From 9b2f09c572a3f4528fa0edb1af47317736978e6c Mon Sep 17 00:00:00 2001 From: Nathan Tenney Date: Mon, 19 May 2025 00:33:56 -0700 Subject: [PATCH 28/29] Testing --- .github/workflows/publish_develop_image.yml | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/.github/workflows/publish_develop_image.yml b/.github/workflows/publish_develop_image.yml index 27eeded..07b0c4d 100644 --- a/.github/workflows/publish_develop_image.yml +++ b/.github/workflows/publish_develop_image.yml @@ -37,15 +37,6 @@ jobs: with: platforms: linux/amd64,linux/arm64 - # Ensure that the repo has the username and token added from the - # official Volttron Dockerhub page at https://hub.docker.com/repository/docker/eclipsevolttron/volttron/general - # On instructions how to do this, see https://docs.github.com/en/actions/guides/publishing-docker-images - # https://github.com/docker/login-action -# - name: Login to DockerHub -# uses: docker/login-action@v3 -# with: -# username: ${{ vars.DOCKER_USER }} -# password: ${{ secrets.DOCKER_API_TOKEN }} - name: Login to DockerHub run: | if [ -n "${{ vars.DOCKER_USER }}" -a -n "${{ secrets.DOCKER_API_TOKEN }}" ]; then @@ -69,13 +60,13 @@ jobs: --build-arg volttron_repo=${{ env.VOLTTRON_GIT_REPO }} \ --platform linux/amd64,linux/arm64 \ -t ${{ env.IMAGE_BASE_NAME }}:${{ env.IMAGE_TAG }} \ - -f ${{ env.DOCKERFILE || './Dockerfile' }} --no-cache --force-rm ." + -f ${{ env.DOCKERFILE || './Dockerfile' }} --no-cache --force-rm --load ." docker buildx build \ --build-arg volttron_git_branch=${{ env.VOLTTRON_GIT_BRANCH }} \ --build-arg volttron_repo=${{ env.VOLTTRON_GIT_REPO }} \ --platform linux/amd64,linux/arm64 \ -t ${{ env.IMAGE_BASE_NAME }}:${{ env.IMAGE_TAG }} \ - -f ${{ env.DOCKERFILE || './Dockerfile' }} --no-cache --force-rm . + -f ${{ env.DOCKERFILE || './Dockerfile' }} --load . status=$? if [ $status -ne 0 ]; then echo "Error: status $status" @@ -86,14 +77,19 @@ jobs: id: docker_push run: | echo "Pushing image" + # docker images echo "docker push ${{ env.IMAGE_BASE_NAME }}:${{ env.IMAGE_TAG }}" - echo "digest=$(docker push ${{ env.IMAGE_BASE_NAME }}:${{ env.IMAGE_TAG }} | tail -n 1)\n" >> $GITHUB_OUTPUT + echo "digest=$(docker push ${{ env.IMAGE_BASE_NAME }}:${{ env.IMAGE_TAG }} | grep '${{env.IMAGE_TAG}}: digest:')" >> $GITHUB_OUTPUT status=$? if [ $status -ne 0 ]; then echo "Error: status $status" exit 1 fi + - name: Show publish digest + run: | + echo "docker_push.outputs.digest: ${{ steps.docker_push.outputs.digest }}" + - name: Check image publish if: steps.docker_push.outputs.digest == '' run: exit 1 From 89d88bf2158ddd88d46810a6c2d9777bb3d6baf5 Mon Sep 17 00:00:00 2001 From: Nathan Tenney Date: Mon, 19 May 2025 01:10:41 -0700 Subject: [PATCH 29/29] testing pull_request_target --- .github/workflows/publish_develop_image.yml | 90 ++++++++++++--------- 1 file changed, 52 insertions(+), 38 deletions(-) diff --git a/.github/workflows/publish_develop_image.yml b/.github/workflows/publish_develop_image.yml index 07b0c4d..bde081b 100644 --- a/.github/workflows/publish_develop_image.yml +++ b/.github/workflows/publish_develop_image.yml @@ -7,7 +7,7 @@ on: branches: - develop workflow_dispatch: - pull_request: + pull_request_target: types: [opened, reopened, synchronize] env: # Image name on Volttron DockerHub account at https://hub.docker.com/orgs/eclipsevolttron @@ -51,50 +51,64 @@ jobs: fi fi - - name: Build Image + - name: Build and push id: docker_build - run: | - echo "Building image" - echo "docker buildx build \ - --build-arg volttron_git_branch=${{ env.VOLTTRON_GIT_BRANCH }} \ - --build-arg volttron_repo=${{ env.VOLTTRON_GIT_REPO }} \ - --platform linux/amd64,linux/arm64 \ - -t ${{ env.IMAGE_BASE_NAME }}:${{ env.IMAGE_TAG }} \ - -f ${{ env.DOCKERFILE || './Dockerfile' }} --no-cache --force-rm --load ." - docker buildx build \ - --build-arg volttron_git_branch=${{ env.VOLTTRON_GIT_BRANCH }} \ - --build-arg volttron_repo=${{ env.VOLTTRON_GIT_REPO }} \ - --platform linux/amd64,linux/arm64 \ - -t ${{ env.IMAGE_BASE_NAME }}:${{ env.IMAGE_TAG }} \ - -f ${{ env.DOCKERFILE || './Dockerfile' }} --load . - status=$? - if [ $status -ne 0 ]; then - echo "Error: status $status" - exit 1 - fi + uses: docker/build-push-action@v2 + with: + context: . + file: ${{ env.DOCKERFILE || './Dockerfile' }} + platforms: linux/amd64,linux/arm64 + build-args: | + volttron_git_branch=${{ env.VOLTTRON_GIT_BRANCH }} + volttron_repo=${{ env.VOLTTRON_GIT_REPO }} + push: true + tags: | + ${{ env.IMAGE_BASE_NAME }}:${{ env.IMAGE_TAG }} - - name: Push Image - id: docker_push - run: | - echo "Pushing image" - # docker images - echo "docker push ${{ env.IMAGE_BASE_NAME }}:${{ env.IMAGE_TAG }}" - echo "digest=$(docker push ${{ env.IMAGE_BASE_NAME }}:${{ env.IMAGE_TAG }} | grep '${{env.IMAGE_TAG}}: digest:')" >> $GITHUB_OUTPUT - status=$? - if [ $status -ne 0 ]; then - echo "Error: status $status" - exit 1 - fi +# - name: Build Image +# id: docker_build +# run: | +# echo "Building image" +# echo "docker buildx build \ +# --build-arg volttron_git_branch=${{ env.VOLTTRON_GIT_BRANCH }} \ +# --build-arg volttron_repo=${{ env.VOLTTRON_GIT_REPO }} \ +# --platform linux/amd64,linux/arm64 \ +# -t ${{ env.IMAGE_BASE_NAME }}:${{ env.IMAGE_TAG }} \ +# -f ${{ env.DOCKERFILE || './Dockerfile' }} --no-cache --force-rm --load ." +# docker buildx build \ +# --build-arg volttron_git_branch=${{ env.VOLTTRON_GIT_BRANCH }} \ +# --build-arg volttron_repo=${{ env.VOLTTRON_GIT_REPO }} \ +# --platform linux/amd64,linux/arm64 \ +# -t ${{ env.IMAGE_BASE_NAME }}:${{ env.IMAGE_TAG }} \ +# -f ${{ env.DOCKERFILE || './Dockerfile' }} --load . +# status=$? +# if [ $status -ne 0 ]; then +# echo "Error: status $status" +# exit 1 +# fi +# +# - name: Push Image +# id: docker_push +# run: | +# echo "Pushing image" +# # docker images +# echo "docker push ${{ env.IMAGE_BASE_NAME }}:${{ env.IMAGE_TAG }}" +# echo "digest=$(docker push ${{ env.IMAGE_BASE_NAME }}:${{ env.IMAGE_TAG }} | grep '${{env.IMAGE_TAG}}: digest:')" >> $GITHUB_OUTPUT +# status=$? +# if [ $status -ne 0 ]; then +# echo "Error: status $status" +# exit 1 +# fi - - name: Show publish digest - run: | - echo "docker_push.outputs.digest: ${{ steps.docker_push.outputs.digest }}" +# - name: Show publish digest +# run: | +# echo "docker_push.outputs.digest: ${{ steps.docker_push.outputs.digest }}" - name: Check image publish - if: steps.docker_push.outputs.digest == '' + if: steps.docker_build.outputs.digest == '' run: exit 1 - name: Image Digest - run: echo ${{ steps.docker_push.outputs.digest }} + run: echo ${{ steps.docker_build.outputs.digest }} - run: echo "🍏 This job's status is ${{ job.status }}."