Compare commits
8 Commits
0b2254336c
...
0.1
| Author | SHA1 | Date | |
|---|---|---|---|
|
ec4c0d09a6
|
|||
|
7c54edc17b
|
|||
|
a29d22aff2
|
|||
|
bc78d63da2
|
|||
|
58b4e61fd0
|
|||
|
cd10376a3e
|
|||
|
dc5833730c
|
|||
|
82e2cc3167
|
10
README.md
10
README.md
@@ -14,3 +14,13 @@ podman-compose.yml
|
|||||||
container-compose.yaml
|
container-compose.yaml
|
||||||
container-compose.yml
|
container-compose.yml
|
||||||
```
|
```
|
||||||
|
|
||||||
|
# Install system-wide
|
||||||
|
**WARNING: DO NOT RUN RANDOM COMMANDS OFF THE INTERNET LIKE THIS, READ WHAT IT DOES AND RUN ONLY IF YOU CAN TRUST IT!**
|
||||||
|
*anyway..*
|
||||||
|
```bash
|
||||||
|
sudo curl -L https://git.shihaam.dev/shihaam/container-compose/raw/branch/main/container-compose -o /usr/local/bin/container-compose \
|
||||||
|
&& sudo chmod +x /usr/local/bin/container-compose
|
||||||
|
```
|
||||||
|
Run the same command again to update it.
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ check_file() {
|
|||||||
shift # Remove build from positional parameters
|
shift # Remove build from positional parameters
|
||||||
;;
|
;;
|
||||||
push)
|
push)
|
||||||
push=push
|
push=true
|
||||||
shift # Remove build from positional parameters
|
shift # Remove build from positional parameters
|
||||||
;;
|
;;
|
||||||
pull)
|
pull)
|
||||||
@@ -131,18 +131,68 @@ build(){
|
|||||||
|
|
||||||
platform=$(yq e ".services.$service.platform" "$file")
|
platform=$(yq e ".services.$service.platform" "$file")
|
||||||
image=$(yq e ".services.$service.image" "$file")
|
image=$(yq e ".services.$service.image" "$file")
|
||||||
|
build=$(yq e ".services.$service.build" "$file")
|
||||||
context=$(yq e ".services.$service.build.context" "$file")
|
context=$(yq e ".services.$service.build.context" "$file")
|
||||||
dockerfile=$(yq e ".services.$service.build.dockerfile" "$file")
|
dockerfile=$(yq e ".services.$service.build.dockerfile" "$file")
|
||||||
# Replace '/' and ':' with '-' in the platform string to make it suitable for a tag
|
# Replace '/' and ':' with '-' in the platform string to make it suitable for a tag
|
||||||
platform_tag=$(echo "$platform" | tr '/:' '-')
|
platform_tag=$(echo "$platform" | tr '/:' '-')
|
||||||
# Append platform information to the image tag
|
# Append platform information to the image tag
|
||||||
new_image_tag="${image}-${platform_tag}"
|
new_image_tag="${image}-${platform_tag}"
|
||||||
|
|
||||||
$engine buildx build --platform $platform -t $new_image_tag -f $context/$dockerfile $context
|
# If dockerfile is null or empty, set it to "Dockerfile"
|
||||||
|
if [ -z "$dockerfile" ]; then
|
||||||
|
dockerfile="Dockerfile"
|
||||||
|
fi
|
||||||
|
if [ -z "$context" ]; then
|
||||||
|
context="."
|
||||||
|
fi
|
||||||
|
$engine buildx build --platform $platform -t $new_image_tag -f $context/$dockerfile $context --load
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
#push(){
|
push(){
|
||||||
#}
|
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")
|
||||||
|
build=$(yq e ".services.$service.build" "$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}"
|
||||||
|
|
||||||
|
# If dockerfile is null or empty, set it to "Dockerfile"
|
||||||
|
if [ -z "$dockerfile" ]; then
|
||||||
|
dockerfile="Dockerfile"
|
||||||
|
fi
|
||||||
|
if [ -z "$context" ]; then
|
||||||
|
context="."
|
||||||
|
fi
|
||||||
|
echo push both tags cmd: $engine push $new_image_tag
|
||||||
|
$engine push $new_image_tag
|
||||||
|
done
|
||||||
|
################################################################ BOTH IMAGES PUSHED
|
||||||
|
manifest_create_cmd="$engine manifest create $image"
|
||||||
|
echo $manifest_create_cmd
|
||||||
|
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")
|
||||||
|
# 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}"
|
||||||
|
|
||||||
|
manifest_create_cmd+=" $new_image_tag"
|
||||||
|
done
|
||||||
|
echo Manifest Create cmd: $manifest_create_cmd
|
||||||
|
$manifest_create_cmd
|
||||||
|
#########################################
|
||||||
|
echo manifest push cmd: $engine manifest push $image
|
||||||
|
$engine manifest push $image
|
||||||
|
}
|
||||||
|
|
||||||
pull(){
|
pull(){
|
||||||
services=$(yq e '.services | keys | .[]' "$file")
|
services=$(yq e '.services | keys | .[]' "$file")
|
||||||
@@ -156,4 +206,7 @@ if [ "$pull" = true ]; then
|
|||||||
pull
|
pull
|
||||||
elif [ "$build" = true ]; then
|
elif [ "$build" = true ]; then
|
||||||
build
|
build
|
||||||
|
elif [ "$push" = true ]; then
|
||||||
|
# echo push
|
||||||
|
push
|
||||||
fi
|
fi
|
||||||
|
|||||||
16
testtag.sh
Executable file
16
testtag.sh
Executable file
@@ -0,0 +1,16 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
image="nginx:latest"
|
||||||
|
platforms=("amd64" "arm64")
|
||||||
|
engine="docker"
|
||||||
|
|
||||||
|
# Start the command string
|
||||||
|
cmd="$engine manifest create $image"
|
||||||
|
|
||||||
|
# Append each platform-specific image to the command string
|
||||||
|
for platform in "${platforms[@]}"; do
|
||||||
|
cmd+=" $image-$platform"
|
||||||
|
done
|
||||||
|
|
||||||
|
# Output the complete command string
|
||||||
|
echo "$cmd"
|
||||||
Reference in New Issue
Block a user