Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build multiarchitecture Lagoon images & Update to Keycloak 17 #3450

Merged
merged 9 commits into from
Jul 20, 2023
Merged
54 changes: 27 additions & 27 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -32,40 +32,26 @@ pipeline {
sh script: "docker image prune -af", label: "Pruning images"
}
}
stage ('refresh upstream images') {
when {
not {
buildingTag()
}
}
steps {
sh script: "make -O -j$NPROC docker_pull", label: "Ensuring fresh upstream images"
}
}
// stage ('refresh upstream images') {
// when {
// not {
// buildingTag()
// }
// }
// steps {
// sh script: "make -O -j$NPROC docker_pull", label: "Ensuring fresh upstream images"
// }
// }
stage ('build images') {
steps {
sh script: "make -O -j$NPROC build", label: "Building images"
sh script: "make -O build", label: "Building images"
}
}
stage ('show trivy scan results') {
steps {
sh script: "cat scan.txt", label: "Display scan results"
}
}
stage ('push images to testlagoon/*') {
when {
not {
environment name: 'SKIP_IMAGE_PUBLISH', value: 'true'
}
}
environment {
PASSWORD = credentials('amazeeiojenkins-dockerhub-password')
}
steps {
sh script: 'docker login -u amazeeiojenkins -p $PASSWORD', label: "Docker login"
sh script: "make -O -j$NPROC publish-testlagoon-baseimages publish-testlagoon-serviceimages publish-testlagoon-taskimages BRANCH_NAME=${SAFEBRANCH_NAME}", label: "Publishing built images"
}
}
stage ('setup test cluster') {
parallel {
stage ('0: setup test cluster') {
Expand All @@ -85,6 +71,20 @@ pipeline {
sh script: "cat test-suite-0.txt", label: "View ${NODE_NAME}:${WORKSPACE}/test-suite-0.txt"
}
}
stage ('push images to testlagoon/*') {
when {
not {
environment name: 'SKIP_IMAGE_PUBLISH', value: 'true'
}
}
environment {
PASSWORD = credentials('amazeeiojenkins-dockerhub-password')
}
steps {
sh script: 'docker login -u amazeeiojenkins -p $PASSWORD', label: "Docker login"
sh script: "make -O publish-testlagoon-images BRANCH_NAME=${SAFEBRANCH_NAME}", label: "Publishing built images"
}
}
}
}
stage ('run first test suite') {
Expand Down Expand Up @@ -157,7 +157,7 @@ pipeline {
}
steps {
sh script: 'docker login -u amazeeiojenkins -p $PASSWORD', label: "Docker login"
sh script: "make -O -j$NPROC publish-testlagoon-baseimages publish-testlagoon-serviceimages publish-testlagoon-taskimages BRANCH_NAME=latest", label: "Publishing built images with :latest tag"
sh script: "make -O publish-testlagoon-images BRANCH_NAME=latest", label: "Publishing built images with :latest tag"
}
}
stage ('deploy to test environment') {
Expand Down Expand Up @@ -186,7 +186,7 @@ pipeline {
}
steps {
sh script: 'docker login -u amazeeiojenkins -p $PASSWORD', label: "Docker login"
sh script: "make -O -j$NPROC publish-uselagoon-baseimages publish-uselagoon-serviceimages publish-uselagoon-taskimages", label: "Publishing built images to uselagoon"
sh script: "make -O publish-uselagoon-images", label: "Publishing built images to uselagoon"
}
}
stage ('scan built images') {
Expand Down
119 changes: 15 additions & 104 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -229,13 +229,14 @@ s3-images += $(service-images)

# Builds all Images
.PHONY: build
build: $(foreach image,$(base-images) $(service-images) $(task-images),build/$(image))
# Outputs a list of all Images we manage
build:
docker buildx create --name $(CI_BUILD_TAG) || echo -e '$(CI_BUILD_TAG) builder already present\n'
PLATFORMS=linux/amd64 REPO=lagoon TAG=latest LAGOON_VERSION=$(LAGOON_VERSION) docker buildx bake -f docker-bake.hcl default --builder $(CI_BUILD_TAG) --load

.PHONY: build-list
build-list:
@for number in $(foreach image,$(build-images),build/$(image)); do \
echo $$number ; \
done
PLATFORMS=linux/amd64 REPO=lagoon TAG=latest LAGOON_VERSION=$(LAGOON_VERSION) docker buildx bake --builder $(CI_BUILD_TAG) --print | jq '.target[].tags[]'


# Wait for Keycloak to be ready (before this no API calls will work)
.PHONY: wait-for-keycloak
Expand Down Expand Up @@ -279,111 +280,21 @@ broker-up: build/broker-single
####### All main&PR images are pushed to testlagoon repository
#######

# Publish command to testlagoon docker hub, done on any main branch or PR
publish-testlagoon-baseimages = $(foreach image,$(base-images),[publish-testlagoon-baseimages]-$(image))
# tag and push all images

.PHONY: publish-testlagoon-baseimages
publish-testlagoon-baseimages: $(publish-testlagoon-baseimages)
.PHONY: publish-testlagoon-images
publish-testlagoon-images:
PLATFORMS=linux/amd64,linux/arm64 REPO=docker.io/testlagoon TAG=$(BRANCH_NAME) LAGOON_VERSION=$(LAGOON_VERSION) docker buildx bake -f docker-bake.hcl --builder $(CI_BUILD_TAG) --push

# tag and push of each image
.PHONY: $(publish-testlagoon-baseimages)
$(publish-testlagoon-baseimages):
# Calling docker_publish for image, but remove the prefix '[publish-testlagoon-baseimages]-' first
$(eval image = $(subst [publish-testlagoon-baseimages]-,,$@))
# Publish images with version tag
$(call docker_publish_testlagoon,$(image),$(image):$(BRANCH_NAME))


# Publish command to amazeeio docker hub, this should only be done during main deployments
publish-testlagoon-serviceimages = $(foreach image,$(service-images),[publish-testlagoon-serviceimages]-$(image))
# tag and push all images
.PHONY: publish-testlagoon-serviceimages
publish-testlagoon-serviceimages: $(publish-testlagoon-serviceimages)

# tag and push of each image
.PHONY: $(publish-testlagoon-serviceimages)
$(publish-testlagoon-serviceimages):
# Calling docker_publish for image, but remove the prefix '[publish-testlagoon-serviceimages]-' first
$(eval image = $(subst [publish-testlagoon-serviceimages]-,,$@))
# Publish images with version tag
$(call docker_publish_testlagoon,$(image),$(image):$(BRANCH_NAME))

.PHONY: publish-uselagoon-images
publish-uselagoon-images:
PLATFORMS=linux/amd64,linux/arm64 REPO=docker.io/uselagoon TAG=$(LAGOON_VERSION) LAGOON_VERSION=$(LAGOON_VERSION) docker buildx bake -f docker-bake.hcl --builder $(CI_BUILD_TAG) --push
PLATFORMS=linux/amd64,linux/arm64 REPO=docker.io/uselagoon TAG=latest LAGOON_VERSION=$(LAGOON_VERSION) docker buildx bake -f docker-bake.hcl --builder $(CI_BUILD_TAG) --push

# Publish command to amazeeio docker hub, this should only be done during main deployments
publish-testlagoon-taskimages = $(foreach image,$(task-images),[publish-testlagoon-taskimages]-$(image))
# tag and push all images
.PHONY: publish-testlagoon-taskimages
publish-testlagoon-taskimages: $(publish-testlagoon-taskimages)

# tag and push of each image
.PHONY: $(publish-testlagoon-taskimages)
$(publish-testlagoon-taskimages):
# Calling docker_publish for image, but remove the prefix '[publish-testlagoon-taskimages]-' first
$(eval image = $(subst [publish-testlagoon-taskimages]-,,$@))
# Publish images with version tag
$(call docker_publish_testlagoon,$(image),$(image):$(BRANCH_NAME))


#######
####### All tagged releases are pushed to uselagoon repository with new semantic tags
#######

# Publish command to uselagoon docker hub, only done on tags
publish-uselagoon-baseimages = $(foreach image,$(base-images),[publish-uselagoon-baseimages]-$(image))

# tag and push all images
.PHONY: publish-uselagoon-baseimages
publish-uselagoon-baseimages: $(publish-uselagoon-baseimages)

# tag and push of each image
.PHONY: $(publish-uselagoon-baseimages)
$(publish-uselagoon-baseimages):
# Calling docker_publish for image, but remove the prefix '[publish-uselagoon-baseimages]-' first
$(eval image = $(subst [publish-uselagoon-baseimages]-,,$@))
# Publish images as :latest
$(call docker_publish_uselagoon,$(image),$(image):latest)
# Publish images with version tag
$(call docker_publish_uselagoon,$(image),$(image):$(LAGOON_VERSION))


# Publish command to amazeeio docker hub, this should only be done during main deployments
publish-uselagoon-serviceimages = $(foreach image,$(service-images),[publish-uselagoon-serviceimages]-$(image))
# tag and push all images
.PHONY: publish-uselagoon-serviceimages
publish-uselagoon-serviceimages: $(publish-uselagoon-serviceimages)

# tag and push of each image
.PHONY: $(publish-uselagoon-serviceimages)
$(publish-uselagoon-serviceimages):
# Calling docker_publish for image, but remove the prefix '[publish-uselagoon-serviceimages]-' first
$(eval image = $(subst [publish-uselagoon-serviceimages]-,,$@))
# Publish images as :latest
$(call docker_publish_uselagoon,$(image),$(image):latest)
# Publish images with version tag
$(call docker_publish_uselagoon,$(image),$(image):$(LAGOON_VERSION))


# Publish command to amazeeio docker hub, this should only be done during main deployments
publish-uselagoon-taskimages = $(foreach image,$(task-images),[publish-uselagoon-taskimages]-$(image))
# tag and push all images
.PHONY: publish-uselagoon-taskimages
publish-uselagoon-taskimages: $(publish-uselagoon-taskimages)

# tag and push of each image
.PHONY: $(publish-uselagoon-taskimages)
$(publish-uselagoon-taskimages):
# Calling docker_publish for image, but remove the prefix '[publish-uselagoon-taskimages]-' first
$(eval image = $(subst [publish-uselagoon-taskimages]-,,$@))
# Publish images as :latest
$(call docker_publish_uselagoon,$(image),$(image):latest)
# Publish images with version tag
$(call docker_publish_uselagoon,$(image),$(image):$(LAGOON_VERSION))

# Clean all build touches, which will case make to rebuild the Docker Images (Layer caching is
# still active, so this is a very safe command)
.PHONY: clean
clean:
rm -rf build/*
docker buildx rm $(CI_BUILD_TAG)

# Conduct post-release scans on images
.PHONY: scan-images
Expand Down
Loading