-
Notifications
You must be signed in to change notification settings - Fork 177
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
azd up
doesn't pass --build-arg
when calling docker build
#3432
Comments
Hrm. This is interesting. I'm not certain that splatting these as args is actually the right thing to do? To me the I'm slightly concerned about cases where we may not be able to resolve values for the env block when we go to build the container, but could later during publishing. I'm just wondering if things like I do expect you want to do this so you can burn in things like the URL of the weather service into your SPA as you build it (either during the compiler or by writing some Part of me wonders if we should just extend the schema for the Whatever we do here - I do want to be consistent with however DCP handles this situation... |
I'm less concerned about where the It is commonplace at build time for Node.js apps to require env vars. If the FROM node:20.7 as build
WORKDIR /app
COPY package.json package.json
COPY package-lock.json package-lock.json
RUN npm i
COPY . .
RUN npm run build-prod
FROM nginx:alpine
COPY --from=build /app/default.conf.template /etc/nginx/templates/default.conf.template
COPY --from=build /app/dist/weather/browser /usr/share/nginx/html
EXPOSE 4000 80
CMD ["nginx", "-g", "daemon off;"] Where it's doing |
This is the right thing to do. Baking in ENV as build args isn't right and it should be explicitly defined. |
I'm good with that, makes sense. On the Aspire side of things, we'll need to expose this functionality then, right? |
Hi @ellismg and @rajeshkamal5050, we have a PR in place that will update the resulting manifest for the {
"type": "dockerfile.v0",
"path": "NodeFrontend/Dockerfile",
"context": "NodeFrontend",
"buildArgs": {
"SOME_BUILD_ARG": "Test",
"ANOTHER_BUILD_ARG": null
},
"env": {
"NODE_ENV": "production"
}
} When
Additionally, it's possible for the values to be represented as value expressions, just like we do with the {
"resources": {
"weatherapi": {
"type": "project.v0",
"path": "../AspireJavaScript.MinimalApi/AspireJavaScript.MinimalApi.csproj",
"env": {
"OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EXCEPTION_LOG_ATTRIBUTES": "true",
"OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EVENT_LOG_ATTRIBUTES": "true"
},
"bindings": {
"http": {
"scheme": "http",
"protocol": "tcp",
"transport": "http"
},
"https": {
"scheme": "https",
"protocol": "tcp",
"transport": "http"
}
}
},
"angular": {
"type": "dockerfile.v0",
"path": "../AspireJavaScript.Angular/Dockerfile",
"context": "../AspireJavaScript.Angular",
"buildArgs": {
"services__weatherapi__0": "{weatherapi.bindings.http.url}",
"services__weatherapi__1": "{weatherapi.bindings.https.url}"
},
"env": {
"NODE_ENV": "development",
"services__weatherapi__0": "{weatherapi.bindings.http.url}",
"services__weatherapi__1": "{weatherapi.bindings.https.url}",
"PORT": "{angular.bindings.http.port}"
},
"bindings": {
"http": {
"scheme": "http",
"protocol": "tcp",
"transport": "http",
"containerPort": 4000
}
}
},
"react": {
"type": "dockerfile.v0",
"path": "../AspireJavaScript.React/Dockerfile",
"context": "../AspireJavaScript.React",
"env": {
"NODE_ENV": "development",
"services__weatherapi__0": "{weatherapi.bindings.http.url}",
"services__weatherapi__1": "{weatherapi.bindings.https.url}",
"PORT": "{react.bindings.http.port}"
},
"bindings": {
"http": {
"scheme": "http",
"protocol": "tcp",
"transport": "http",
"containerPort": 4001
}
}
},
"vue": {
"type": "dockerfile.v0",
"path": "../AspireJavaScript.Vue/Dockerfile",
"context": "../AspireJavaScript.Vue",
"env": {
"NODE_ENV": "development",
"services__weatherapi__0": "{weatherapi.bindings.http.url}",
"services__weatherapi__1": "{weatherapi.bindings.https.url}",
"PORT": "{vue.bindings.http.port}"
},
"bindings": {
"http": {
"scheme": "http",
"protocol": "tcp",
"transport": "http",
"containerPort": 4002
}
}
}
}
} Note Notice that the Does that make sense? See dotnet/aspire#2851 |
Thanks, @IEvangelist - This makes sense to me - we'll add support for this new flag so we pass |
This just got mereged! |
@IEvangelist , with #3545 azd will use the build-args, however, azd is not resolving references like it does with the environment block. So, for now, the first step would be to honor build-args verbatim from the manifest. |
Output from
azd version
Run
azd version
and copy and paste the output here:azd version 1.7.0-beta.1-pr.3511727 (commit 3442439a53d9f59437ee3b13070ff9985c07cd91)
Describe the bug
Description of issue you're seeing...
I have a .NET Aspire application with an ASP.NET Core Minimal API, and three SPA framework frontends, Angular, React, and Vue. When I call
azd up --debug
, I can observe that thedocker build
command invocations aren't passing any--build-args
when I believe that they should..NET Aspire generates the following manifest:
To Reproduce
Steps to reproduce the behavior...
Create a .NET Aspire app, add a non-.NET app to it that defines a Dockerfile such as a simple SPA app with an nginx image. Note that the manifest defines
env
variables, I believe that these should be splatted into the--build-arg
. Here's an example output from theazd up--debug
:From this output you can see the
framework_service_docker.go
claims thatbuildArgs
is an empty array[]
, thus there aren't any--build-arg
switches.Expected behavior
A clear and concise description of what you expected to happen.
I expected that for each
env
defined in the .NET Aspire manifest to have a corresponding--build-arg
passed when thedocker build
command is called.Additional context
Add any other context about the problem here.
See Set build-time variables (--build-arg)
Discovered as part of dotnet/aspire-samples#125
The text was updated successfully, but these errors were encountered: