sparse-intern-71089
04/21/2022, 5:29 AMtall-librarian-49374
04/21/2022, 6:42 AMtall-librarian-49374
04/21/2022, 6:43 AMcold-insurance-72507
04/21/2022, 7:35 AMtall-librarian-49374
04/21/2022, 7:41 AMcold-insurance-72507
04/21/2022, 8:21 AMvar assemblerImageName = $"{projectName}-assembler";
var assemblerImage = new Image(assemblerImageName, new ImageArgs
{
ImageName = Output.Format($"{containerRegistry.LoginServer}/{assemblerImageName}:1.0.0"),
Build = new DockerBuild
{
Dockerfile = "./../CrazyBike.Assembler/Dockerfile",
Context = "./.."
},
Registry = new ImageRegistry
{
Server = containerRegistry.LoginServer,
Username = adminUsername,
Password = adminPassword
}
});
var assemblerName = $"{projectName}-{stackName}-ca-assembler";
var assembler = new App.ContainerApp(assemblerName, new App.ContainerAppArgs
{
Name = assemblerName,
ResourceGroupName = resourceGroup.Name,
ManagedEnvironmentId = kubeEnv.Id,
Configuration = new App.Inputs.ConfigurationArgs
{
Registries =
{
new App.Inputs.RegistryCredentialsArgs
{
Server = containerRegistry.LoginServer,
Username = adminUsername,
PasswordSecretRef = $"{containerRegistryName}-admin-pwd"
}
},
Secrets =
{
new App.Inputs.SecretArgs
{
Name = $"{containerRegistryName}-admin-pwd",
Value = adminPassword
}
}
},
Template = new App.Inputs.TemplateArgs
{
Containers =
{
new App.Inputs.ContainerArgs
{
Name = assemblerImageName,
Image = assemblerImage.ImageName
}
}
}
});
cold-insurance-72507
04/21/2022, 9:52 AMtall-librarian-49374
04/21/2022, 10:44 AMcold-insurance-72507
04/21/2022, 2:32 PMcold-insurance-72507
04/22/2022, 7:39 AMcold-insurance-72507
04/27/2022, 4:55 AMRegistryImage
but following the same configuration that I have for Image
the docker build doesn’t work
Error building docker image: Error response from daemon: Cannot locate specified Dockerfile: /Volumes/bahamut/projects/Conferences/CrazyBike/CrazyBike.Assembler/Dockerfile
and I don’t understand why because Dockerfile
and Context
are set in same way as for Image
(In that case the build works). Opening a command line in the same directory of the pulumi project and trying a docker build -f
passing the same docker file and context also works…
var assemblerContext = $"{buildContext}/CrazyBike.Assembler";
var assemblerImageName = $"{projectName}-assembler";
var assemblerImage = new RegistryImage(assemblerImageName, new RegistryImageArgs
{
Name = Output.Format($"{containerRegistry.LoginServer}/{assemblerImageName}:latest"),
Build = new RegistryImageBuildArgs
{
Dockerfile = $"{assemblerContext}/Dockerfile",
Context = buildContext,
BuildId = GenerateHash(assemblerContext)
}
}, new CustomResourceOptions
{
Provider = dockerProvider
});
AssemblerImageName = assemblerImage.Name;
Here attached the structure of the .net solution.
In general the documentation about docker resources it’s not so good 😅 . I’m also reading many issues about RegistryImage
, many of them quite old and still without a solution (for example https://github.com/pulumi/pulumi-docker/issues/132). @faint-table-42725 @white-balloon-205 do you have one?tall-librarian-49374
04/27/2022, 6:34 AMbuild: {
context: `${cwd}/node-app`,
},
without the dockerfile option and it works. Dockerfile is inside the node-app
folder.cold-insurance-72507
04/27/2022, 7:17 AM${cwd}
?? I understand that stands for current working directory but in C# if it is an interpolated string the parameter resolves to what?
The docs example is this and it’s not clear what ‘path’ is:
using Pulumi;
using Docker = Pulumi.Docker;
class MyStack : Stack
{
public MyStack()
{
var helloworld = new Docker.RegistryImage("helloworld", new Docker.RegistryImageArgs
{
Build = new Docker.Inputs.RegistryImageBuildArgs
{
Context = $"{path.Cwd}/absolutePathToContextFolder",
},
});
}
}
Looking at my solution structure CrazyBike.Infra
is the pulumi project from where the pulumi up runs, I want the solution folder as a build context (from CrazyBike.Infra, that I suppose is the current working directory, that means --> ./..
) and docker files are inside each project (one inside CrazyBike.Assembler
, one inside CrazyBike.Shipper
…)
As I said using the Image
in this way it works:
var assemblerImageName = $"{projectName}-assembler";
var assemblerImage = new Image(assemblerImageName, new ImageArgs
{
ImageName = Output.Format($"{containerRegistry.LoginServer}/{assemblerImageName}:latest"),
Build = new DockerBuild
{
Dockerfile = "./../CrazyBike.Assembler/Dockerfile",
Context = "./.."
},
Registry = new ImageRegistry
{
Server = containerRegistry.LoginServer,
Username = adminUsername,
Password = adminPassword
}
});
So it means that Image
and RegistryImage
behave in different ways with Context and Dockerfile properties…
I can’t imagine why it so difficult… 😂tall-librarian-49374
04/27/2022, 8:36 AMcwd
is indeed the current working directorytall-librarian-49374
04/27/2022, 8:37 AMtall-librarian-49374
04/27/2022, 8:38 AMSo it means thatYeah that is true… they were implemented by different teams at different times. Sorry for all the troubles.andImage
behave in different ways with Context and Dockerfile propertiesRegistryImage
cold-insurance-72507
04/27/2022, 8:39 AMDirectory.GetCurrentDirectory
but doesn’t work…
I’m looking at this https://github.com/kreuzwerker/terraform-provider-docker/issues/249cold-insurance-72507
04/27/2022, 8:45 AM**/Dockerfile*
from .dockerignore
but doesn’t work also…
this is the code that uses just the Context
Build = new RegistryImageBuildArgs
{
//Dockerfile = $"{shipperContext}/Dockerfile",
Context = $"{Directory.GetCurrentDirectory()}/../CrazyBike.Shipper",
BuildId = GenerateHash(shipperContext)
}
and this what pulumi sees
+ docker:index/registryImage:RegistryImage: (create)
[urn=urn:pulumi:main::crazybike::docker:index/registryImage:RegistryImage::crazybike-shipper]
[provider=urn:pulumi:main::crazybike::pulumi:providers:docker::azure_acr::2e013c0d-d9fa-47e0-941e-bf2136e955c4]
build : {
buildId : "6da3b02a81474b5d9e423c827f0901de"
context : "/Volumes/bahamut/projects/Conferences/CrazyBike/CrazyBike.Infra/../CrazyBike.Shipper"
dockerfile: "Dockerfile"
}
insecureSkipVerify: false
keepRemotely : false
name : "<http://crazybikemaincr.azurecr.io/crazybike-shipper:latest|crazybikemaincr.azurecr.io/crazybike-shipper:latest>"
but then it fails with the same error: Error building docker image: Error response from daemon: Cannot locate specified Dockerfile: Dockerfile
cold-insurance-72507
04/28/2022, 10:38 AMRegistryImage
supports only the case where the `Dockerfile`is at the root of the build context...quite unbelievable because the docker cli works in a different way (Dockerfile must be inside the context...but maybe within a nested subfolder). Can someone confirm this? In case you have multiple projects and one that is a shared class library referenced by all the other the single project cannot be the docker build context...the only way is to select the solution folder as the context. Correct me if I'm wrong. ... When a native Pulumi docker provider? 😂tall-librarian-49374
04/28/2022, 1:05 PMWhen a native Pulumi docker provider?It’s on our roadmap, I believe. Maybe within a quarter or so.
cold-insurance-72507
04/28/2022, 1:07 PMtall-librarian-49374
04/28/2022, 1:08 PMcold-insurance-72507
04/28/2022, 1:12 PMbrave-planet-10645
04/28/2022, 1:14 PMbrave-planet-10645
04/28/2022, 1:16 PMcold-insurance-72507
04/28/2022, 1:17 PMcold-insurance-72507
04/28/2022, 1:22 PMcold-insurance-72507
04/28/2022, 1:24 PMbillowy-army-68599
cold-insurance-72507
04/28/2022, 2:02 PMcold-insurance-72507
05/09/2022, 7:13 AMbrave-planet-10645
05/09/2022, 9:15 AMcold-insurance-72507
05/09/2022, 10:12 AMbrave-planet-10645
05/09/2022, 11:06 AMCrazyBike.Buy
code (which is the application code), right? But the docker file is in the src
folder. Why isn’t it in the CrazyBike.Buy
folder, because I think that might be one of the problems here?cold-insurance-72507
05/09/2022, 12:37 PMRegistryImage
is only able to find a dockerfile if it is placed AT THE ROOT of the context 😭 ...and in a real solution that is not a trivial example most of the time the context folder needs to be a parent directory (for example here because I have the CrazyBike.Shared that must be passed into the context). Using the Image
(not RegistryImage
) this problem is not present (but there are many others...). So I decided to move dockerfile(s) outside of each project...at the root level.cold-insurance-72507
05/09/2022, 12:50 PMbrave-planet-10645
05/09/2022, 12:54 PMcold-insurance-72507
05/09/2022, 12:59 PMcold-insurance-72507
05/09/2022, 2:49 PMcold-insurance-72507
05/09/2022, 4:08 PMbillowy-army-68599
billowy-army-68599
cold-insurance-72507
05/09/2022, 5:02 PMRegistryImage
? Thanks!billowy-army-68599
cold-insurance-72507
05/10/2022, 3:52 AMRegistryImage
and your trick about hashing the context https://github.com/pulumi/pulumi-docker/issues/132#issuecomment-812234817, can you maybe help me on this?