Skip to content

Commit

Permalink
add building of postam image for nodejs
Browse files Browse the repository at this point in the history
  • Loading branch information
ypoplavs committed May 21, 2024
1 parent 6e0f62b commit 5ea9fbc
Show file tree
Hide file tree
Showing 3 changed files with 183 additions and 11 deletions.
82 changes: 71 additions & 11 deletions .github/workflows/docker-build-develop.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ on:
push:
branches:
- develop
- feat/TKC-1987-postman-image
paths-ignore:
- 'docs/**'
env:
Expand Down Expand Up @@ -654,21 +655,80 @@ jobs:
run: |
docker push kubeshop/testkube-playwright-executor:${{ steps.commit.outputs.short }}
workflow_dispatch:
needs: [api, single_executor, executor_jmeter, executor_jmeterd, jmeterd_slave, executor_maven, executor_gradle, executor_cypress, executor_playwright]
executor_postman_node21:
runs-on: ubuntu-latest
steps:
- name: Free Disk Space (Ubuntu)
uses: jlumbroso/free-disk-space@main
with:
# this might remove tools that are actually needed,
# if set to "true" but frees about 6 GB
tool-cache: false

- name: Checkout
uses: actions/checkout@v4

- name: Get commit sha
id: github_sha
run: echo "::set-output name=sha_short::${GITHUB_SHA::7}"
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v3

- name: Set-up Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
cache: false

- name: Go Cache
uses: actions/cache@v4
with:
path: |
~/go/pkg/mod
~/.cache/go-build
key: playwright-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- id: commit
uses: prompt/actions-commit-hash@v3

- name: Repository Dispatch
uses: peter-evans/repository-dispatch@v3
- name: Release
uses: goreleaser/goreleaser-action@v5
with:
token: ${{ secrets.CI_BOT_TOKEN }}
repository: kubeshop/helm-charts
event-type: trigger-workflow-api-develop
client-payload: '{"image_tag_api": "${{ steps.github_sha.outputs.sha_short }}"}'
distribution: goreleaser
version: latest
args: release -f goreleaser_files/.goreleaser-docker-build-executor-postman-node21.yml --snapshot
env:
GITHUB_TOKEN: ${{ secrets.CI_BOT_TOKEN }}
DOCKER_BUILDX_BUILDER: "${{ steps.buildx.outputs.name }}"
DOCKER_BUILDX_CACHE_FROM: "type=gha"
DOCKER_BUILDX_CACHE_TO: "type=gha,mode=max"
IMAGE_TAG_SHA: true

- name: Push image to the Registry
run: |
docker push kubeshop/testkube-postman-executor:node21-${{ steps.commit.outputs.short }}
# workflow_dispatch:
# needs: [api, single_executor, executor_jmeter, executor_jmeterd, jmeterd_slave, executor_maven, executor_gradle, executor_cypress, executor_playwright]
# runs-on: ubuntu-latest
# steps:
# - name: Checkout
# uses: actions/checkout@v4
#
# - name: Get commit sha
# id: github_sha
# run: echo "::set-output name=sha_short::${GITHUB_SHA::7}"
#
# - name: Repository Dispatch
# uses: peter-evans/repository-dispatch@v3
# with:
# token: ${{ secrets.CI_BOT_TOKEN }}
# repository: kubeshop/helm-charts
# event-type: trigger-workflow-api-develop
# client-payload: '{"image_tag_api": "${{ steps.github_sha.outputs.sha_short }}"}'
20 changes: 20 additions & 0 deletions contrib/executor/postman/build/agent/Dockerfile.node21
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# syntax=docker/dockerfile:1
FROM node:21-alpine3.17

COPY postman /bin/runner
RUN npm install -g newman
RUN apk --no-cache add ca-certificates git curl

# support npm report permissions
RUN mkdir -p /.npm
RUN chmod 777 /.npm
RUN chmod 777 /root/
RUN chmod 777 /usr/local/lib/node_modules
RUN chmod 777 /usr/local/bin

WORKDIR /root/
EXPOSE 8082

USER 1001

