Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
807 views
in Technique[技术] by (71.8m points)

docker - kaniko executor - build 2 containers without multistage

I am trying to build 2 containers in the same stage. The reasoning behind this is that everything is identical on them, but one of them will have a different usage. I don't see a reason to make a multistage build since everything is already in place and creating a new stage would download the image for the builder from cache again.

My script looks like this.

script:
    - chmod a+x k8s/check-if-needed-to-run-composer.sh
    - k8s/check-if-needed-to-run-composer.sh
    - echo "{"credsStore":"ecr-login","credHelpers":{"$AWS_ACCOUNT_ID.dkr.ecr.region.amazonaws.com":"ecr-login"}}" > /kaniko/.docker/config.json
    - executor --context $CI_PROJECT_DIR --dockerfile $CI_PROJECT_DIR/k8s/job-manager/Dockerfile --build-arg DECRYPTION_SECRET="$DECRYPTION_SECRET" --destination $AWS_REPOSITORY_JOB_MANAGER:$CI_COMMIT_REF_SLUG --verbosity=panic
    - executor --context $CI_PROJECT_DIR --dockerfile $CI_PROJECT_DIR/k8s/command-image/Dockerfile --build-arg DECRYPTION_SECRET="$DECRYPTION_SECRET" --destination $AWS_REPOSITORY_COMMAND_IMAGE:$CI_COMMIT_REF_SLUG --verbosity=panic

The problem is that first executor works, while the second one throws:

/bin/bash: line 158: /usr/local/bin/executor: No such file or directory

After investigating further it seems that at the end of executor the script remains inside the container (and that doesn't have the executor - and it shouldn't). I tried to use exit (script below) but that just stops the execution. Maybe I should try to emulate a ctrl + p?

script:
    - chmod a+x k8s/check-if-needed-to-run-composer.sh
    - k8s/check-if-needed-to-run-composer.sh
    - echo "{"credsStore":"ecr-login","credHelpers":{"$AWS_ACCOUNT_ID.dkr.ecr.region.amazonaws.com":"ecr-login"}}" > /kaniko/.docker/config.json
    - executor --context $CI_PROJECT_DIR --dockerfile $CI_PROJECT_DIR/k8s/job-manager/Dockerfile --build-arg DECRYPTION_SECRET="$DECRYPTION_SECRET" --destination $AWS_REPOSITORY_JOB_MANAGER:$CI_COMMIT_REF_SLUG --verbosity=panic
    - exit
    - executor --context $CI_PROJECT_DIR --dockerfile $CI_PROJECT_DIR/k8s/command-image/Dockerfile --build-arg DECRYPTION_SECRET="$DECRYPTION_SECRET" --destination $AWS_REPOSITORY_COMMAND_IMAGE:$CI_COMMIT_REF_SLUG --verbosity=panic

In any case... is there a way to run 2 executors one after the other in the same stage?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...