Skip to content

Commit

Permalink
[#61287] WIP: etc: DockerHelper.sh: Build with registry cache
Browse files Browse the repository at this point in the history
Adds an option to use remote GitHub registry cache.

Signed-off-by: Illia Vysochyn <[email protected]>
  • Loading branch information
ivysochyn committed Jul 1, 2024
1 parent e13e22a commit 6139784
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion etc/DockerHelper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ usage: $0 [CMD] [OPTIONS]
-threads Max number of threads to use if compiling.
-sha Use git commit sha as the tag image. Default is
'latest'.
-cache Use remote registry cache when building the image.
-h -help Show this message and exits
EOF
Expand Down Expand Up @@ -60,12 +61,20 @@ _setup() {
fromImage="${FROM_IMAGE_OVERRIDE:-"${org}/flow-${os}-dev"}:${imageTag}"
context="."
buildArgs="--build-arg numThreads=${numThreads}"
cacheArgs=""
if [[ "${useCache}" == "yes" ]]; then
cacheArgs="--cache-from type=registry,ref=ghcr.io/antmicro/openroad-flow-scripts-test-cache/${os}"
fi
;;
"dev" )
fromImage="${FROM_IMAGE_OVERRIDE:-$osBaseImage}"
cp tools/OpenROAD/etc/DependencyInstaller.sh etc/InstallerOpenROAD.sh
context="etc"
buildArgs=""
cacheArgs=""
if [[ "${useCache}" == "yes" ]]; then
cacheArgs="--cache-from type=registry,ref=ghcr.io/antmicro/openroad-flow-scripts-test-cache-deps/${os}"
fi
;;
*)
echo "Target ${target} not found" >&2
Expand All @@ -79,7 +88,11 @@ _setup() {

_create() {
echo "Create docker image ${imagePath} using ${file}"
docker build --file "${file}" --tag "${imagePath}" ${buildArgs} "${context}"
if docker buildx version > /dev/null 2>&1; then
docker buildx build --load=true --file "${file}" ${cacheArgs} --tag "${imagePath}" ${buildArgs} "${context}"
else
docker build --file "${file}" ${cacheArgs} --tag "${imagePath}" ${buildArgs} "${context}"
fi
rm -f etc/InstallerOpenROAD.sh
}

Expand Down Expand Up @@ -143,6 +156,7 @@ fi
os="centos7"
target="dev"
useCommitSha="no"
useCache="no"
numThreads="-1"

while [ "$#" -gt 0 ]; do
Expand All @@ -166,6 +180,9 @@ while [ "$#" -gt 0 ]; do
echo "${1} requires an argument" >&2
_help
;;
-cache )
useCache=yes
;;
*)
echo "unknown option: ${1}" >&2
_help
Expand Down

0 comments on commit 6139784

Please sign in to comment.