ENTRYPOINT ["/bin/runner"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
env:
# Goreleaser always uses the docker buildx builder with name "default"; see
# https://github.com/goreleaser/goreleaser/pull/3199
# To use a builder other than "default", set this variable.
# Necessary for, e.g., GitHub actions cache integration.
- DOCKER_REPO={{ if index .Env "DOCKER_REPO" }}{{ .Env.DOCKER_REPO }}{{ else }}kubeshop{{ end }}
- DOCKER_BUILDX_BUILDER={{ if index .Env "DOCKER_BUILDX_BUILDER" }}{{ .Env.DOCKER_BUILDX_BUILDER }}{{ else }}default{{ end }}
# Setup to enable Docker to use, e.g., the GitHub actions cache; see
# https://docs.docker.com/build/building/cache/backends/
# https://github.com/moby/buildkit#export-cache
- DOCKER_BUILDX_CACHE_FROM={{ if index .Env "DOCKER_BUILDX_CACHE_FROM" }}{{ .Env.DOCKER_BUILDX_CACHE_FROM }}{{ else }}type=registry{{ end }}
- DOCKER_BUILDX_CACHE_TO={{ if index .Env "DOCKER_BUILDX_CACHE_TO" }}{{ .Env.DOCKER_BUILDX_CACHE_TO }}{{ else }}type=inline{{ end }}
# Build image with commit sha tag
- IMAGE_TAG_SHA={{ if index .Env "IMAGE_TAG_SHA" }}{{ .Env.IMAGE_TAG_SHA }}{{ else }}{{ end }}
builds:
- id: "linux"
main: "./contrib/executor/postman/cmd/agent"
binary: "postman"
env:
- CGO_ENABLED=0
goos:
- linux
goarch:
- amd64
- arm64
mod_timestamp: "{{ .CommitTimestamp }}"
dockers:
- dockerfile: "./contrib/executor/postman/build/agent/Dockerfile.node21"
use: buildx
goos: linux
goarch: amd64
image_templates:
- "{{ if not .Env.IMAGE_TAG_SHA }}{{ .Env.DOCKER_REPO }}/testkube-postman-executor:{{ .Version }}-node21-amd64{{ end }}"
- "{{ if .Env.IMAGE_TAG_SHA }}{{ .Env.DOCKER_REPO }}/testkube-postman-executor:node21-{{ .ShortCommit }}-amd64{{ end }}"
build_flag_templates:
- "--platform=linux/amd64"
- "--label=org.opencontainers.image.title={{ .ProjectName }}"
- "--label=org.opencontainers.image.created={{ .Date}}"
- "--label=org.opencontainers.image.revision={{ .FullCommit }}"
- "--label=org.opencontainers.image.version={{ .Version }}"
- "--builder={{ .Env.DOCKER_BUILDX_BUILDER }}"
- "--cache-to={{ .Env.DOCKER_BUILDX_CACHE_TO }}"
- "--cache-from={{ .Env.DOCKER_BUILDX_CACHE_FROM }}"
- "--build-arg=TOKEN={{ .Env.GITHUB_TOKEN }}"
- "--build-arg=ALPINE_IMAGE={{ .Env.ALPINE_IMAGE }}"
- "--build-arg=BUSYBOX_IMAGE={{ .Env.BUSYBOX_IMAGE }}"

- dockerfile: "./contrib/executor/postman/build/agent/Dockerfile.node21"
use: buildx
goos: linux
goarch: arm64
image_templates:
- "{{ if not .Env.IMAGE_TAG_SHA }}{{ .Env.DOCKER_REPO }}/testkube-postman-executor:{{ .Version }}-node21-arm64v8{{ end }}"
- "{{ if .Env.IMAGE_TAG_SHA }}{{ .Env.DOCKER_REPO }}/testkube-postman-executor:node21-{{ .ShortCommit }}-arm64v8{{ end }}"
build_flag_templates:
- "--platform=linux/arm64/v8"
- "--label=org.opencontainers.image.created={{ .Date }}"
- "--label=org.opencontainers.image.title={{ .ProjectName }}"
- "--label=org.opencontainers.image.revision={{ .FullCommit }}"
- "--label=org.opencontainers.image.version={{ .Version }}"
- "--builder={{ .Env.DOCKER_BUILDX_BUILDER }}"
- "--cache-to={{ .Env.DOCKER_BUILDX_CACHE_TO }}"
- "--cache-from={{ .Env.DOCKER_BUILDX_CACHE_FROM }}"
- "--build-arg=TOKEN={{ .Env.GITHUB_TOKEN }}"
- "--build-arg=ALPINE_IMAGE={{ .Env.ALPINE_IMAGE }}"
- "--build-arg=BUSYBOX_IMAGE={{ .Env.BUSYBOX_IMAGE }}"

docker_manifests:
- name_template: "{{ if .Env.IMAGE_TAG_SHA }}{{ .Env.DOCKER_REPO }}/testkube-postman-executor:node21-{{ .ShortCommit }}{{ end }}"
image_templates:
- "{{ if .Env.IMAGE_TAG_SHA }}{{ .Env.DOCKER_REPO }}/testkube-postman-executor:node21-{{ .ShortCommit }}-arm64v8{{ end }}"
- "{{ if .Env.IMAGE_TAG_SHA }}{{ .Env.DOCKER_REPO }}/testkube-postman-executor:node21-{{ .ShortCommit }}-amd64{{ end }}"
- name_template: "{{ if not .Env.IMAGE_TAG_SHA }}{{ .Env.DOCKER_REPO }}/testkube-postman-executor:{{ .Version }}-node21{{ end }}"
image_templates:
- "{{ if not .Env.IMAGE_TAG_SHA }}{{ .Env.DOCKER_REPO }}/testkube-postman-executor:{{ .Version }}-node21-amd64{{ end }}"
- "{{ if not .Env.IMAGE_TAG_SHA }}{{ .Env.DOCKER_REPO }}/testkube-postman-executor:{{ .Version }}-node21-arm64v8{{ end }}"
- name_template: "{{ if not .Env.IMAGE_TAG_SHA }}{{ .Env.DOCKER_REPO }}/testkube-postman-executor:node21{{ end }}"
image_templates:
- "{{ if not .Env.IMAGE_TAG_SHA }}{{ .Env.DOCKER_REPO }}/testkube-postman-executor:{{ .Version }}-node21-amd64{{ end }}"
- "{{ if not .Env.IMAGE_TAG_SHA }}{{ .Env.DOCKER_REPO }}/testkube-postman-executor:{{ .Version }}-node21-arm64v8{{ end }}"

release:
disable: true

docker_signs:
- cmd: cosign
artifacts: all
output: true
args:
- 'sign'
- '${artifact}'
- "--yes"

0 comments on commit 5ea9fbc

Please sign in to comment.