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

When using podman kube play, allow to specify Dockerfile/build folder location #12485

Closed
BernhardPosselt opened this issue Dec 2, 2021 · 15 comments · Fixed by #12913
Closed
Assignees
Labels
kind/feature Categorizes issue or PR as related to a new feature. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. stale-issue

Comments

@BernhardPosselt
Copy link

Is this a BUG REPORT or FEATURE REQUEST? (leave only one on its own line)

/kind feature

Description

podman play kube allows you to build a container from a local container file by using a subdirectory as the image value.

This is fine if you set up a new project, but if you retroactively want to enable in your project, it will require a giant commit, possibly moving thousands of files into a subfolder, breaking peoples ide setups and potentially builds.

The main issue here is that Dockerfiles/Containerfiles can not reference directories that are above their current folder; the following line can not be built:

COPY ../directory /server/directory

This only leaves you with moving everything to a sub directory

docker-compose solves this by being able to specify the build directory and Dockerfile location whereas the following is not possible using the kube configuration:

spec:
  containers:
  - image: "."
    name: server
@openshift-ci openshift-ci bot added the kind/feature Categorizes issue or PR as related to a new feature. label Dec 2, 2021
@rhatdan
Copy link
Member

rhatdan commented Dec 2, 2021

SGTM, But the Dockerfile and context directory are per image, I believe. How should it be handled if there is more then one image?

@rhatdan
Copy link
Member

rhatdan commented Dec 2, 2021

@baude WDYT?

@BernhardPosselt
Copy link
Author

Yep, they are per image. I'm currently trying to learn podman/k8s and migrate off Docker so I'm not 100% sure but the yaml spec doesn't look like there can ever be more than 1 image per container

@rhatdan
Copy link
Member

rhatdan commented Dec 2, 2021

Right, but what if you have two containers in a Pod? Then you would have two images to build potentially.

@baude
Copy link
Member

baude commented Dec 2, 2021

yeah this gets kind of ugly quickly, which is why I asked @BernhardPosselt to make the issue. could we allow the context dir to be set in addition to the subdir. it would have to then be for all images.

the other idea i was chewing on is some sort of k8s annotations ... but we cannoot auto-gen those. it would all be manual. k8s would ignore it

@BernhardPosselt
Copy link
Author

Wouldn't it be possible to attach that build information on the container level itself? Otherwise I actually wouldn't mind going for something like annotations that define per image where my Dockerfile and context directory are.

As for the use case: looked into it a bit more but then realized that I can't even move it around in the repository because I would break the deployment scripts (which I can't edit, don't ask why xD) as well.

So basically I really need a way to be able to build from the same location where the pod yaml is in, which is currently only possible using a docker-compose.yml.

@rhatdan
Copy link
Member

rhatdan commented Dec 3, 2021

Currently we look for the subdirs with the image name. We could point to a different directory, which also had the image named subdirs. But that is not really what you want.

@flouthoc
Copy link
Collaborator

flouthoc commented Dec 3, 2021

I am pretty sure kubernetes does not supports this but this could be a podman only [RFE].

Developers use tools like skaffold (https://skaffold.dev/docs/) as client instead of kubectl with kubernetes which performs building of images https://skaffold.dev/docs/pipeline-stages/builders/ locally.

If this is a podman only RFE then I'd agree with @baude pod annotations looks like a really good way to implement this

I personally think best approach to solve this problem without tampering with k8s api struct would be.

  • define a small build protocol/specification using pod annotations : Declarative solution
apiVersion: v1
kind: Pod
metadata:
  name: mypod
  annotations:
    podman-build: "{image: <imagename>, context: </path/context>, containerfile: <path/to/containerfile>}"
    podman-build: "{image: <imagename2>, context: </path/context2>, containerfile: <path/to/containerfile2>}"
  • Second would be not declarative with similar format in podman play kube cli

@vrothberg
Copy link
Member

Friendly ping.

@BernhardPosselt would the build annotations as outlined above satisfy your needs?

@BernhardPosselt
Copy link
Author

Yes.

@vrothberg
Copy link
Member

Great, thanks!

@flouthoc, do you want to give it a shot and have some cycles? I think this could be a great feature for Podman 4.0.

@flouthoc
Copy link
Collaborator

@vrothberg Sure I'd love to.

@flouthoc flouthoc self-assigned this Dec 15, 2021
@github-actions
Copy link

A friendly reminder that this issue had no activity for 30 days.

rhatdan added a commit to rhatdan/podman that referenced this issue Mar 1, 2022
This option was requested so that users could specify alternate
locations to find context directories for each image build. It
requites the --build option to be set.

Partion Fix: containers#12485

Signed-off-by: Daniel J Walsh <[email protected]>
tricktron pushed a commit to tricktron/podman that referenced this issue Mar 14, 2022
This option was requested so that users could specify alternate
locations to find context directories for each image build. It
requites the --build option to be set.

Partion Fix: containers#12485

Signed-off-by: Daniel J Walsh <[email protected]>
@reavessm
Copy link

Did this feature get implemented? The PR listed here doesn't seem to allow specific builds per image, only one context-dir for the entire file

@rhatdan
Copy link
Member

rhatdan commented Sep 23, 2022

Open a separate Issue for that.

@github-actions github-actions bot added the locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. label Sep 14, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 14, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind/feature Categorizes issue or PR as related to a new feature. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. stale-issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants