Skip to content

Add support for ENV and CMD commands in Dockerfiles #1542

@felipehuici

Description

@felipehuici

Feature request summary

Right now the ENV and CMD commands in Dockerfiles are ignored by kraft cloud deploy. The idea is to add support for these, essentially:

  • ENV --> Map to kraft cloud deploy's -e flag
  • CMD --> Use it to override the Kraftfile's cmd line (it one such line exists)

We introduce an additional ExporterEntry (type OCI) which saves the OCI artifact to a temporary location, then unpack the output tarball and read in config.json which contains all the information we want.

The issue is that this is embedded in function is part of a general interface which is only concerned about the generation of a rootfs and not any additional metadata. (Handling serializing directories in to CPIO archives, reading existing CPIO archives, and turning Dockerfiles into CPIO archives is its main purpose).

The generation of the rootfs is done at lots of different points throughout the project, depending on what you invoke, which is why we have this. Once solution could be to update the Initrd interface to handle these additional metadata attributes, which would ultimately return empty for other source inputs (directory, existing cpio archives, etc.). This would be the quickest solution.

  1. Add new interface methods:

    Env() []string
    Args() []string // join ENTRYPOINT + CMD together
    Ports() []string // EXPOSE
    Volumes() []string // VOLUME
  2. Add the ExporterEntry and then parse the temporary archive using stereoscope such that we can access the Metadata object.

  3. Update all references where the Args are necessary.

  4. Similar to the readme work, propagate this info back to our OCI image

Note, we should NOT automatically map ports or create volumes. This is not how docker behaves, it is only acting as a reference.

Describe alternatives

No response

Related architectures

None

Related platforms

None

Additional context

No response

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions