podman icon indicating copy to clipboard operation
podman copied to clipboard

kube play build should support nested directories

Open axel7083 opened this issue 8 months ago • 3 comments

Feature request description

When playing with the podman kube play --build command, we may want to provide our full project as context-dir. However, the image name to build does not support nested directories.

.
└── my-project/
    ├── mocks/
    │   ├── service-a/
    │   │   └── Containerfile
    │   ├── service-b/
    │   │   └── Containerfile
    │   └── play.yaml
    ├── packages/
    │   ├── foo/
    │   └── bar/
    └── shared.config.json

Let's take an example, I've got some services in mocks/* and a mocks/play.yaml, however, if I specify image: service-a it will not found it if context-dir is the full project.

If I want to build service-a and service-b I need the context-dir to be in mocks, but if the Containerfile need more context (for example the shared.config.json) or the packages/* this is impossible.

Suggest potential solution

I can see two solutions

  1. Search in more location

When searching for the <name>.Containerfile, it searches from the context-dir root, we could do from the context-dir root, and the yaml file.

  1. Support nested path

For example mocks/service-a:latest should search for service-a first (backward compatibility) and mocks/service-a second etc.

This would be easy, as the logic to extract path is located in pkg/domain/infra/abi/play.go#L1632

https://github.com/containers/podman/blob/4c3027c149ad54dbb6f96328694e7b852623b4b8/pkg/domain/infra/abi/play.go#L1632

We could instead of returning a single string, return an array of path to search for.

Have you considered any alternatives?

N/A

Additional context

I'm open to work on this issue

axel7083 avatar Mar 31 '26 09:03 axel7083

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

github-actions[bot] avatar May 01 '26 00:05 github-actions[bot]

Hi @axel7083, Is nested path support only needed for tagged images, or should it also work for images with digests and registry-qualified image names?

haneul-24 avatar Aug 17 '26 13:08 haneul-24

Hi @axel7083, Is nested path support only needed for tagged images, or should it also work for images with digests and registry-qualified image names?

I mean, it would be nice if this is configurable, like in my dream world, podman could support some syntax sugar like

apiVersion: v1
kind: Pod
metadata:
  name: nginx
spec:
  containers:
    - name: nginx
      image: 
          context: /home/foo
          name: quay.io/foo:latest
          args: 
              foo: "bar"
      ports:
        - containerPort: 80

And podman would expose a command like podman play build --target=kubernetes that would translate it to

apiVersion: v1
kind: Pod
metadata:
  name: nginx
spec:
  containers:
    - name: nginx
      image: quay.io/foo:latest
      ports:
        - containerPort: 80

and would have build the quay.io/foo:latest image in the process :)

axel7083 avatar Aug 17 '26 16:08 axel7083