Skip to content
Snippets Groups Projects
Commit 6cdab8d2 authored by Alex de Cock Buning's avatar Alex de Cock Buning
Browse files

build: Added build_and_push_images.sh script

This commit introduces a new bash script, build_and_push_images.sh, which automates the process of building and pushing Docker images for l2sm-switch, l2sm-controller, and l2sm-operator.

This script simplifies the image creation and push workflow, providing options for building images, pushing images, or both.
parent 91733342
No related branches found
No related tags found
1 merge request!2repo: added new directory where utils scripts will be
#!/bin/bash
# Set environment variables
export VERSION="2.2"
export DOCKERHUB_REPO="alexdecb"
# Function to build image
build_image() {
local image_name="$1"
local folder_name="$2"
echo "Building ${image_name}..."
docker build -t "${DOCKERHUB_REPO}/${image_name}:${VERSION}" -f "./build/${folder_name}/Dockerfile" .
}
# Function to push image
push_image() {
local image_name="$1"
echo "Pushing ${image_name}..."
docker push "${DOCKERHUB_REPO}/${image_name}:${VERSION}"
}
# Option 1: Build image
if [ "$1" == "build" ]; then
build_image "l2sm-switch" "switch"
build_image "l2sm-controller" "controller"
build_image "l2sm-operator" "operator"
echo "Images have been built successfully."
# Option 2: Push image
elif [ "$1" == "push" ]; then
push_image "l2sm-switch"
push_image "l2sm-controller"
push_image "l2sm-operator"
echo "Images have been pushed successfully."
# Option 3: Build and push image
elif [ "$1" == "build_push" ]; then
build_image "l2sm-switch" "switch"
push_image "l2sm-switch"
build_image "l2sm-controller" "controller"
push_image "l2sm-controller"
build_image "l2sm-operator" "operator"
push_image "l2sm-operator"
echo "Images have been built and pushed successfully."
# Invalid option
else
echo "Invalid option. Please use 'build', 'push', or 'build_push'."
exit 1
fi
...@@ -4,7 +4,7 @@ WORKDIR /usr/src/l2sm-switch ...@@ -4,7 +4,7 @@ WORKDIR /usr/src/l2sm-switch
COPY ./src/switch/ ./build/switch/build-go.sh ./ COPY ./src/switch/ ./build/switch/build-go.sh ./
RUN ./build-go.sh RUN chmod +x ./build-go.sh && ./build-go.sh
FROM ubuntu:latest FROM ubuntu:latest
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment