dotnet / dotnet/docker-tools

Add a `buildContext` option to Platform in Manifest

Open
#1,592 1 comment 0 reactions 0 assignees View on GitHub
area-infrastructure
Dominant language
C#
Stars
181
Forks
67
Avg merge
2d 15h
Merged PRs (30d)
10

Description

By default, ImageBuilder uses an explicit build context of the Dockerfile's location:

https://github.com/dotnet/docker-tools/blob/14b1496d071432e9776c93ad637479371bfec6c9/src/Microsoft.DotNet.ImageBuilder/src/ViewModel/PlatformInfo.cs#L59-L62

In some cases it's desirable to access content from outside the Dockerfile's directory. For example, when building .NET projects, you may need to access a `Directory.Build.Props` or `NuGet.config` located in a parent directory.

There are two ideas I came up with for implementing this:

## Option 1: explicit path

This option would allow you to set the explicit path to the build context. The path would be relative to the manifest.

```jsonc
{
"dockerfile": "src/ImageBuilder/Dockerfile.linux",
"buildContext": "path/to/my/preferred/context",
"os": "linux",
"osVersion": "azurelinux",
"tags": {
"linux-amd64": {},
"linux-amd64-$(UniqueId)": {}
}
},
```

## Option 2: limited choices

The other option would allow you to choose between having the build context be the Dockerfile's parent directory (the default, today) or the manifest's parent directory. This could be via an enum:

```jsonc
{
"dockerfile": "src/ImageBuilder/Dockerfile.linux",
"buildContext": "Manifest", // OR "Dockerfile"
"os": "linux",
"osVersion": "azurelinux",
"tags": {
"linux-amd64": {},
"linux-amd64-$(UniqueId)": {}
}
},
```

Or a boolean:

```jsonc
{
"dockerfile": "src/ImageBuilder/Dockerfile.linux",
"manifestRelativeBuildContext": "true", // "false" is the default
"os": "linux",
"osVersion": "azurelinux",
"tags": {
"linux-amd64": {},
"linux-amd64-$(UniqueId)": {}
}
},
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.