GoogleContainerTools / kaniko

Build Container Images In Kubernetes
Apache License 2.0
14.81k stars 1.44k forks source link

Error /kaniko/executor: No such file or directory #2380

Open tech-discuss opened 1 year ago

tech-discuss commented 1 year ago

### .gitlab-ci.yml file

image: google/cloud-sdk:latest
variables:
  PROJECT_ID: $GCP_PROJECT_ID
  IMAGE: gcr.io/$GCP_PROJECT_ID/vonome-official-website:latest2

before_script:
  - apt-get update && apt-get install -y wget
  - |
      wget https://github.com/GoogleContainerTools/kaniko/archive/refs/tags/v1.9.1.tar.gz
      tar xzf v1.9.1.tar.gz
      export PATH=$PATH:$PWD/kaniko 
  - gcloud auth activate-service-account --key-file $GOOGLE_APPLICATION_CREDENTIALS
  - gcloud services enable containerregistry.googleapis.com
  - gcloud --quiet config set project $GCP_PROJECT_ID
  - gcloud --quiet config set container/use_client_certificate False
  - echo "Running on $CI_PROJECT_DIR..."
  - mkdir -p /kaniko/.docker
  - echo "{\"auths\":{\"${CI_REGISTRY}\":{\"auth\":\"$(printf "%s:%s" "${CI_REGISTRY_USER}" "${CI_REGISTRY_PASSWORD}" | base64 | tr -d '\n')\"},\"$CI_DEPENDENCY_PROXY_SERVER\":{\"auth\":\"$(printf "%s:%s" ${CI_DEPENDENCY_PROXY_USER} "${CI_DEPENDENCY_PROXY_PASSWORD}" | base64 | tr -d '\n')\"}}}" > /kaniko/.docker/config.json

stages:
  - build

build:
  stage: build
  # image:
  #   name: gcr.io/kaniko-project/executor:latest
  #   entrypoint: [""]
  script:
    - echo "Start test $IMAGE "
    - /kaniko/executor
      --context "${CI_PROJECT_DIR}"
      --dockerfile "${CI_PROJECT_DIR}/Dockerfile"
      --destination "${CI_REGISTRY_IMAGE}:${CI_COMMIT_TAG}"
      --no-push
  only:
    - development

### Error Message

Updated property [container/use_client_certificate].
$ echo "Running on $CI_PROJECT_DIR..."
Running on /builds/vonomecode/vonome-official-website/vonome-website-project...
$ mkdir -p /kaniko/.docker
$ echo "{\"auths\":{\"${CI_REGISTRY}\":{\"auth\":\"$(printf "%s:%s" "${CI_REGISTRY_USER}" "${CI_REGISTRY_PASSWORD}" | base64 | tr -d '\n')\"},\"$CI_DEPENDENCY_PROXY_SERVER\":{\"auth\":\"$(printf "%s:%s" ${CI_DEPENDENCY_PROXY_USER} "${CI_DEPENDENCY_PROXY_PASSWORD}" | base64 | tr -d '\n')\"}}}" > /kaniko/.docker/config.json
$ echo "Start test $IMAGE "
Start test gcr.io/useful-atlas-372807/vonome-official-website:latest2 
$ /kaniko/executor --context "${CI_PROJECT_DIR}" --dockerfile "${CI_PROJECT_DIR}/Dockerfile" --destination "${CI_REGISTRY_IMAGE}:${CI_COMMIT_TAG}" --no-push
/scripts-39705433-3695664429/step_script: line 167: /kaniko/executor: No such file or directory
Cleaning up project directory and file based variables
00:01
ERROR: Job failed: command terminated with exit code 1
waddles commented 1 year ago

Gitlab requires a shell, there is no shell in the gcr.io/kaniko-project/executor:latest image, you need to use the gcr.io/kaniko-project/executor:debug image. You are running your build: step on the image defined at the global scope, ie. google/cloud-sdk:latest which obviously does not have kaniko installed.

aaron-prindle commented 1 year ago

@ibnazher were you able to resolve this using the information @waddles provided?

As they mentioned it seems you attempted to use the kaniko executor binary on an image that did not contain it. Likely you would want to use the image - gcr.io/kaniko-project/executor:debug as mentioned above.