Skip to content
Snippets Groups Projects
Commit ad5454a7 authored by Ulf Seltmann's avatar Ulf Seltmann
Browse files

Merge branch 'add-build-context' into 'master'

add option for docker-build-context

See merge request !8
parents fe8cffef 71739f3d
Branches
1 merge request!8add option for docker-build-context
Pipeline #1396 passed with stages
in 1 minute and 36 seconds
# Changelog
## [1.3.0] - 2019-01-12
### Added
* new option `--build-context`
### Changed
* omitting `--output` is skipping image-saving to a file rather than failing execution
## [1.2.4] - 2018-12-17
### Added
* reintroduced image-import prior to build
......@@ -43,3 +50,4 @@
[1.2.2]: https://git.sc.uni-leipzig.de/ubl/bdd_dev/webmasterei/deployer/compare/release%2F1.2.1...release%2F1.2.2
[1.2.3]: https://git.sc.uni-leipzig.de/ubl/bdd_dev/webmasterei/deployer/compare/release%2F1.2.2...release%2F1.2.3
[1.2.4]: https://git.sc.uni-leipzig.de/ubl/bdd_dev/webmasterei/deployer/compare/release%2F1.2.3...release%2F1.2.4
[1.3.0]: https://git.sc.uni-leipzig.de/ubl/bdd_dev/webmasterei/deployer/compare/release%2F1.2.4...release%2F1.3.0
......@@ -91,7 +91,8 @@ From now on charts located in this repository can be deployed by using the `--ch
## docker build
* `--build-arg`: used to provide build-arguments do `docker build`-command. This is mainly used for `HTTP_PROXY`/`http_proxy`: When you specify `--build-arg HTTP_PROXY=...` the tool adds the build argument `--build-arg http_proxy=...` as well, so lower-case proxy-variables are provided automatically. Nevertheless can you use this option to provide your own build-arguments within the `Dockerfile`
* `--output`: sets the filepath to the file where the built image is saved
* `--output`: sets the filepath to the file where the built image is saved. If omitted the image is not saved to a file
* `--build-context`: sets the build-context for `docker build` to a custom path. If omitted the path where the command is invoked is used.
## docker publish
......
......@@ -21,6 +21,7 @@ namespace=""
cluster_url=""
service_account=""
repo_url=""
build_context="."
! getopt --test > /dev/null
if [[ ${PIPESTATUS[0]} -ne 4 ]]; then
......@@ -29,7 +30,7 @@ if [[ ${PIPESTATUS[0]} -ne 4 ]]; then
fi
OPTIONS=
LONGOPTS=docker-config:,tag:,build-arg:,values:,set:,set-string:,charts:,name:,token:,certificate-authority:,namespace:,cluster-url:,service-account:,output:,input:,repo-url:
LONGOPTS=docker-config:,tag:,build-arg:,values:,set:,set-string:,charts:,name:,token:,certificate-authority:,namespace:,cluster-url:,service-account:,output:,input:,repo-url:,build-context:
# -use ! and PIPESTATUS to get exit code with errexit set
# -temporarily store output to be able to check for errors
......@@ -91,11 +92,7 @@ while true; do
service_account="$2"
shift 2
;;
--output)
image_file="$2"
shift 2
;;
--input)
--output|--input)
image_file="$2"
shift 2
;;
......@@ -103,6 +100,10 @@ while true; do
repo_url="$2"
shift 2
;;
--build-context)
build_context="$2"
shift 2
;;
--)
shift
break
......@@ -330,9 +331,8 @@ save_image() {
echo -ne "saving image ..."
if [ "${image_file}" == "" ];then
echo "failed"
echo "no image name specified"
return 1
echo "skipped. No filename specified"
return 0
fi
out=`docker save --output=${image_file} ${image_name} 2>&1`
......@@ -356,7 +356,7 @@ build_image() {
cmd="$cmd --build-arg $arg --build-arg ${arg,,}"
done
cmd="$cmd -t ${image_name} ."
cmd="$cmd -t ${image_name} ${build_context}"
out=`$cmd 2>&1`
if [ "$?" != "0" ];then
echo "failed"
......@@ -372,15 +372,13 @@ import_image() {
echo -ne "importing image..."
if [ "${image_file}" == "" ];then
echo "failed! No image file specified"
echo "Make sure to specify an image file via --input"
return 1
echo "skipped! No image file specified"
return 0
fi
if [ ! -f $image_file ];then
echo "failed"
echo "${image_file} not found"
return 1
echo "skipped. \"${image_file}\" not found"
return 0
fi
out=`docker load --input=${image_file} 2>&1`
......@@ -438,8 +436,7 @@ fi
case $1 in
build)
import_image
build_image && save_image
import_image && build_image && save_image
;;
publish)
prepare_image_publisher && import_image && publish_image
......
FROM busybox
CMD ["/bin/sh", "-c", "echo hello world"]
......@@ -11,6 +11,28 @@ services:
DOCKER_HOST: tcp://docker:2375
command: deployer build --output .tmp/image.tar.gz
build-no-save:
build: .
volumes:
- ./:/app
- ./assets/deployer:/usr/local/bin/deployer
depends_on:
- docker
environment:
DOCKER_HOST: tcp://docker:2375
command: deployer build
build-custom-context:
build: .
volumes:
- ./:/app
- ./assets/deployer:/usr/local/bin/deployer
depends_on:
- docker
environment:
DOCKER_HOST: tcp://docker:2375
command: deployer build --build-context ./custom-context --output .tmp/image.tar.gz
publish:
build: .
volumes:
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment