All checks were successful
Build and push Docker image in git push / build (push) Successful in 4m58s
54 lines
1.4 KiB
Bash
Executable File
54 lines
1.4 KiB
Bash
Executable File
#/bin/bash
|
|
|
|
# https://stackoverflow.com/a/4774063
|
|
SCRIPTPATH="$(cd -- "$(dirname "$0")" >/dev/null 2>&1; pwd -P)"
|
|
|
|
source "$SCRIPTPATH/vars.sh"
|
|
|
|
requirements="requirements-frozen.txt"
|
|
if [ "$1" != "-no-updates" ]; then
|
|
echo "Update the depencendies in requirements.txt? [may break app] (y/n)"
|
|
read newlockfile
|
|
if [ "$newlockfile" == "y" ]; then
|
|
requirements="requirements.txt"
|
|
fi;
|
|
fi;
|
|
|
|
for platform in $PLATFORMS; do
|
|
if [ "$platform" == "gpu" ]; then
|
|
platform="amd64"
|
|
from_image="$IMAGE_REGISTRY/$IMAGE_OWNER/$IMAGE_NAME:tmp-local-only"
|
|
tag_image="$IMAGE_REGISTRY/$IMAGE_OWNER/$IMAGE_NAME:gpu-amd64"
|
|
|
|
docker build \
|
|
--pull \
|
|
--platform "linux/$platform" \
|
|
--file "$SCRIPTPATH/docker/Dockerfile.gpu" \
|
|
--tag "$from_image" \
|
|
"$SCRIPTPATH"
|
|
else
|
|
from_image="$CPU_BASEIMAGE"
|
|
tag_image="$IMAGE_REGISTRY/$IMAGE_OWNER/$IMAGE_NAME:cpu-$platform"
|
|
|
|
docker pull --platform "linux/$platform" "$BASEIMAGE"
|
|
fi;
|
|
|
|
docker build \
|
|
--platform "linux/$platform" \
|
|
--file "$SCRIPTPATH/docker/Dockerfile" \
|
|
--build-arg FROM_IMAGE="$from_image" \
|
|
--build-arg H_UID=1050 \
|
|
--build-arg PIP_REQ_FILE="$requirements" \
|
|
--build-arg H_GID=1050 \
|
|
--tag "$tag_image" \
|
|
"$SCRIPTPATH"
|
|
done;
|
|
|
|
if [ "$requirements" == "requirements.txt" ]; then
|
|
# extract requirements-frozen.txt
|
|
cid=$(docker create "$tag_image")
|
|
docker cp "$cid:/ums-agenten/requirements.txt" "$SCRIPTPATH/docker/requirements-frozen.txt"
|
|
docker rm "$cid"
|
|
fi;
|
|
|