Skip to content

Commit

Permalink
docker: use shorter tags
Browse files Browse the repository at this point in the history
Signed-off-by: Vitor Bandeira <[email protected]>
  • Loading branch information
Vitor Bandeira committed Jul 3, 2024
1 parent 9112979 commit e227c3d
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 36 deletions.
62 changes: 26 additions & 36 deletions etc/DockerHelper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ usage: $0 [CMD] [OPTIONS]
'builder': os + packages to compile app +
copy source code and build app
-threads Max number of threads to use if compiling.
-sha Use git commit sha as the tag image. Default is
'latest'.
Default = \$(nproc)
-ci Install CI tools in image
-h -help Show this message and exits
-username Docker Username
Expand All @@ -36,7 +35,6 @@ EOF
}

_setup() {
commitSha="$(git rev-parse HEAD | tr -cd 'a-zA-Z0-9-')"
case "${os}" in
"ubuntu20.04")
osBaseImage="ubuntu:20.04"
Expand All @@ -50,9 +48,10 @@ _setup() {
;;
esac
imageName="${IMAGE_NAME_OVERRIDE:-"${org}/flow-${os}-${target}"}"
imageTag="${commitSha}"
if [[ "${tag}" != "NONE" ]]; then
if [[ "${tag}" != "" ]]; then
imageTag="${tag}"
else
imageTag=$(./etc/DockerTag.sh -dev)
fi
case "${target}" in
"builder" | "master")
Expand Down Expand Up @@ -95,43 +94,34 @@ _push() {
echo "Missing required -password=<PASS> argument"
_help
fi
docker login --username ${username} --password ${password}
if [[ "${tag}" == "NONE" ]]; then
tag="latest"
if [[ "${target}" != "dev" ]] && [[ "${target}" != "master" ]]; then
echo "Target ${target} is not valid candidate for push to Docker Hub." >&2
_help
fi
mkdir -p build
case "${target}" in
"dev" )
./etc/DockerHelper.sh create -os=${os} -ci -target=${target} \
2>&1 | tee build/create-${os}-${target}-${tag}.log
docker push ${imagePath}
;;

"master" )
# Create dev image needed as a base for builder image
./etc/DockerHelper.sh create -os=${os} -target=dev \
2>&1 | tee build/create-${os}-dev-${target}-${tag}.log
# Create builder image
./etc/DockerHelper.sh create -os=${os} -target=builder \
2>&1 | tee build/create-${os}-${target}-${tag}.log
docker login --username "${username}" --password "${password}"

docker push ${org}/flow-${os}-dev:${commitSha}
if [[ "${tag}" == "" ]]; then
tag=$(./etc/DockerTag.sh -dev)
fi

docker tag ${org}/flow-${os}-dev:${commitSha} ${org}/flow-${os}-dev:latest
docker push ${org}/flow-${os}-dev:latest
mkdir -p build
./etc/DockerHelper.sh create -os=${os} -target=dev -tag=${tag} -ci \
2>&1 | tee build/create-${os}-dev-${tag}.log

docker tag ${org}/flow-${os}-builder:${commitSha} ${org}/orfs:${commitSha}
docker push ${org}/orfs:${commitSha}
docker push "${imageName}:${tag}"

docker tag ${org}/flow-${os}-builder:${commitSha} ${org}/orfs:${tag}
docker push ${org}/orfs:${tag}
;;
if [[ "${target}" == "master" ]]; then
tag=$(./etc/DockerTag.sh -master)
# Create builder image
./etc/DockerHelper.sh create -os=${os} -target=builder -tag=${tag} \
2>&1 | tee build/create-${os}-${target}-${tag}.log

*)
echo "Target ${target} is not valid candidate for push to Docker Hub." >&2
_help
;;
esac
docker tag ${org}/flow-${os}-builder:${tag} ${org}/orfs:${tag}
docker push ${org}/orfs:${tag}
docker tag ${org}/flow-${os}-builder:${tag} ${org}/orfs:${tag}
docker push ${org}/orfs:${tag}
fi
}

#
Expand Down Expand Up @@ -161,7 +151,7 @@ fi
os="ubuntu22.04"
target="dev"
numThreads="-1"
tag="NONE"
tag=""
options=""

while [ "$#" -gt 0 ]; do
Expand Down
23 changes: 23 additions & 0 deletions etc/DockerTag.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env bash

cd $(dirname $(realpath $0))/../

if [[ "$@" == "-dev" ]]; then
file_list=(
"./build_openroad.sh"
"./docker/Dockerfile.builder"
"./docker/Dockerfile.dev"
"./etc/DependencyInstaller.sh"
"./etc/DockerHelper.sh"
"./tools/OpenROAD/docker/Dockerfile.builder"
"./tools/OpenROAD/docker/Dockerfile.dev"
"./tools/OpenROAD/docker/Dockerfile.binary"
"./tools/OpenROAD/etc/DependencyInstaller.sh"
)
cat "${file_list[@]}" | sha256sum | awk '{print substr($1, 1, 6)}'
elif [[ "$@" == "-master" ]]; then
git describe
else
echo "Usage: $0 {-dev|-master}"
exit 1
fi

0 comments on commit e227c3d

Please sign in to comment.