Skip to content
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

Inputs are not resolved for docker build args #230

Open
Greven145 opened this issue Jun 26, 2024 · 0 comments · May be fixed by #232
Open

Inputs are not resolved for docker build args #230

Greven145 opened this issue Jun 26, 2024 · 0 comments · May be fixed by #232
Labels
bug Something isn't working

Comments

@Greven145
Copy link

🔥 Bug Description

When an input is used as a reference for the value of a buildArg, the value is not replaced in the docker build command

🔍 Steps to Reproduce the Bug

  1. Start with an app host project with a parameter and a container resource

    var builder = DistributedApplication.CreateBuilder(args);
    
    var npmToken = builder.AddParameter("npmToken", secret: true);
    builder.AddNpmApp("client", "../aspirate-buildargs-bug.Client")
            .PublishAsDockerFile([
                new DockerBuildArg("NPM_TOKEN", npmToken.Resource)
            ]);
    
    builder.Build().Run();
  2. Generate the manifest

    {
      "resources": {
        "npmToken": {
          "type": "parameter.v0",
          "value": "{npmToken.inputs.value}",
          "inputs": {
            "value": {
              "type": "string",
              "secret": true
            }
          }
        },
        "client": {
          "type": "dockerfile.v0",
          "path": "../aspirate-buildargs-bug.Client/Dockerfile",
          "context": "../aspirate-buildargs-bug.Client",
          "buildArgs": {
            "NPM_TOKEN": "{npmToken.value}"
          },
          "env": {
            "NODE_ENV": "development"
          }
        }
      }
    }
  3. Run aspirate build

      $ aspirate build -m manifest.json
      
           _                    _           ___  
          / \     ___   _ __   (_)  _ __   ( _ ) 
         / _ \   / __| | '_ \  | | | '__|  / _ \ 
        / ___ \  \__ \ | |_) | | | | |    | (_) |
       /_/   \_\ |___/ | .__/  |_| |_|     \___/ 
                       |_|                       
      Handle deployments of a .NET Aspire AppHost
      
      
      ── Handling Aspirate State ─────────────────────────────────────────────────────────────────────────────
      Loading state from 
      <snip file path>/aspirate-buildargs-bug/aspirate-buildargs-bug.AppHost/aspirate-state.json.
      Would you like to use all previous state values, and skip re-prompting where possible ? [y/n] (y): y
      (✔) Done:  State loaded successfully from 
      <snip file path>/aspirate-buildargs-bug/aspirate-buildargs-bug.AppHost/aspirate-state.json. Will run 
      without re-prompting for values.
      
      ── Handling Aspirate Secrets ───────────────────────────────────────────────────────────────────────────
      Secret State have been loaded, but the current command does not need to decrypt them.
      
      ── Handling Aspire Manifest ────────────────────────────────────────────────────────────────────────────
      Aspire Manifest supplied at path: manifest.json.
      Skipping Aspire Manifest generation.
      
      ── Selecting Required Components ───────────────────────────────────────────────────────────────────────
      Processing all components in the loaded file, as per the state file.
      
      ── Gathering Information about deployables ─────────────────────────────────────────────────────────────
      No project components selected. Skipping execution of container detail gathering for them.
      No project components selected. Skipping execution of container detail gathering for them.
      
      ── Handling Projects ───────────────────────────────────────────────────────────────────────────────────
      No project components selected. Skipping build and publish action.
      
      ── Handling Dockerfiles ────────────────────────────────────────────────────────────────────────────────
      (✔) Done:  Setting container details for Dockerfile client
      
      Executing: docker build --tag "client:latest" --build-arg NODE_ENV="development" --build-arg 
      NPM_TOKEN="{npmToken.value}" --file 
      "<snip file path>/aspirate-buildargs-bug/aspirate-buildargs-bug.Client/Dockerfile" 
      ../aspirate-buildargs-bug.Client
     <snip docker stuff>
      
       🚀 Execution Completed 🚀

🧯 Possible Solution

Resolve the build arguments as potential reference values like other resource manifest references

@Greven145 Greven145 linked a pull request Jun 27, 2024 that will close this issue
5 tasks
@prom3theu5 prom3theu5 added the bug Something isn't working label Jul 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants