Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
1
1-tracer
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
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
Issue analytics
Insights
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
SO2
1-tracer
Commits
535c7326
Commit
535c7326
authored
2 years ago
by
Mihai Baruta
Browse files
Options
Downloads
Patches
Plain Diff
Add --force_build to disable caching when building a docker image
parent
96f7301d
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
local.sh
+16
-5
16 additions, 5 deletions
local.sh
with
16 additions
and
5 deletions
local.sh
+
16
−
5
View file @
535c7326
...
@@ -39,11 +39,12 @@ print_help() {
...
@@ -39,11 +39,12 @@ print_help() {
echo
" checker - runs the checker"
echo
" checker - runs the checker"
echo
" -h|--help - prints this message"
echo
" -h|--help - prints this message"
echo
""
echo
""
echo
"local.sh docker build [--image_name <image_name>] [--tag <tag>] [--registry <registry>]"
echo
"local.sh docker build [--image_name <image_name>] [--tag <tag>] [--registry <registry>]
[--force_build]
"
echo
""
echo
""
echo
" --image_name <image_name> - the name of the image (default: current directory name)"
echo
" --image_name <image_name> - the name of the image (default: current directory name)"
echo
" --tag <tag> - the tag of the image (default: 'latest')"
echo
" --tag <tag> - the tag of the image (default: 'latest')"
echo
" --registry <registry> - the registry in which the image will be pushed (default: 'gitlab.cs.pub.ro:5050')"
echo
" --registry <registry> - the registry in which the image will be pushed (default: 'gitlab.cs.pub.ro:5050')"
echo
" --force_build - disable caching when building the docker image"
echo
""
echo
""
echo
"local.sh docker push --user <user> --token <token> [--image_name <image_name>] [--tag <tag>] [--registry <registry>]"
echo
"local.sh docker push --user <user> --token <token> [--image_name <image_name>] [--tag <tag>] [--registry <registry>]"
echo
""
echo
""
...
@@ -51,7 +52,7 @@ print_help() {
...
@@ -51,7 +52,7 @@ print_help() {
echo
" --tag <tag> - the tag of the image (default: 'latest')"
echo
" --tag <tag> - the tag of the image (default: 'latest')"
echo
" --registry <registry> - the registry in which the image will be pushed (default: 'gitlab.cs.pub.ro:5050')"
echo
" --registry <registry> - the registry in which the image will be pushed (default: 'gitlab.cs.pub.ro:5050')"
echo
" --user <registry> - username for the repository registry"
echo
" --user <registry> - username for the repository registry"
echo
" --token <
registry> - the registry in which the image will be pushed (default: 'gitlab.cs.pub.ro:5050')
"
echo
" --token <
token> - the token used to authenticate in the docker registry
"
echo
""
echo
""
echo
"local.sh docker test [--full_image_name <full_image_name>] [argumets_for_checker]"
echo
"local.sh docker test [--full_image_name <full_image_name>] [argumets_for_checker]"
echo
""
echo
""
...
@@ -63,10 +64,11 @@ print_help() {
...
@@ -63,10 +64,11 @@ print_help() {
echo
" --full_image_name <full_image_name> - the full name of the image (default: gitlab.cs.pub.ro:5050/<current_directory_name>:latest)"
echo
" --full_image_name <full_image_name> - the full name of the image (default: gitlab.cs.pub.ro:5050/<current_directory_name>:latest)"
echo
" --use_executable <executable> - command to run inside the container (default: /bin/bash)"
echo
" --use_executable <executable> - command to run inside the container (default: /bin/bash)"
echo
""
echo
""
echo
"local.sh checker [--remove_image] [--use_existing_image <image_name>] [argumets_for_checker]"
echo
"local.sh checker [--remove_image] [--use_existing_image <image_name>]
[--force_build]
[argumets_for_checker]"
echo
""
echo
""
echo
" --remove_image - remove the checker's docker image after the run"
echo
" --remove_image - remove the checker's docker image after the run"
echo
" --use_existing_image - user image_name instead of building the image from current directory"
echo
" --use_existing_image - user image_name instead of building the image from current directory"
echo
" --force_build - disable caching when building the docker image"
echo
" argumets_for_checker - list of space separated arguments to be passed to the checker"
echo
" argumets_for_checker - list of space separated arguments to be passed to the checker"
echo
""
echo
""
}
}
...
@@ -75,6 +77,7 @@ docker_build() {
...
@@ -75,6 +77,7 @@ docker_build() {
local
image_name
=
"
$DEFAULT_IMAGE_NAME
"
local
image_name
=
"
$DEFAULT_IMAGE_NAME
"
local
tag
=
"
$DEFAULT_TAG
"
local
tag
=
"
$DEFAULT_TAG
"
local
registry
=
"
$DEFAULT_REGISTRY
"
local
registry
=
"
$DEFAULT_REGISTRY
"
local
extra_docker_args
=()
while
[[
$#
-gt
0
]]
;
do
while
[[
$#
-gt
0
]]
;
do
case
$1
in
case
$1
in
...
@@ -90,13 +93,16 @@ docker_build() {
...
@@ -90,13 +93,16 @@ docker_build() {
shift
shift
registry
=
"
$1
"
registry
=
"
$1
"
;;
;;
--force_build
)
extra_docker_args+
=(
'--no-cache'
)
;;
esac
esac
shift
shift
done
done
LOG_INFO
"Building Docker image..."
LOG_INFO
"Building Docker image..."
docker image build
-t
"
${
registry
}
/
${
image_name
}
:
${
tag
}
"
.
docker image build
"
${
extra_docker_args
[@]
}
"
-t
"
${
registry
}
/
${
image_name
}
:
${
tag
}
"
.
}
}
docker_push
()
{
docker_push
()
{
...
@@ -203,6 +209,8 @@ checker_main() {
...
@@ -203,6 +209,8 @@ checker_main() {
local
script_args
=()
local
script_args
=()
local
remove_image
=
''
local
remove_image
=
''
local
image_name
=
''
local
image_name
=
''
local
extra_docker_args
=()
local
project_directory
=
''
while
[[
$#
-gt
0
]]
;
do
while
[[
$#
-gt
0
]]
;
do
case
$1
in
case
$1
in
...
@@ -213,6 +221,9 @@ checker_main() {
...
@@ -213,6 +221,9 @@ checker_main() {
shift
shift
image_name
=
"
$1
"
image_name
=
"
$1
"
;;
;;
--force_build
)
extra_docker_args+
=(
'--no-cache'
)
;;
*
)
*
)
script_args+
=(
"
$1
"
)
script_args+
=(
"
$1
"
)
;;
;;
...
@@ -224,7 +235,7 @@ checker_main() {
...
@@ -224,7 +235,7 @@ checker_main() {
image_name
=
"
$(
basename
"
$(
pwd
)
"
)
"
image_name
=
"
$(
basename
"
$(
pwd
)
"
)
"
LOG_INFO
"Building image..."
LOG_INFO
"Building image..."
docker build
-q
-t
"
$image_name
"
.
docker build
"
${
extra_docker_args
[@]
}
"
-q
-t
"
$image_name
"
.
fi
fi
tmpdir
=
"
$(
mktemp
-d
)
"
tmpdir
=
"
$(
mktemp
-d
)
"
...
...
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