Skip to content

Commit

Permalink
Merge pull request #141 from rosineygp/feat/docker-image-pull
Browse files Browse the repository at this point in the history
feat: option to pull image before start mkdkr job
  • Loading branch information
rosineygp authored Jan 14, 2021
2 parents 2c131a4 + a994128 commit 1dad2d3
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 10 deletions.
17 changes: 17 additions & 0 deletions .mkdkr
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,18 @@ _update_workdir() {
_MKDKR_WORKDIR=$(docker inspect --format='{{.Config.WorkingDir}}' "${container_name}")
}

_docker_image_pull() {
local -r image="${1}"
if [ "${MKDKR_DOCKER_IMAGE_PULL:-missing}" == "always" ]; then
_pretty "orange" "\ndocker pull image: ${image}"
docker pull "${image}" >&2
local -r exit_code="$?"
if [ "$exit_code" != "0" ]; then
exit "$exit_code"
fi
fi
}

# header fn
_header_render() {
cat <<EOF
Expand Down Expand Up @@ -435,6 +447,7 @@ instance:() {

_remove_running_job
_network_create
_docker_image_pull "${image}"

_pretty "cyan" "\ninstance: ${image} ${args[*]}"

Expand Down Expand Up @@ -476,6 +489,8 @@ service:() {
service_count=""
fi

_docker_image_pull "${image}"

# shellcheck disable=SC2086
docker run --rm -d \
-v "${PWD}":"${PWD}" \
Expand All @@ -499,6 +514,8 @@ dind:() {
_remove_running_job
_network_create

_docker_image_pull "${image}"

_pretty "cyan" "\ndind: ${image} ${args[*]}"

# shellcheck disable=SC2086
Expand Down
21 changes: 11 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -648,16 +648,17 @@ pipeline:

# Environment Variables

| Name | Default | Description |
|---------------------------|-------------------------------------|-------------------------------------------------------------|
| MKDKR_TTL | 3600 | The time limit to a job or service run |
| MKDKR_SHELL | sh | Change to another shell eg. bash, csh |
| MKDKR_JOB_STDOUT | last stdout | Path of file, generated with last stdout output |
| MKDKR_JOB_NAME* | (job\|service)\_target-name\_(uuid) | Unique job name, used as container name suffix |
| MKDKR_INCLUDE_CLONE_DEPTH | 1 | In the most of case you no need change history for includes |
| MKDKR_BRANCH_NAME | | Return current git branch, if it exist |
| MKDKR_BRANCH_NAME_SLUG | | Return current git branch, if it exist, with safe values |
| MKDKR_NETWORK_ARGS | | Arguments of docker create networks |
| Name | Default | Description |
|---------------------------|-------------------------------------|-------------------------------------------------------------------|
| MKDKR_TTL | 3600 | The time limit to a job or service run |
| MKDKR_SHELL | sh | Change to another shell eg. bash, csh |
| MKDKR_JOB_STDOUT | last stdout | Path of file, generated with last stdout output |
| MKDKR_JOB_NAME* | (job\|service)\_target-name\_(uuid) | Unique job name, used as container name suffix |
| MKDKR_INCLUDE_CLONE_DEPTH | 1 | In the most of case you no need change history for includes |
| MKDKR_BRANCH_NAME | | Return current git branch, if it exist |
| MKDKR_BRANCH_NAME_SLUG | | Return current git branch, if it exist, with safe values |
| MKDKR_NETWORK_ARGS | | Arguments of docker create networks |
| MKDKR_DOCKER_IMAGE_PULL | missing | Set "always" to force pull images before docker instance creation |

> - to overwrite the values use: `export <var>=<value>`
> - \* auto generated
Expand Down

0 comments on commit 1dad2d3

Please sign in to comment.