Docker Base Image Begin
This commit is contained in:
53
build-images.sh
Executable file
53
build-images.sh
Executable file
@@ -0,0 +1,53 @@
|
||||
#/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="tmp_local/gpu_baseimage:amd64"
|
||||
tag_image="$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_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;
|
||||
|
||||
Reference in New Issue
Block a user