@@ -18,26 +18,26 @@ usage: $0 [CMD] [OPTIONS]
1818 push Push the docker image to Docker Hub
1919
2020 OPTIONS:
21- -os=OS_NAME Choose beween centos7 (default), ubuntu20.04 and ubuntu22.04.
21+ -os=OS_NAME Choose beween ubuntu20.04 and ubuntu22.04 (default) .
2222 -target=TARGET Choose target fo the Docker image:
2323 'dev': os + packages to compile app
2424 'builder': os + packages to compile app +
2525 copy source code and build app
2626 -threads Max number of threads to use if compiling.
2727 -sha Use git commit sha as the tag image. Default is
2828 'latest'.
29+ -ci Install CI tools in image
2930 -h -help Show this message and exits
31+ -username Docker Username
32+ -password Docker Password
3033
3134EOF
3235 exit " ${1:- 1} "
3336}
3437
3538_setup () {
36- commitSha=" $( git rev-parse HEAD) "
39+ commitSha=" $( git rev-parse HEAD | tr -cd ' a-zA-Z0-9- ' ) "
3740 case " ${os} " in
38- " centos7" )
39- osBaseImage=" centos:centos7"
40- ;;
4141 " ubuntu20.04" )
4242 osBaseImage=" ubuntu:20.04"
4343 ;;
@@ -50,13 +50,12 @@ _setup() {
5050 ;;
5151 esac
5252 imageName=" ${IMAGE_NAME_OVERRIDE:- " ${org} /flow-${os} -${target} " } "
53- if [[ " ${useCommitSha} " == " yes" ]]; then
54- imageTag=" ${commitSha} "
55- else
56- imageTag=" latest"
53+ imageTag=" ${commitSha} "
54+ if [[ " ${tag} " != " NONE" ]]; then
55+ imageTag=" ${tag} "
5756 fi
5857 case " ${target} " in
59- " builder" )
58+ " builder" | " master " )
6059 fromImage=" ${FROM_IMAGE_OVERRIDE:- " ${org} /flow-${os} -dev" } :${imageTag} "
6160 context=" ."
6261 buildArgs=" --build-arg numThreads=${numThreads} "
@@ -65,7 +64,7 @@ _setup() {
6564 fromImage=" ${FROM_IMAGE_OVERRIDE:- $osBaseImage } "
6665 cp tools/OpenROAD/etc/DependencyInstaller.sh etc/InstallerOpenROAD.sh
6766 context=" etc"
68- buildArgs=" "
67+ buildArgs=" --build-arg options= ${options} "
6968 ;;
7069 * )
7170 echo " Target ${target} not found" >&2
@@ -79,38 +78,51 @@ _setup() {
7978
8079_create () {
8180 echo " Create docker image ${imagePath} using ${file} "
82- docker build --file " ${file} " --tag " ${imagePath} " ${buildArgs} " ${context} "
81+ docker build \
82+ --file " ${file} " \
83+ --tag " ${imagePath} " \
84+ ${buildArgs} \
85+ " ${context} " \
86+ --progress plain
8387 rm -f etc/InstallerOpenROAD.sh
8488}
8589
8690_push () {
91+ if [[ -z ${username+x} ]]; then
92+ echo " Missing required -username=<USER> argument"
93+ _help
94+ fi
95+ if [[ -z ${password+x} ]]; then
96+ echo " Missing required -password=<PASS> argument"
97+ _help
98+ fi
99+ docker login --username ${username} --password ${password}
100+ if [[ " ${tag} " == " NONE" ]]; then
101+ tag=" latest"
102+ fi
103+ mkdir -p build
87104 case " ${target} " in
88105 " dev" )
89- read -p " Will push docker image ${imagePath} to DockerHub [y/N]" -n 1 -r
90- echo
91- if [[ $REPLY =~ ^[Yy]$ ]]; then
92- mkdir -p build
93-
94- OS_LIST=" centos7 ubuntu20.04 ubuntu22.04"
95- # create image with sha and latest tag for all os
96- for os in ${OS_LIST} ; do
97- ./etc/DockerHelper.sh create -target=dev \
98- 2>&1 | tee build/create-${os} -latest.log
99- ./etc/DockerHelper.sh create -target=dev -sha \
100- 2>&1 | tee build/create-${os} -${commitSha} .log
101- done
102-
103- for os in ${OS_LIST} ; do
104- echo [DRY-RUN] docker push openroad/flow-${os} -dev:latest
105- echo [DRY-RUN] docker push openroad/flow-${os} -dev:${commitSha}
106- done
107-
108- else
109- echo " Will not push."
110- fi
106+ ./etc/DockerHelper.sh create -os=${os} -ci -target=${target} \
107+ 2>&1 | tee build/create-${os} -${target} -${tag} .log
108+ docker push ${imagePath}
111109 ;;
110+
111+ " master" )
112+ # Create dev image needed as a base for builder image
113+ ./etc/DockerHelper.sh create -os=${os} -target=dev \
114+ 2>&1 | tee build/create-${os} -dev-${target} -${tag} .log
115+ # Create builder image
116+ ./etc/DockerHelper.sh create -os=${os} -target=builder \
117+ 2>&1 | tee build/create-${os} -${target} -${tag} .log
118+ docker push ${org} /flow-${os} -dev:${commitSha}
119+ docker push ${org} /flow-${os} -dev:${commitSha} ${org} /flow-${os} -dev:latest
120+ docker push ${org} /flow-${os} -builder:${commitSha} ${org} /orfs:${commitSha}
121+ docker push ${org} /flow-${os} -builder:${commitSha} ${org} /orfs:${tag}
122+ ;;
123+
112124 * )
113- echo " Target ${target} is not valid candidate for push to DockerHub ." >&2
125+ echo " Target ${target} is not valid candidate for push to Docker Hub ." >&2
114126 _help
115127 ;;
116128 esac
@@ -139,17 +151,21 @@ if [[ -z $(command -v "${_rule}") ]]; then
139151 _help
140152fi
141153
142- # default values, can be overwritten by cmdline args
143- os=" centos7 "
154+ # default values, can be overwritten by command line arguments
155+ os=" ubuntu22.04 "
144156target=" dev"
145- useCommitSha=" no"
146157numThreads=" -1"
158+ tag=" NONE"
159+ options=" "
147160
148161while [ " $# " -gt 0 ]; do
149162 case " ${1} " in
150163 -h|-help)
151164 _help 0
152165 ;;
166+ -ci )
167+ options=" -ci"
168+ ;;
153169 -os=* )
154170 os=" ${1#* =} "
155171 ;;
@@ -159,10 +175,16 @@ while [ "$#" -gt 0 ]; do
159175 -threads=* )
160176 numThreads=" ${1#* =} "
161177 ;;
162- -sha )
163- useCommitSha=yes
178+ -username=* )
179+ username=" ${1#* =} "
180+ ;;
181+ -password=* )
182+ password=" ${1#* =} "
183+ ;;
184+ -tag=* )
185+ tag=" ${1#* =} "
164186 ;;
165- -os | -target )
187+ -os | -target | -threads | -username | -password | -tag )
166188 echo " ${1} requires an argument" >&2
167189 _help
168190 ;;
0 commit comments