Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
W
wallet-dapp
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
hive
wallet-dapp
Commits
c1ed19f9
Commit
c1ed19f9
authored
5 days ago
by
Bartek Wrona
Browse files
Options
Downloads
Patches
Plain Diff
Defined a script to build application image
parent
2ae41a5b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!1
Prepared definition of application docker image
Pipeline
#118421
passed
5 days ago
Stage: build
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
scripts/ci-helpers/build_instance.sh
+125
-0
125 additions, 0 deletions
scripts/ci-helpers/build_instance.sh
with
125 additions
and
0 deletions
scripts/ci-helpers/build_instance.sh
0 → 100755
+
125
−
0
View file @
c1ed19f9
#! /bin/bash
set
-euo
pipefail
SCRIPTPATH
=
"
$(
cd
--
"
$(
dirname
"
$0
"
)
"
>
/dev/null 2>&1
;
pwd
-P
)
"
SCRIPTSDIR
=
"
$SCRIPTPATH
/.."
print_help
()
{
cat
<<-
EOF
Usage:
$0
<image_tag> <src_dir> <registry_url> [OPTION[=VALUE]]...
Builds docker image containing Hive Bridge application installation, ready to run. To spawn it, just run a container and map port 8080 to the host.
OPTIONS:
--help|-h|-? Display this help screen and exit
--progress=TYPE Determines how to display build progress (default: 'auto')
--push Allows to automatically push built image to the registry
EOF
}
PROGRESS_DISPLAY
=
${
PROGRESS_DISPLAY
:-
"auto"
}
IMAGE_OUTPUT
=
"--load"
BUILD_IMAGE_TAG
=
""
REGISTRY
=
""
SRCROOTDIR
=
""
while
[
$#
-gt
0
]
;
do
case
"
$1
"
in
--help
|
-h
|
-?
)
print_help
exit
0
;;
--progress
=
*
)
arg
=
"
${
1
#*=
}
"
PROGRESS_DISPLAY
=
"
$arg
"
;;
--push
)
IMAGE_OUTPUT
=
"--push"
;;
*
)
if
[
-z
"
$BUILD_IMAGE_TAG
"
]
;
then
BUILD_IMAGE_TAG
=
"
${
1
}
"
elif
[
-z
"
$SRCROOTDIR
"
]
;
then
SRCROOTDIR
=
"
${
1
}
"
elif
[
-z
"
$REGISTRY
"
]
;
then
REGISTRY
=
${
1
}
else
echo
"ERROR: '
$1
' is not a valid option/positional argument"
echo
print_help
exit
2
fi
;;
esac
shift
done
_TST_IMGTAG
=
${
BUILD_IMAGE_TAG
:?
"Missing arg #1 to specify built image tag"
}
_TST_SRCDIR
=
${
SRCROOTDIR
:?
"Missing arg #2 to specify source directory"
}
_TST_REGISTRY
=
${
REGISTRY
:?
"Missing arg #3 to specify target container registry"
}
# Supplement a registry path by trailing slash (if needed)
#[[ "${REGISTRY}" != */ ]] && REGISTRY="${REGISTRY}/"
echo
"Moving into source root directory:
${
SRCROOTDIR
}
"
pushd
"
$SRCROOTDIR
"
export
DOCKER_BUILDKIT
=
1
BUILD_TIME
=
"
$(
date
-uIseconds
)
"
GIT_COMMIT_SHA
=
"
$(
git rev-parse HEAD
||
true
)
"
if
[
-z
"
$GIT_COMMIT_SHA
"
]
;
then
GIT_COMMIT_SHA
=
"[unknown]"
fi
GIT_CURRENT_BRANCH
=
"
$(
git branch
--show-current
||
true
)
"
if
[
-z
"
$GIT_CURRENT_BRANCH
"
]
;
then
GIT_CURRENT_BRANCH
=
"
$(
git describe
--abbrev
=
0
--all
|
sed
's/^.*\///'
||
true
)
"
if
[
-z
"
$GIT_CURRENT_BRANCH
"
]
;
then
GIT_CURRENT_BRANCH
=
"[unknown]"
fi
fi
GIT_LAST_LOG_MESSAGE
=
"
$(
git log
-1
--pretty
=
%B
||
true
)
"
if
[
-z
"
$GIT_LAST_LOG_MESSAGE
"
]
;
then
GIT_LAST_LOG_MESSAGE
=
"[unknown]"
fi
GIT_LAST_COMMITTER
=
"
$(
git log
-1
--pretty
=
"%an <%ae>"
||
true
)
"
if
[
-z
"
$GIT_LAST_COMMITTER
"
]
;
then
GIT_LAST_COMMITTER
=
"[unknown]"
fi
GIT_LAST_COMMIT_DATE
=
"
$(
git log
-1
--pretty
=
"%aI"
||
true
)
"
if
[
-z
"
$GIT_LAST_COMMIT_DATE
"
]
;
then
GIT_LAST_COMMIT_DATE
=
"[unknown]"
fi
echo
-e
"
\n
Building base instance image...
\n
"
docker buildx build
--target
=
app
\
--progress
=
"
$PROGRESS_DISPLAY
"
\
--build-arg
BUILD_TIME
=
"
$BUILD_TIME
"
\
--build-arg
GIT_COMMIT_SHA
=
"
$GIT_COMMIT_SHA
"
\
--build-arg
GIT_CURRENT_BRANCH
=
"
$GIT_CURRENT_BRANCH
"
\
--build-arg
GIT_LAST_LOG_MESSAGE
=
"
$GIT_LAST_LOG_MESSAGE
"
\
--build-arg
GIT_LAST_COMMITTER
=
"
$GIT_LAST_COMMITTER
"
\
--build-arg
GIT_LAST_COMMIT_DATE
=
"
$GIT_LAST_COMMIT_DATE
"
\
--tag
"
${
REGISTRY
}
:
${
BUILD_IMAGE_TAG
}
"
\
"
${
IMAGE_OUTPUT
}
"
\
--file
Dockerfile
"
$SRCROOTDIR
"
echo
-e
"
\n
Done!
\n
Building instance image...
\n
"
echo
"APP_IMAGE_NAME=
$REGISTRY
:
$BUILD_IMAGE_TAG
"
>
app_docker_image_name.env
{
echo
"APP_IMAGE_VERSION=
$BUILD_IMAGE_TAG
"
}
>>
app_docker_image_name.env
popd
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment