nx-tools icon indicating copy to clipboard operation
nx-tools copied to clipboard

nx-container build not pushing or loading images

Open AlanGRutter opened this issue 1 year ago • 6 comments

I have followed the instructions in the documentation to either load an image into docker images or push to DockerHub by modifying the metadata section with project.json.

In both cases when I run the command, I get a warning 'No output specified with docker-container driver. Build result will only remain in the build cache.'. The command that was issues does not include the --load or --push options.

AlanGRutter avatar Jan 04 '24 02:01 AlanGRutter

@AlanGRutter please share your config here 🙏🏻

gperdomor avatar Jan 26 '24 12:01 gperdomor

@gperdomor I'm experiencing the same issue with our recently migration to NX/nx-container. Building images produces the error @AlanGRutter mentioned.

This is our nx-container configuration for an app (redacted sensitive info) in our project.json

 "container": {
      "executor": "@nx-tools/nx-container:build",
      "dependsOn": ["build"],
      "options": {
        "engine": "docker",
        "metadata": {
          "images": [
            "xxxxxxxxxxx.dkr.ecr.us-west-1.amazonaws.com/my-service"
          ],
          "repository": "xxxxxxxxxxx.dkr.ecr.us-west-1.amazonaws.com",
          "platforms": ["linux/arm64"],
          "push": true,
          "tags": [
            "type=schedule",
            "type=ref,event=branch",
            "type=ref,event=tag",
            "type=ref,event=pr",
            "type=sha,prefix=sha-"
          ]
        }
      }
    }
    ```
    
   We are running this command in GH Actions via this step:
   
   ```yaml
         # Run the `container` nx target
      - name: Docker build & push
        env:
          INPUT_GITHUB_TOKEN: ${{ secrets.MY_GH_TOKEN }}
        run: |
          npx nx run-many -t container --parallel=5

Any help would be appreciated. We followed the documentation to set up the repo/project. Ie running...

nx g @nx-tools/nx-container:init

And selecting Docker

When we run the command in CI and locally, the image is produced, and we can docker run the image, and the apps spin up no problem. It's just the push step that is failing for us.

eric-deeporigin avatar Mar 18 '24 23:03 eric-deeporigin

The fix for us was to run the command with --push option as well

npx nx run-many -t container --parallel=5 --push

eric-deeporigin avatar Mar 18 '24 23:03 eric-deeporigin

The fix for us was to run the command with --push option as well

Thank you, ran into this issue and adding --push worked!

srimanth-duggineni avatar Apr 14 '24 12:04 srimanth-duggineni

I think moving "push": true out of the metadata section into the root of options should work as well.

tomwidmer avatar Aug 09 '24 14:08 tomwidmer

@eric-deeporigin your configuration is wrong, as @tomwidmer says, push option should not be inside metadata… please check this docs… Also you can check the complete schema here here

gperdomor avatar Aug 12 '24 02:08 gperdomor