Skip to content

Commit

Permalink
push images to GAR
Browse files Browse the repository at this point in the history
  • Loading branch information
chen.shmilovich committed Sep 9, 2024
1 parent 2ba9684 commit 4de319f
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 4 deletions.
26 changes: 23 additions & 3 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,24 @@ pipeline {
}

stages {
stage('Login to registries') {
steps {
script {
withCredentials([
usernamePassword(credentialsId: 'jenkins-artifactory', usernameVariable: 'ARTIFACTORY_USER', passwordVariable: 'ARTIFACTORY_PASS'),
file(credentialsId: 'google-artifactory-dev-write', variable: 'GAR_WR_SECRET')
]) {
sh '''#!/bin/bash
set -euo pipefail
echo "Logging into Artifactory"
docker login docker.internal.sysdig.com -u="$ARTIFACTORY_USER" -p="$ARTIFACTORY_PASS"
echo "Logging into GAR dev"
cat $GAR_WR_SECRET | docker login --username _json_key --password-stdin us-docker.pkg.dev/sysdig-artifact-registry-dev/gar-docker
'''
}
}
}
}
stage('Build and Push Dependency Image') {
steps {
checkout([$class: 'GitSCM',
Expand All @@ -14,11 +32,13 @@ pipeline {
userRemoteConfigs: [[credentialsId: 'github-jenkins-user-token', url: 'https://github.com/draios/linux-bench.git']]
])
script {
docker.withRegistry("https://docker.internal.sysdig.com", 'jenkins-artifactory') {
sh "IMAGE_TAG=${params.TAG} PUSH=yes make -f makefile-sysdig build-dependency-image"
docker.withRegistry("https://docker.internal.sysdig.com", 'jenkins-artifactory') {
sh "IMAGE_TAG=${params.TAG} PUSH=yes make -f makefile-sysdig build-dependency-image"
sh "IMAGE_TAG=${params.TAG} PUSH=yes make -f makefile-sysdig build-dependency-image-gar"
}
}
}
}
}
}
}

9 changes: 8 additions & 1 deletion makefile-sysdig
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
# This repo is a fork of a public upstream, so Sysdig specific make commands have been added in a separate makefile

ARTIFACTORY := docker.internal.sysdig.com
GAR_DEV_REGISTRY := us-docker.pkg.dev/sysdig-artifact-registry-dev/gar-docker/secure
PROJECT := linux-bench
IMAGE_REPO := $(PROJECT)-dependency
IMAGE_TAG?= dev
DEPENDENCY_IMAGE_NAME := $(ARTIFACTORY)/$(IMAGE_REPO):$(IMAGE_TAG)
DEPENDENCY_IMAGE_NAME_GAR := $(GAR_DEV_REGISTRY)/$(IMAGE_REPO):$(IMAGE_TAG)

ifndef PUSH
PUSH_FLAG := ""
Expand All @@ -15,4 +17,9 @@ endif
build-dependency-image:
docker buildx rm -f $(PROJECT)-builder || true
docker buildx create --name $(PROJECT)-builder --use
docker buildx build --platform linux/arm64,linux/amd64 $(PUSH_FLAG) --tag $(DEPENDENCY_IMAGE_NAME) .
docker buildx build --platform linux/arm64,linux/amd64 $(PUSH_FLAG) --tag $(DEPENDENCY_IMAGE_NAME) --file Dependency-Dockerfile .

build-dependency-image-gar:
docker buildx rm -f $(PROJECT)-builder || true
docker buildx create --name $(PROJECT)-builder --use
docker buildx build --platform linux/arm64,linux/amd64 $(PUSH_FLAG) --tag $(DEPENDENCY_IMAGE_NAME_GAR) --file Dependency-Dockerfile .

0 comments on commit 4de319f

Please sign in to comment.