containers/podlet

Enhancement: Tolerate `build:` directive in compose file

kronenpj opened this issue · 4 comments

K9,

May I suggest an approach to tolerating build: directives in compose files: Utilize the stanza title or container_name to infer the name of the local image. For example:

# redis
netbox-redis:
    container_name: netbox-redis
    hostname: redis
    #image: localhost/netbox-redis:latest
    build: ./valkey

Podman compose will generate a container called netbox-redis with a latest tag. Without the container_name tag this image would be created from the current directory and the netbox-redis key. If an image isn't found, an error is warranted.

I don't know how much effort this would be but it would add a little compatibility to this excellent tool.

I'm not sure if this is a good idea. The reason podlet does not currently support build in compose services is that quadlet does not directly support building an image before running a container. Quadlet .container files map to podman run commands in the generated systemd service. You could create a service which builds the image and then add it to Requires= and After= in the [Unit] section of the .container quadlet file. I feel like this may be out of scope for podlet as the specifics of how you wish to build the image will likely be highly dependent on your setup. Perhaps you could ask the podman team to add a Build= directive to .image quadlet files?

Ah, hadn't considered that aspect and the relationship between the .container files and the podman run command line. I was trying to keep the compose.yml file in one piece for building and starting. However, it's easy enough to split, so I'll go that route. Thanks for the consideration!

Could this issue be reopened? Quadlet now seems to support .build files