FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
stackrox/scripts/ensure_image.sh at master · stackrox/stackrox · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
stackrox
/
stackrox
Public
Notifications
You must be signed in to change notification settings
Fork
191
Star
1.3k
Code
Issues
54
Pull requests
604
Actions
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Security and quality
Insights
Expand file tree
Breadcrumbs
stackrox
/
scripts
/
ensure_image.sh
Copy path
More file actions
More file actions
Latest commit
History
History
History
executable file
·
47 lines (40 loc) · 1.5 KB
Breadcrumbs
stackrox
/
scripts
/
ensure_image.sh
Copy path
File metadata and controls
executable file
·
47 lines (40 loc) · 1.5 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!
/usr/bin/env bash
#
# This script takes in an image, as well as instructions on how to build it (via a Dockerfile and a build dir).
#
# First, it tries to pull the image. If it succeeds, it exits.
#
# If not, it builds the image. If run in CI, it also pushes the image.
CONTAINER_ENGINE=
"
${CONTAINER_ENGINE
:-
docker}
"
die
() {
echo
>&2
"
$@
"
exit
1
}
image=
"
$1
"
dockerfile=
"
$2
"
dir=
"
$3
"
[[
-n
"
${image}
"
&&
-n
"
${dockerfile}
"
&&
-n
"
${dir}
"
]]
||
die
"
Usage
$0
<image> <dockerfile_path> <dir>
"
echo
"
Potentially pulling image
${image}
"
docker_pull_output=
"
$(
${CONTAINER_ENGINE}
pull
"
${image}
"
2>&1
)
"
if
[[
"
$?
"
-eq
0 ]]
;
then
echo
"
Image exists. Exiting...
"
exit
0
fi
if
[[
!
"
${docker_pull_output}
"
=~
^.
*
manifest
\
for.
*
not
\
found.
*
$ ]]
;
then
die
"
Unexpected
${CONTAINER_ENGINE}
pull error:
${docker_pull_output}
"
fi
set
-e
echo
"
Building the image since it doesn't exist
"
${CONTAINER_ENGINE}
build -t
"
${image}
"
-f
"
${dockerfile}
"
"
${dir}
"
if
[[
-n
"
${CI}
"
]]
;
then
case
"
$image
"
in
quay.io/rhacs-eng/
*
)
${CONTAINER_ENGINE}
login -u
"
$QUAY_RHACS_ENG_RW_USERNAME
"
--password-stdin
<<<
"
$QUAY_RHACS_ENG_RW_PASSWORD
"
quay.io
;;
quay.io/stackrox-io/
*
)
${CONTAINER_ENGINE}
login -u
"
$QUAY_STACKROX_IO_RW_USERNAME
"
--password-stdin
<<<
"
$QUAY_STACKROX_IO_RW_PASSWORD
"
quay.io
;;
*
)
die
"
Unsupported registry of image:
$image
"
esac
${CONTAINER_ENGINE}
push
"
${image}
"
|
cat
else
echo
"
Not in CI, not pushing the new image...
"
fi
Back
|
FazBrowse Home
|
New Git URL