diff --git a/Changelog.md b/Changelog.md index 463ac46b7de33970b562df111e9f331288e5c8e6..28cfe86ed52d084f4d455cc73d8e7fe9e7733925 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,5 +1,12 @@ # 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 diff --git a/Readme.md b/Readme.md index 7fd1faecc5e680d1340cc927deb9f837eb5eb395..1b1aef8eecf34aa38898bc8b85352894a7b17b1b 100644 --- a/Readme.md +++ b/Readme.md @@ -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 diff --git a/assets/deployer b/assets/deployer index 3b80c6e6a529e9fb1d9a70379f97b0c665fb1e16..f34f20dd39b5abb7f3a1be5d7e1d7cf98f15c7d0 100755 --- a/assets/deployer +++ b/assets/deployer @@ -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 diff --git a/custom-context/Dockerfile b/custom-context/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..143257c5437298d2a36dc59f1f04598d925e4f6c --- /dev/null +++ b/custom-context/Dockerfile @@ -0,0 +1,4 @@ +FROM busybox + +CMD ["/bin/sh", "-c", "echo hello world"] + diff --git a/docker-compose.yml b/docker-compose.yml index 942c275a0154168c53f88e7087e6ae15f51f6757..2f61d5bc73ee240c0900a09db30429b22e4b0886 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -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: