Skip to content
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

minikube image build should support configuring build-args #12384

Open
briandealwis opened this issue Sep 1, 2021 · 5 comments
Open

minikube image build should support configuring build-args #12384

briandealwis opened this issue Sep 1, 2021 · 5 comments
Labels
area/image Issues/PRs related to the minikube image subcommand kind/feature Categorizes issue or PR as related to a new feature. lifecycle/frozen Indicates that an issue or PR should not be auto-closed due to staleness. priority/backlog Higher priority than priority/awaiting-more-evidence.

Comments

@briandealwis
Copy link
Contributor

Steps to reproduce the issue:

I'm unable to use minikube image build with a Dockerfile requiring build-args, using the docker runtime. I was unable to concoct a --build-opt value that would result in a correct docker build --build-arg key=value command line.

Minikube's underlying implementation takes the --build-opt arguments, prefixes them with -- and then appends the result as a single argument:

for _, opt := range opts {
args = append(args, "--"+opt)
}

The other container runtimes do something similar.

Docker's command-line parser requires that the --build-arg key-value pairs are provided as a separate argument. It doesn't seem to support specifying build-args using a single-argument style like --build-arg=key=value.

$ minikube --alsologtostderr image build --build-opt=build-arg=BUILDPLATFORM=linux  .
[...]
I0901 09:40:27.239205   86641 build_images.go:137] Building image from path: /var/folders/mx/_6wvyq4n3psb4nj95d8ycpv80000gn/T/build.157572332.tar
I0901 09:40:27.240484   86641 ssh_runner.go:149] Run: sudo mkdir -p /var/lib/minikube/build
I0901 09:40:27.245954   86641 ssh_runner.go:316] scp /var/folders/mx/_6wvyq4n3psb4nj95d8ycpv80000gn/T/build.157572332.tar --> /var/lib/minikube/build/build.157572332.tar (2048 bytes)
I0901 09:40:27.259538   86641 ssh_runner.go:149] Run: sudo mkdir -p /var/lib/minikube/build/build.157572332
I0901 09:40:27.264557   86641 ssh_runner.go:149] Run: sudo tar -C /var/lib/minikube/build/build.157572332 -xf /var/lib/minikube/build/build.157572332.tar
I0901 09:40:27.269088   86641 docker.go:249] Building image: /var/lib/minikube/build/build.157572332
I0901 09:40:27.269162   86641 ssh_runner.go:149] Run: docker build /var/lib/minikube/build/build.157572332 --build-arg=BUILDPLATFORM=linux
unknown flag: --build-arg=BUILDPLATFORM
See 'docker build --help'.
[...]

It seems worth adding an additional --build-arg flag for minikube image build:

  • for the docker runtimes and crio (pod man) runtimes, it would add each entry with a prior --build-arg
  • for containerd (buildkit), it would prefix each entry with `--opt' 'build-arg:'
@afbjorklund
Copy link
Collaborator

Sounds like a good idea!

@spowelljr spowelljr added kind/feature Categorizes issue or PR as related to a new feature. priority/important-longterm Important over the long term, but may not be staffed and/or may need multiple releases to complete. labels Sep 7, 2021
@afbjorklund afbjorklund self-assigned this Sep 8, 2021
@afbjorklund
Copy link
Collaborator

afbjorklund commented Sep 8, 2021

Will fix this one as well, along with env: #12431.

@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough contributors to adequately respond to all issues and PRs.

This bot triages issues and PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue or PR as fresh with /remove-lifecycle stale
  • Mark this issue or PR as rotten with /lifecycle rotten
  • Close this issue or PR with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Dec 7, 2021
@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.

This bot triages issues and PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue or PR as fresh with /remove-lifecycle rotten
  • Close this issue or PR with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle rotten

@k8s-ci-robot k8s-ci-robot added lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels Jan 6, 2022
@spowelljr spowelljr added lifecycle/frozen Indicates that an issue or PR should not be auto-closed due to staleness. and removed lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. labels Jan 19, 2022
@spowelljr spowelljr added priority/backlog Higher priority than priority/awaiting-more-evidence. and removed priority/important-longterm Important over the long term, but may not be staffed and/or may need multiple releases to complete. labels May 11, 2022
@tomsaleeba
Copy link

Using these version on Linux

$ minikube version
minikube version: v1.26.0
commit: f4b412861bb746be73053c9f6d2895f12cf78565-dirty
$ docker --version
Docker version 20.10.17, build 100c70180f
$ uname -a
Linux blah 5.16.18-1-MANJARO #1 SMP PREEMPT Mon Mar 28 09:13:53 UTC 2022 x86_64 GNU/Linux

...it seems that

support specifying build-args using a single-argument style like --build-arg=key=value

...works 🎉. Here's a demo showing docker supports the syntax directly:

$ cat Dockerfile
FROM ubuntu:20.04
ARG QQQ
RUN echo "QQQ=$QQQ"
$ docker build --build-arg=QQQ=fff .
Sending build context to Docker daemon  10.24kB
Step 1/3 : FROM ubuntu:20.04
 ---> 2a4d239ad3cc
Step 2/3 : ARG QQQ
 ---> Running in aa8a3e125afd
Removing intermediate container aa8a3e125afd
 ---> fbd68f28e9af
Step 3/3 : RUN echo "QQQ=$QQQ"
 ---> Running in 8d6e55796ab4
QQQ=fff
Removing intermediate container 8d6e55796ab4
 ---> 7e5fea687653
Successfully built 7e5fea687653

And here's using minikube

$ minikube image build --build-opt=build-arg=QQQ=blah .
Sending build context to Docker daemon  10.24kB
Step 1/3 : FROM ubuntu:20.04
...snip pulling base image logs
 ---> 3bc6e9f30f51
Step 2/3 : ARG QQQ
 ---> Running in 43a966130990
Removing intermediate container 43a966130990
 ---> db3157d02c61
Step 3/3 : RUN echo "QQQ=$QQQ"
 ---> Running in 8aab10656d86
QQQ=blah
Removing intermediate container 8aab10656d86
 ---> 100b899719ee
Successfully built 100b899719ee

As a workaround for the original bug report, you can get minikube to configure your docker CLI, and then write the docker build command directly:

eval $(minikube docker-env)
docker build --build-arg=QQQ=fff .

@afbjorklund afbjorklund added the area/image Issues/PRs related to the minikube image subcommand label Mar 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/image Issues/PRs related to the minikube image subcommand kind/feature Categorizes issue or PR as related to a new feature. lifecycle/frozen Indicates that an issue or PR should not be auto-closed due to staleness. priority/backlog Higher priority than priority/awaiting-more-evidence.
Projects
None yet
Development

No branches or pull requests

6 participants