added support to build
This commit is contained in:
parent
906513b27b
commit
0b2254336c
@ -3,6 +3,10 @@
|
||||
check_file() {
|
||||
file=""
|
||||
engine=""
|
||||
pull="false"
|
||||
push="false"
|
||||
build="false"
|
||||
|
||||
local opt
|
||||
local OPTARG
|
||||
local OPTIND=1
|
||||
@ -14,6 +18,18 @@ check_file() {
|
||||
engine="${arg#*=}"
|
||||
shift # Remove --engine= from positional parameters
|
||||
;;
|
||||
build)
|
||||
build=true
|
||||
shift # Remove build from positional parameters
|
||||
;;
|
||||
push)
|
||||
push=push
|
||||
shift # Remove build from positional parameters
|
||||
;;
|
||||
pull)
|
||||
pull=true
|
||||
shift # Remove build from positional parameters
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
@ -107,3 +123,37 @@ for service in $services; do
|
||||
echo "Dockerfile: $dockerfile"
|
||||
echo "---------------------"
|
||||
done
|
||||
|
||||
|
||||
build(){
|
||||
services=$(yq e '.services | keys | .[]' "$file")
|
||||
for service in $services; do
|
||||
|
||||
platform=$(yq e ".services.$service.platform" "$file")
|
||||
image=$(yq e ".services.$service.image" "$file")
|
||||
context=$(yq e ".services.$service.build.context" "$file")
|
||||
dockerfile=$(yq e ".services.$service.build.dockerfile" "$file")
|
||||
# Replace '/' and ':' with '-' in the platform string to make it suitable for a tag
|
||||
platform_tag=$(echo "$platform" | tr '/:' '-')
|
||||
# Append platform information to the image tag
|
||||
new_image_tag="${image}-${platform_tag}"
|
||||
|
||||
$engine buildx build --platform $platform -t $new_image_tag -f $context/$dockerfile $context
|
||||
done
|
||||
}
|
||||
#push(){
|
||||
#}
|
||||
|
||||
pull(){
|
||||
services=$(yq e '.services | keys | .[]' "$file")
|
||||
for service in $services; do
|
||||
$engine pull $(yq e ".services.$service.image" "$file")
|
||||
done
|
||||
}
|
||||
|
||||
# If pull argument is provided, then pull
|
||||
if [ "$pull" = true ]; then
|
||||
pull
|
||||
elif [ "$build" = true ]; then
|
||||
build
|
||||
fi
|
||||
|
Loading…
x
Reference in New Issue
Block a user