-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can't install to container, before doing a build in GitLab. (Missing package manager?) #1440
Comments
I think I got around this, by having another GitLab job (Ubuntu) download git, clone the repo, and upload an artifact with the files to the Kaniko job. Is this the intended way to add files for Kaniko to build with in GitLab? It seems slightly overkill just to add files to me, but I'm new to CI-CD. Maybe keeping jobs super small in gitlab is intended? Any way, thanks in advance for any advice you might have on this! I was stuck on it for a while now lol. Staging setup:
image: ubuntu:18.04
stage: Build-staging
script:
- apt update && apt install -y git
- git clone <mylib.git repo>
artifacts:
name: "Lib-$CI_JOB_ID"
paths:
- mylib/
exclude:
- mylib/.git/**/*
expire_in: 1 day
Staging build:
image:
name: gcr.io/kaniko-project/executor:debug
entrypoint: [""]
tags: [ docker ]
stage: Deploy-staging
dependencies:
- "Staging setup"
script:
# --- Login stuff here --- #
# --- artifact is added to project by default, setup already done!! ---
- /kaniko/executor --context ${CI_PROJECT_DIR} --dockerfile ${CI_PROJECT_DIR}/Dockerfile --destination ${REPO_URL} |
@cjshowalter The problem is, that the script is executed in the context of the knaiko-Image. And that image has no git (because it isn't needed and does not belong there). I do not have a really good solution, but I can give some pointers:
|
Hey @cmorty, thanks for the reply! I guess that's where I'm stuck. I don't know how to add git to the Kaniko image. It doesn't have any package manager I can find, or curl, make, and cmake for building it myself. I'll have to remember about the custom executors, I'd like to get podman working eventually too xD, I'm not sure if that lets you use git, or any other packages though. |
@cjshowalter You'll need a multistage build: https://docs.docker.com/develop/develop-images/multistage-build/ You can take the kaniko image and copy the executor into the alpine/git image. (You can do this using kaniko) and then upload that image to you registry and use that as your image. You're Dockerfile should look something like
...to get the gist. ;) |
Hey @cmorty, I missed the reply. Sorry about the late response xD. Multistage builds is definitely a neat idea. I'm worried about it breaking though. Here, they mentioned that's not yet supported I think. (Second bullet point). Plus I'd have to re-build it every time kaniko pushes an update. I'm guessing this isn't a common problem. People probably keep all the dependencies in the repo itself, or use submodules to pull additional ones before building. I control both repos I'm trying to combine into the container, and submodules are a pita to keep updated with the branch you're pulling from. I guess kaniko pushing a larger version of the container, before they strip out their package manager is one option. I'm not sure they're up to supporting something like that... |
I have similar problem. I have to create the docker image and upload it into a remote git repo. Unfortunately, the image is over 1GB and it is too big for the |
have this problem as well, wanting to install wget to test connectivity but apt and apk arent available? looks like this might be a solution -> https://github.com/WoozyMasta/kaniko-tools |
As mentioned in the thread, the options here for installing some helper tools into the kaniko image include:
Going to close this as I believe the question was answered in the thread and there isn't anything actionable here. Feel free to comment and I can re-open if there is more here, thanks |
Actual behavior
For running in GitLab, I have a yml similar to:
That part works great, but I can't find how to do any setup before building the image. There's a couple repo's I'd like to git clone before getting to the build part, so everything's together. I can't find how to install git, or any other packages I might need in the future. Is there a package manager I'm just missing? It's busybox, so I tried opkg, but it says it's not found. I also tried apt, pacman, yum, etc without any luck.
Expected behavior
A package manager to install missing libraries to container, before building containers in a GitLab runner.
Additional Information
N/A
N/A
gcr.io/kaniko-project/executor:debug
Triage Notes for the Maintainers
--cache
flagThe text was updated successfully, but these errors were encountered: