Skip to content

Support building from Dockerfile.in templates in devcontainer.json using configurable preprocessing tool#1233

Open
Mathiyarasy wants to merge 10 commits into
devcontainers:mainfrom
Mathiyarasy:dev/Mathi/dotinsupport
Open

Support building from Dockerfile.in templates in devcontainer.json using configurable preprocessing tool#1233
Mathiyarasy wants to merge 10 commits into
devcontainers:mainfrom
Mathiyarasy:dev/Mathi/dotinsupport

Conversation

@Mathiyarasy
Copy link
Copy Markdown
Contributor

@Mathiyarasy Mathiyarasy commented May 20, 2026

Fixes: #1223

Issue Description: Podman supports building from Dockerfile.in files by using the system cpp preprocessor to generate a valid Dockerfile before the build runs. Dev Containers do not currently support this workflow. The existing CLI reads the Dockerfile directly, identifies the final FROM stage, and then extends it with features. When the input is a Dockerfile.in that has not been preprocessed yet, the CLI may not see a resolved FROM instruction, which causes the build flow to fail.

Solution:

  • This PR adds configurable preprocessing support for Dockerfile.in-style templates before the existing Dockerfile build flow runs.
  • Introduces a new dockerfilePreprocessor configuration in devcontainer.json to support building from Dockerfile.in-style templates.
  • This preprocessing step run before the existing Dockerfile build flow.
  • The implementation is generalized beyond cpp so it can also support generator-style tools such as cmake, meson, and autoconf.

Preprocessing contract

  • tool: required. Specifies the preprocessor tool to invoke. The CLI assumes the tool is already installed on the host and only invokes it.
  • args: optional. Arguments passed directly to the configured tool.
  • generatedDockerfilePath: required. Specifies the path, relative to the Dockerfile.in directory, where the preprocessing tool will produce the final Dockerfile. After preprocessing, the CLI validates that this file exists and then promotes it into the CLI-owned output path used by the rest of the build flow.

Validation rules

  • tool is required.
  • generatedDockerfilePath is required.

Example

{
	"build": {
		"dockerfile": "Dockerfile.in"
	},
	"dockerfilePreprocessor": {
		"tool": "cpp",
		"args": [
			"-P",
			"./Dockerfile.in",
			"Dockerfile"
		],
		"generatedDockerfilePath": "Dockerfile"
	},
	"features": {
		"ghcr.io/devcontainers/features/github-cli:1": {
			"version": "latest"
		}
	}
}

Test coverage

Adds unit and integration coverage for:

  • valid preprocessing flows
  • invalid config combinations
  • missing outputs
  • stale artifacts
  • Docker Compose-based preprocessing

@Mathiyarasy Mathiyarasy changed the title Support for building from Dockerfile.in-style templates in devcontainer.json Support building from Dockerfile.in templates in devcontainer.json using configurable preprocessing tool May 20, 2026
@Mathiyarasy Mathiyarasy marked this pull request as ready for review May 22, 2026 10:07
@Mathiyarasy Mathiyarasy requested a review from a team as a code owner May 22, 2026 10:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support for Podman's preprocessed dockerfiles

1 participant