Commit 29232a8e authored by Protocole's avatar Protocole Committed by Thomas Boni
Browse files

Resolve "[Job] Additional options for docker build"

parent 1a76e0ae
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -64,3 +64,7 @@ The registry and tag of the resulting Docker image follow this behavior:
| `COMMIT_CREATE_LATEST` | In a commit context, also update `latest` tag | `false` |
| `TAG_CREATE_LATEST` | In a tag context, also update `latest` tag | `true` |
| `DOCKERFILE_PATH` | Path to Dockerfile from the repository root | `Dockerfile` |
| `DOCKER_USE_CACHE` | Cache Dockerfile layers. Cached layers are stored in the [container registry](https://docs.gitlab.com/ee/user/packages/container_registry/){:target="_blank"} in `/cache` repository | `false` | 
| `DOCKER_CACHE_TTL` | Cached layers TTL |  `336h` |
| `DOCKER_VERBOSITY` | Set the verbosity of the build in job's log (see [levels](https://github.com/GoogleContainerTools/kaniko#--verbosity){:target="_blank"})  |  `info` |
| `DOCKER_OPTIONS`   | If you want to use additional [options](https://github.com/GoogleContainerTools/kaniko#additional-flags){:target="_blank"} | ` ` |
+15 −2
Original line number Diff line number Diff line
@@ -12,10 +12,17 @@ docker_build:
    CUSTOM_REGISTRY: ""
    REGISTRY_USER: ""
    REGISTRY_PASSWORD: ""

    CUSTOM_TAG: ""
    COMMIT_CREATE_LATEST: "false"
    TAG_CREATE_LATEST: "true"
    DOCKERFILE_PATH: "Dockerfile"

    DOCKER_USE_CACHE: "false"
    DOCKER_CACHE_TTL: "336h"

    DOCKER_VERBOSITY: "info"
    DOCKER_OPTIONS: ""
  script:
    - mkdir -p /kaniko/.docker/
    - if [ ! -z ${CUSTOM_REGISTRY} ]; then
@@ -38,8 +45,14 @@ docker_build:
    -   fi
    - fi

    - if [ "${DOCKER_USE_CACHE}" = "true" ]; then
    -   DOCKER_OPTIONS="--cache=true --cache-ttl=${DOCKER_CACHE_TTL} ${DOCKER_OPTIONS}"
    - fi

    - DOCKER_OPTIONS="--verbosity=${DOCKER_VERBOSITY} ${DOCKER_OPTIONS}"

    - if [ ! -z ${CUSTOM_TAG} ]; then
    -   /kaniko/executor --context ${CI_PROJECT_DIR} --dockerfile ${CI_PROJECT_DIR}/${DOCKERFILE_PATH} --destination ${REGISTRY_IMAGE}:${CUSTOM_TAG}
    -   /kaniko/executor --context ${CI_PROJECT_DIR} --dockerfile ${CI_PROJECT_DIR}/${DOCKERFILE_PATH} --destination ${REGISTRY_IMAGE}:${CUSTOM_TAG} ${DOCKER_OPTIONS}
    - else
    -   /kaniko/executor --context ${CI_PROJECT_DIR} --dockerfile ${CI_PROJECT_DIR}/${DOCKERFILE_PATH} --destination ${REGISTRY_IMAGE}:${IMAGE_TAG} ${OPTIONAL_TAG}
    -   /kaniko/executor --context ${CI_PROJECT_DIR} --dockerfile ${CI_PROJECT_DIR}/${DOCKERFILE_PATH} --destination ${REGISTRY_IMAGE}:${IMAGE_TAG} ${OPTIONAL_TAG} ${DOCKER_OPTIONS}
    - fi
+4 −0
Original line number Diff line number Diff line
* New variable `DOCKER_USE_CACHE` to be able to cache layers of build
* New variable `DOCKER_CACHE_TTL` to define time to live of cache
* New variable `DOCKER_VERBOSITY` to set the verbosity of the build
* New variable `DOCKER_OPTIONS` to be able to add additional options
 No newline at end of file