Skip to content

Commit

Permalink
Make registry configurable in build script
Browse files Browse the repository at this point in the history
Signed-off-by: gabriel-farache <[email protected]>
  • Loading branch information
gabriel-farache committed Jan 27, 2025
1 parent 648edc3 commit fcc66e8
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
2 changes: 1 addition & 1 deletion 01_basic/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Use the scripts:
* Build and push the image:
```
cd ..
WORKFLOW_ID=basic WORKFLOW_FOLDER=01_basic ./scripts/build-push.sh
WORKFLOW_ID=basic WORKFLOW_FOLDER=01_basic WORKFLOW_IMAGE_REGISTRY=quay.io WORKFLOW_IMAGE_NAMESPACE=orchestrator ./scripts/build-push.sh
```
* Generate manifests that have to be applied on the OCP cluster wiht RHDH and OSL:
```
Expand Down
2 changes: 1 addition & 1 deletion 02_advanced/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ Application properties can be initialized from environment variables before runn
Use the scripts:
* Build and push the image:
```
WORKFLOW_ID=create-ocp-project WORKFLOW_FOLDER=02_advanced ./scripts/build-push.sh
WORKFLOW_ID=create-ocp-project WORKFLOW_FOLDER=02_advanced WORKFLOW_IMAGE_REGISTRY=quay.io WORKFLOW_IMAGE_NAMESPACE=orchestrator ./scripts/build-push.sh
```
* Generate manifests that have to be applied on the OCP cluster wiht RHDH and OSL:
```
Expand Down
13 changes: 12 additions & 1 deletion scripts/build-push.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ function usage {
echo -e "Usage: WORKFLOW_ID=WORKFLOW_ID WORKFLOW_FOLDER=WORKFLOW_FOLDER $program_name"
echo " WORKFLOW_ID ID of the workflow to build and push"
echo " WORKFLOW_FOLDER Path of the directory containing the workflow's files"
echo " WORKFLOW_IMAGE_REGISTRY Registry name to which the image will be pushed. I.E: quay.io"
echo " WORKFLOW_IMAGE_NAMESPACE Name of the registry's namespace in which store the image. I.E: orchestrator"
exit 1
}

Expand All @@ -18,6 +20,15 @@ if [[ -z "${WORKFLOW_FOLDER}" ]]; then
usage
fi

if [[ -z "${WORKFLOW_IMAGE_REGISTRY}" ]]; then
echo 'Error: WORKFLOW_IMAGE_REGISTRY env variable must be set with the image registry name; e.g: quay.io'
usage
fi

if [[ -z "${WORKFLOW_IMAGE_NAMESPACE}" ]]; then
echo "Error: WORKFLOW_IMAGE_NAMESPACE env variable must be set with the name of the namespace's registry in which store the image; e.g: orchestrator"
usage
fi

WORKDIR=$(mktemp -d)
echo "Workdir: ${WORKDIR}"
Expand All @@ -29,7 +40,7 @@ cd "${WORKDIR}"
rm -rf **/target
mv ${WORKFLOW_FOLDER}/src/main/resources ${WORKFLOW_FOLDER}/.

IMAGE_NAME=quay.io/orchestrator/demo-${WORKFLOW_ID}
IMAGE_NAME=${WORKFLOW_IMAGE_REGISTRY}/${WORKFLOW_IMAGE_NAMESPACE}/demo-${WORKFLOW_ID}
IMAGE_TAG=$(git rev-parse --short=8 HEAD)

docker build -f resources/workflow-builder.Dockerfile --build-arg WF_RESOURCES=${WORKFLOW_FOLDER} --ulimit nofile=4096:4096 --tag ${IMAGE_NAME}:${IMAGE_TAG} --tag ${IMAGE_NAME}:latest .
Expand Down

0 comments on commit fcc66e8

Please sign in to comment.