From ef9038b25fabb4459bdc874d14b11a3bebeec5bf Mon Sep 17 00:00:00 2001 From: David Ferlay Date: Mon, 17 Mar 2025 18:49:32 +0100 Subject: [PATCH 1/5] Adding actions to build and push images --- image/actions/build/Dockerfile | 8 ++++++++ image/actions/build/action.sh | 4 ++++ image/actions/build/action.yaml | 24 ++++++++++++++++++++++++ 3 files changed, 36 insertions(+) create mode 100644 image/actions/build/Dockerfile create mode 100644 image/actions/build/action.sh create mode 100644 image/actions/build/action.yaml diff --git a/image/actions/build/Dockerfile b/image/actions/build/Dockerfile new file mode 100644 index 0000000..d83da04 --- /dev/null +++ b/image/actions/build/Dockerfile @@ -0,0 +1,8 @@ +FROM alpine:3.21 + +RUN apk upgrade --update-cache -a && apk add \ + docker \ + openrc \ + git-cliff && \ + rm -fr /var/cache/apk/* && \ + rc-update add docker boot diff --git a/image/actions/build/action.sh b/image/actions/build/action.sh new file mode 100644 index 0000000..8729c0f --- /dev/null +++ b/image/actions/build/action.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +id +service docker status diff --git a/image/actions/build/action.yaml b/image/actions/build/action.yaml new file mode 100644 index 0000000..8eaf1d7 --- /dev/null +++ b/image/actions/build/action.yaml @@ -0,0 +1,24 @@ +working_directory: "{{ .current_working_dir }}" +action: + title: Build + description: Create new docker image from local files + options: + - name: tag + title: Custom tag + description: Option to preview changelog and tag + type: string + default: "" + +runtime: + type: container + image: image-actions-build:latest + build: + context: ./ + args: + GIT_AUTHOR_NAME: ${USER} + GIT_AUTHOR_EMAIL: no-reply@skilld.cloud + command: + - /bin/bash + - /action/action.sh + - "{{ .tag }}" + From 834e66004f766d38fbe2e864c5987383ffcf02de Mon Sep 17 00:00:00 2001 From: David Ferlay Date: Tue, 18 Mar 2025 12:16:41 +0100 Subject: [PATCH 2/5] Adding actions to build and push images --- .gitignore | 19 +++++++++ image/actions/build/Dockerfile | 22 ++++++++--- image/actions/build/action.sh | 13 ++++++- image/actions/build/action.yaml | 14 ++----- image/actions/build/codebase.md | 69 +++++++++++++++++++++++++++++++++ 5 files changed, 120 insertions(+), 17 deletions(-) create mode 100644 .gitignore create mode 100644 image/actions/build/codebase.md diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4328201 --- /dev/null +++ b/.gitignore @@ -0,0 +1,19 @@ +.idea +__pycache__/ +.metals +.swp +**/.swp +*.iml +.DS_Store +**/.~lock.* +plasmactl +plasmactl.exe +.compose +.compose/* +file.diff +build_*/ +deploy.log +.plasmactl/* +!.plasmactl/config.yaml +codebase.md + diff --git a/image/actions/build/Dockerfile b/image/actions/build/Dockerfile index d83da04..c7db0ef 100644 --- a/image/actions/build/Dockerfile +++ b/image/actions/build/Dockerfile @@ -1,8 +1,20 @@ FROM alpine:3.21 -RUN apk upgrade --update-cache -a && apk add \ - docker \ - openrc \ - git-cliff && \ +WORKDIR /host +ARG USER_ID +ARG USER_NAME +ARG GROUP_ID + +RUN adduser -D -u ${USER_ID} -g ${GROUP_ID} -h /home/${USER_NAME} ${USER_NAME} \ + && chown -R ${USER_NAME}:${USER_NAME} /host \ + && apk upgrade --update-cache -a && apk add \ + docker \ + openrc && \ rm -fr /var/cache/apk/* && \ - rc-update add docker boot + rc-update add docker boot && \ + mkdir -p /run/openrc && \ + touch /run/openrc/softlevel + +USER ${USER_NAME} + + diff --git a/image/actions/build/action.sh b/image/actions/build/action.sh index 8729c0f..1a4c298 100644 --- a/image/actions/build/action.sh +++ b/image/actions/build/action.sh @@ -1,4 +1,13 @@ #!/bin/sh - +whoami id -service docker status +docker build --help +service docker status || true +service containerd status || true +service docker start +service containerd start || true +service docker status || true +service containerd status || true +docker --version +export VERSION=111.111 +docker build -t skilldlabs/docker-non-root-for-ci:${VERSION}-r --build-arg ALPINE_VERSION=${VERSION} --build-arg GID=233 --build-arg GNAME=docker --build-arg UNAME=skilld . diff --git a/image/actions/build/action.yaml b/image/actions/build/action.yaml index 8eaf1d7..c0fb467 100644 --- a/image/actions/build/action.yaml +++ b/image/actions/build/action.yaml @@ -2,12 +2,6 @@ working_directory: "{{ .current_working_dir }}" action: title: Build description: Create new docker image from local files - options: - - name: tag - title: Custom tag - description: Option to preview changelog and tag - type: string - default: "" runtime: type: container @@ -15,10 +9,10 @@ runtime: build: context: ./ args: - GIT_AUTHOR_NAME: ${USER} - GIT_AUTHOR_EMAIL: no-reply@skilld.cloud + USER_ID: {{ .current_uid }} + GROUP_ID: {{ .current_gid }} + USER_NAME: plasma command: - - /bin/bash + - /bin/sh - /action/action.sh - - "{{ .tag }}" diff --git a/image/actions/build/codebase.md b/image/actions/build/codebase.md new file mode 100644 index 0000000..1906c3e --- /dev/null +++ b/image/actions/build/codebase.md @@ -0,0 +1,69 @@ +# action.sh + +```sh +#!/bin/sh +whoami +id +docker build --help +service docker status || true +service containerd status || true +service docker start +service containerd start || true +service docker status || true +service containerd status || true +docker --version +export VERSION=111.111 +docker build -t skilldlabs/docker-non-root-for-ci:${VERSION}-r --build-arg ALPINE_VERSION=${VERSION} --build-arg GID=233 --build-arg GNAME=docker --build-arg UNAME=skilld . + +``` + +# action.yaml + +```yaml +working_directory: "{{ .current_working_dir }}" +action: + title: Build + description: Create new docker image from local files + +runtime: + type: container + image: image-actions-build:latest + build: + context: ./ + args: + USER_ID: {{ .current_uid }} + GROUP_ID: {{ .current_gid }} + USER_NAME: plasma + command: + - /bin/sh + - /action/action.sh + + +``` + +# Dockerfile + +``` +FROM alpine:3.21 + +WORKDIR /host +ARG USER_ID +ARG USER_NAME +ARG GROUP_ID + +RUN adduser -D -u ${USER_ID} -g ${GROUP_ID} -h /home/${USER_NAME} ${USER_NAME} \ + && chown -R ${USER_NAME}:${USER_NAME} /host \ + && apk upgrade --update-cache -a && apk add \ + docker \ + openrc && \ + rm -fr /var/cache/apk/* && \ + rc-update add docker boot && \ + mkdir -p /run/openrc && \ + touch /run/openrc/softlevel + +USER ${USER_NAME} + + + +``` + From 4f205c317204220260f9a23fe94a565f5e845f73 Mon Sep 17 00:00:00 2001 From: David Ferlay Date: Tue, 18 Mar 2025 17:29:10 +0100 Subject: [PATCH 3/5] Adding actions to build and push images --- image/actions/build/Dockerfile | 20 ---------- image/actions/build/action.sh | 15 ++----- image/actions/build/action.yaml | 36 ++++++++++------- image/actions/build/codebase.md | 69 --------------------------------- 4 files changed, 26 insertions(+), 114 deletions(-) delete mode 100644 image/actions/build/Dockerfile delete mode 100644 image/actions/build/codebase.md diff --git a/image/actions/build/Dockerfile b/image/actions/build/Dockerfile deleted file mode 100644 index c7db0ef..0000000 --- a/image/actions/build/Dockerfile +++ /dev/null @@ -1,20 +0,0 @@ -FROM alpine:3.21 - -WORKDIR /host -ARG USER_ID -ARG USER_NAME -ARG GROUP_ID - -RUN adduser -D -u ${USER_ID} -g ${GROUP_ID} -h /home/${USER_NAME} ${USER_NAME} \ - && chown -R ${USER_NAME}:${USER_NAME} /host \ - && apk upgrade --update-cache -a && apk add \ - docker \ - openrc && \ - rm -fr /var/cache/apk/* && \ - rc-update add docker boot && \ - mkdir -p /run/openrc && \ - touch /run/openrc/softlevel - -USER ${USER_NAME} - - diff --git a/image/actions/build/action.sh b/image/actions/build/action.sh index 1a4c298..f4d9a1f 100644 --- a/image/actions/build/action.sh +++ b/image/actions/build/action.sh @@ -1,13 +1,6 @@ #!/bin/sh +date +pwd whoami -id -docker build --help -service docker status || true -service containerd status || true -service docker start -service containerd start || true -service docker status || true -service containerd status || true -docker --version -export VERSION=111.111 -docker build -t skilldlabs/docker-non-root-for-ci:${VERSION}-r --build-arg ALPINE_VERSION=${VERSION} --build-arg GID=233 --build-arg GNAME=docker --build-arg UNAME=skilld . +env + diff --git a/image/actions/build/action.yaml b/image/actions/build/action.yaml index c0fb467..6a088eb 100644 --- a/image/actions/build/action.yaml +++ b/image/actions/build/action.yaml @@ -1,18 +1,26 @@ -working_directory: "{{ .current_working_dir }}" action: title: Build - description: Create new docker image from local files + description: Create + options: + - name: firstoption + title: First option + type: string + default: "" + - name: secondoption + title: Second option + description: Option to do something + type: boolean + default: false runtime: - type: container - image: image-actions-build:latest - build: - context: ./ - args: - USER_ID: {{ .current_uid }} - GROUP_ID: {{ .current_gid }} - USER_NAME: plasma - command: - - /bin/sh - - /action/action.sh - + type: shell + env: + MY_ENV_VAR: "my_env_var" + script: | + $$SHELL -l + date + pwd + whoami + env + echo "" + {{ .action_dir }}/main.sh "{{ .firstoption }}" "{{ .secondoption }}" diff --git a/image/actions/build/codebase.md b/image/actions/build/codebase.md deleted file mode 100644 index 1906c3e..0000000 --- a/image/actions/build/codebase.md +++ /dev/null @@ -1,69 +0,0 @@ -# action.sh - -```sh -#!/bin/sh -whoami -id -docker build --help -service docker status || true -service containerd status || true -service docker start -service containerd start || true -service docker status || true -service containerd status || true -docker --version -export VERSION=111.111 -docker build -t skilldlabs/docker-non-root-for-ci:${VERSION}-r --build-arg ALPINE_VERSION=${VERSION} --build-arg GID=233 --build-arg GNAME=docker --build-arg UNAME=skilld . - -``` - -# action.yaml - -```yaml -working_directory: "{{ .current_working_dir }}" -action: - title: Build - description: Create new docker image from local files - -runtime: - type: container - image: image-actions-build:latest - build: - context: ./ - args: - USER_ID: {{ .current_uid }} - GROUP_ID: {{ .current_gid }} - USER_NAME: plasma - command: - - /bin/sh - - /action/action.sh - - -``` - -# Dockerfile - -``` -FROM alpine:3.21 - -WORKDIR /host -ARG USER_ID -ARG USER_NAME -ARG GROUP_ID - -RUN adduser -D -u ${USER_ID} -g ${GROUP_ID} -h /home/${USER_NAME} ${USER_NAME} \ - && chown -R ${USER_NAME}:${USER_NAME} /host \ - && apk upgrade --update-cache -a && apk add \ - docker \ - openrc && \ - rm -fr /var/cache/apk/* && \ - rc-update add docker boot && \ - mkdir -p /run/openrc && \ - touch /run/openrc/softlevel - -USER ${USER_NAME} - - - -``` - From 74029335f4b176cda82bfd71f52bc2c75065824f Mon Sep 17 00:00:00 2001 From: David Ferlay Date: Wed, 19 Mar 2025 12:32:42 +0100 Subject: [PATCH 4/5] Adding actions to build and push images --- image/actions/build/action.sh | 1 - image/actions/build/action.yaml | 5 ++--- 2 files changed, 2 insertions(+), 4 deletions(-) mode change 100644 => 100755 image/actions/build/action.sh diff --git a/image/actions/build/action.sh b/image/actions/build/action.sh old mode 100644 new mode 100755 index f4d9a1f..367fb0b --- a/image/actions/build/action.sh +++ b/image/actions/build/action.sh @@ -2,5 +2,4 @@ date pwd whoami -env diff --git a/image/actions/build/action.yaml b/image/actions/build/action.yaml index 6a088eb..09c876e 100644 --- a/image/actions/build/action.yaml +++ b/image/actions/build/action.yaml @@ -17,10 +17,9 @@ runtime: env: MY_ENV_VAR: "my_env_var" script: | - $$SHELL -l date pwd whoami - env + echo $SHELL echo "" - {{ .action_dir }}/main.sh "{{ .firstoption }}" "{{ .secondoption }}" + {{ .action_dir }}/action.sh "{{ .firstoption }}" "{{ .secondoption }}" From 89bcc1c6eaba79e99245dee8ebc2f99420e3fe7d Mon Sep 17 00:00:00 2001 From: David Ferlay Date: Fri, 4 Apr 2025 17:47:05 +0200 Subject: [PATCH 5/5] Testing shell actions --- .plasmactl/config.yaml | 41 +++++++++++++++++++++++++++++++++ image/actions/build/action.sh | 16 ++++++++++--- image/actions/build/action.yaml | 31 ++++++++++++++++++++----- 3 files changed, 79 insertions(+), 9 deletions(-) create mode 100644 .plasmactl/config.yaml diff --git a/.plasmactl/config.yaml b/.plasmactl/config.yaml new file mode 100644 index 0000000..ef0324b --- /dev/null +++ b/.plasmactl/config.yaml @@ -0,0 +1,41 @@ +launchrctl: + actions_naming: + - search: ".roles." + replace: "." + - search: "_" + replace: "-" +web: + vars_file: platform/group_vars/platform/vars.yaml + variables: + - plasmactl_web_ui_platform_name + - plasmactl_web_ui_platform_page_name + - plasmactl_web_ui_platform_header_name + - plasmactl_web_ui_platform_favicon + - machine_color_1 + - machine_color_2 + - machine_color_3 + - machine_color_4 + - machine_color_5 + - machine_color_6 + - machine_color_7 + - machine_color_8 + - machine_color_9 + - machine_color_10 + - machine_color_11 + - machine_color_12 + - machine_color_13 + - machine_color_14 + - machine_color_15 + - machine_color_16 + - machine_color_17 +sshconfig: + port: 13377777 + user: skilld +platform: + entities: + timelog: + diff: + gitlab_url: http://projects.interaction.svc.skilld:8081/api/v4 + odoo_url: http://erp.interaction.svc.skilld:8069 + odoo_admin: skilld + odoo_db: skilld diff --git a/image/actions/build/action.sh b/image/actions/build/action.sh index 367fb0b..3481c29 100755 --- a/image/actions/build/action.sh +++ b/image/actions/build/action.sh @@ -1,5 +1,15 @@ #!/bin/sh -date -pwd -whoami +echo +# Print the total count of arguments +echo "Total number of arguments passed to the script: $#" +count=1 +for arg in "$@" +do + if [ -z "$arg" ]; then + echo "- Argument $count: \"\"" + else + echo "- Argument $count: $arg" + fi + count=$((count + 1)) +done diff --git a/image/actions/build/action.yaml b/image/actions/build/action.yaml index 09c876e..389c102 100644 --- a/image/actions/build/action.yaml +++ b/image/actions/build/action.yaml @@ -1,6 +1,12 @@ action: title: Build description: Create + arguments: + - name: action + title: Action + description: Operation type to use (sub/pub) + enum: [sub, pub] + required: true options: - name: firstoption title: First option @@ -11,15 +17,28 @@ action: description: Option to do something type: boolean default: false + - name: sshpass + title: SSH Key passphrase + process: + - processor: keyring.GetKeyValue + options: + key: sshpass + default: "" + - name: port + description: The SSH port for connections (default is 22). + type: integer + process: + - processor: config.GetValue + options: + path: sshconfig.port + default: 22 runtime: type: shell env: MY_ENV_VAR: "my_env_var" script: | - date - pwd - whoami - echo $SHELL - echo "" - {{ .action_dir }}/action.sh "{{ .firstoption }}" "{{ .secondoption }}" + echo "firstoption: {{ .firstoption }}" + echo "secondoption: {{ .secondoption }}" + echo "sshpass: {{ .sshpass }}" + echo "port: {{ .port }}"