Skip to content

Commit

Permalink
Increase build timeout pipeline (#20)
Browse files Browse the repository at this point in the history
* Increase build timeout pipeline

Signed-off-by: see-quick <[email protected]>

* add base image to speed up build time

Signed-off-by: see-quick <[email protected]>

* Jakub comments

Signed-off-by: see-quick <[email protected]>

* add a other architectures to build base image

Signed-off-by: see-quick <[email protected]>

* last changes

Signed-off-by: see-quick <[email protected]>

* little bit of debug

Signed-off-by: see-quick <[email protected]>

* build fix

Signed-off-by: see-quick <[email protected]>

* try prepare base and build images in one step

Signed-off-by: see-quick <[email protected]>

* save and load base image

Signed-off-by: see-quick <[email protected]>

* try without cache

Signed-off-by: see-quick <[email protected]>

* add cache back that I know everything works :)

Signed-off-by: see-quick <[email protected]>

* change cache key to bypass old cache

Signed-off-by: see-quick <[email protected]>

---------

Signed-off-by: see-quick <[email protected]>
  • Loading branch information
see-quick authored Oct 8, 2023
1 parent befb634 commit be0f31e
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 9 deletions.
4 changes: 2 additions & 2 deletions .azure/build_pipeline.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ jobs:
- template: "./install_docker.yaml"
- task: Cache@2
inputs:
key: '"kafka_binaries"'
key: '"kafka_binaries_v2"'
path: images
displayName: Kafka Binaries cache
- bash: make prepare
displayName: "Download kafka"
- bash: make docker_build
- bash: make docker_prepare_base_images docker_build
displayName: "Build images"
env:
DOCKER_BUILDKIT: 1
Expand Down
7 changes: 6 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
PROJECT_NAME=test-container
PROJECT_NAME_BASE=base
DOCKERFILE_DIR ?= ./images
DOCKERFILE_BASE_DIR ?= ./images/base
REGISTRY ?= quay.io
REGISTRY_ORGANIZATION ?= strimzi-test-container
IMAGE_TAG ?= main
DOCKER_VERSION_ARG ?= latest
ARCHS ?= amd64

all: prepare docker_build docker_tag_push clean
all: docker_prepare_base_images prepare docker_build docker_tag_push clean

docker_prepare_base_images:
./images/base/build_base_images.sh $(DOCKER_VERSION_ARG) $(PROJECT_NAME_BASE) "$(ARCHS)" $(DOCKERFILE_BASE_DIR)

docker_build:
./images/build_push_images.sh $(DOCKER_VERSION_ARG) $(PROJECT_NAME) $(DOCKERFILE_DIR) "$(ARCHS)"
Expand Down
8 changes: 3 additions & 5 deletions images/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
FROM registry.access.redhat.com/ubi8/ubi-minimal:latest
ARG ARCH=${ARCH}

FROM strimzi/base:latest-$ARCH

ARG KAFKA_VERSION
ARG SCALA_VERSION

USER root

RUN microdnf update \
&& microdnf install java-11-openjdk-headless shadow-utils \
&& microdnf clean all

# Add strimzi user with UID 1001
# The user is in the group 0 to have access to the mounted volumes and storage
RUN useradd -r -m -u 1001 -g 0 strimzi
Expand Down
7 changes: 7 additions & 0 deletions images/base/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM registry.access.redhat.com/ubi8/ubi-minimal:latest

USER root

RUN microdnf update \
&& microdnf --setopt=install_weak_deps=0 --setopt=tsflags=nodocs install java-11-openjdk-headless shadow-utils \
&& microdnf clean all
35 changes: 35 additions & 0 deletions images/base/build_base_images.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/bash

#####
# DOCKER AND PROJECT auxiliary variables
#####
DOCKER_VERSION_ARG=$1
PROJECT_NAME_BASE=$2
ARCHITECTURES=$3
DOCKERFILE_BASE_DIR=$4

CURRENT_TAG=${CURRENT_TAG:-"local"}

####
# BUILD BASE IMAGES
####
for ARCH in $ARCHITECTURES
do
echo "[INFO] Building image with name: strimzi/$PROJECT_NAME_BASE:$CURRENT_TAG-$ARCH)."
docker build --platform linux/$ARCH --build-arg version=$DOCKER_VERSION_ARG -t strimzi/$PROJECT_NAME_BASE:$CURRENT_TAG-$ARCH $DOCKERFILE_BASE_DIR

# "refresh" Docker's awareness of the image
docker save strimzi/$PROJECT_NAME_BASE:$CURRENT_TAG-$ARCH -o strimzi_base_$ARCH.tar
docker load -i strimzi_base_$ARCH.tar
# tagging this image eliminate this error
# ```
# ERROR: failed to solve: strimzi/base:local: pull access denied, repository does not exist or may require authorization: server message: insufficient_scope: authorization failed
# ```
# May be more likely to recognize this new tag as a local entity without trying to fetch it from a remote repository.
# This specific tagging can help in resolving ambiguities that Docker might have had with the original image name and tag.
docker tag strimzi/$PROJECT_NAME_BASE:$CURRENT_TAG-$ARCH strimzi/$PROJECT_NAME_BASE:latest-$ARCH``
done

# PRINT ALL IMAGES
docker images

5 changes: 4 additions & 1 deletion images/build_push_images.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ PROJECT_NAME=$2
DOCKERFILE_DIR=$3
ARCHITECTURES=$4

# PRINT ALL IMAGES
docker images

#####
# FOR EACH KAFKA VERSION BUILD IMAGE WITH DIFFERENT TAG (i.e., 'strimzi-test-container/test-container:0.1.0-kafka-2.8.1)
#####
Expand All @@ -34,7 +37,7 @@ do
for ARCH in $ARCHITECTURES
do
echo "[INFO] Building image with name: strimzi-test-container/$PROJECT_NAME:$CURRENT_TAG-$ARCH $KAFKA_VERSION with $SCALA_VERSION)."
docker build --platform linux/$ARCH --build-arg version=$DOCKER_VERSION_ARG --build-arg KAFKA_VERSION=$KAFKA_VERSION --build-arg SCALA_VERSION=$SCALA_VERSION -t strimzi/$PROJECT_NAME:$CURRENT_TAG-$ARCH $DOCKERFILE_DIR
docker build --platform linux/$ARCH --build-arg version=$DOCKER_VERSION_ARG --build-arg KAFKA_VERSION=$KAFKA_VERSION --build-arg SCALA_VERSION=$SCALA_VERSION --build-arg ARCH=$ARCH -t strimzi/$PROJECT_NAME:$CURRENT_TAG-$ARCH $DOCKERFILE_DIR
done
done

Expand Down

0 comments on commit be0f31e

Please sign in to comment.