#push azure

1 messages ยท Page 1 of 1 (latest)

wet flume
#

Thanks, I'll give it a go. I think I might have asked my question prematurely ๐Ÿ™‚

wet flume
#

on building the container, using cue if I wanted to specify the WORKDIR would I use the following syntax?

#
            docker.#WorkDir & {
                contents: app
                dest:     "/app"
            },
wet flume
#

Could someone give me a syntax example of pushing with authentication please?

worldly meteor
#

You can use docker.#Set for that purpose

docker.#Set & {
  config: workdir: "/tmp"
}

Why is that? well docker.#Set uses core.#imageConfig, if you see the available options of core.#imageConfig you will see the options
https://github.com/dagger/dagger/blob/main/pkg/dagger.io/dagger/core/image.cue
https://github.com/dagger/dagger/blob/main/pkg/universe.dagger.io/docker/set.cue

GitHub

A portable devkit for CI/CD pipelines. Contribute to dagger/dagger development by creating an account on GitHub.

GitHub

A portable devkit for CI/CD pipelines. Contribute to dagger/dagger development by creating an account on GitHub.

wet flume
#

FTL failed to load plan: push.auth.username: reference "AZURE_USER" not found:

#
    push: docker.#Push & {
        env: AZURE_USER:     client.env.AZURE_USER
        env: AZURE_PASSWORD: client.env.AZURE_PASSWORD

        image: image.output
        dest:  "registry.example.com/app"
        auth?: {
            username: "\(AZURE_USER)"
            secret:   "\(AZURE_PASSWORD)"
        }
    }
bright kite
wet flume
#

FTL failed to load plan: field not allowed: push:

#
dagger.#Plan & {
    client: env: {
        AZURE_USER:     dagger.#Secret
        AZURE_PASSWORD: dagger.#Secret
    }

    client: filesystem: ".": read: contents: dagger.#FS

    actions: build: #reportBuildCUE & {
        app: client.filesystem.".".read.contents
    }

    push: docker.#Push & {
        // env: AZURE_USER:     client.env.AZURE_USER
        // env: AZURE_PASSWORD: client.env.AZURE_PASSWORD

        image: image.output
        dest:  "registry.example.com/app"
        auth?: {
            username: client.env.AZURE_USER
            secret:   client.env.AZURE_PASSWORD
        }
    }
}
#

Oops!

#

I think I've spotted it

wet flume
#

Nope ๐Ÿ˜ฆ

#

FTL failed to load plan: actions.push.image: reference "_build" not found:

wet flume
#
package main

import (
    "dagger.io/dagger"
    "universe.dagger.io/docker"
)

// Build steps are defined in native CUE.
#reportBuildCUE: {
    // Source code of the application
    app: dagger.#FS

    // Container image
    image: _build.output

    // Build steps
    _build: docker.#Build & {
        steps: [
            docker.#Pull & {
                source: "node:lts-alpine"
            },
            docker.#Run & {
                command: {
                    name: "npm"
                    args: ["install", "-g", "@quasar/cli"]
                }
            },
            docker.#Copy & {
                contents: app
                dest:     "/app"
            },
            docker.#Set & {
                config: workdir: "/app"
            },
            docker.#Run & {
                command: {
                    name: "npm"
                    args: ["install"]
                }
            },
            docker.#Run & {
                command: {
                    name: "npm"
                    args: ["run", "build"]
                }
            },
            docker.#Set & {
                config: workdir: "/app/dist/spa"
            },
            docker.#Set & {
                config: expose: "4000": {}
            },
            docker.#Set & {
                config: cmd: ["quasar", "serve", "--history"]
            },
        ]
    }
}
#
dagger.#Plan & {
    client: env: {
        AZURE_USER:     dagger.#Secret
        AZURE_PASSWORD: dagger.#Secret
    }

    client: filesystem: ".": read: contents: dagger.#FS

    actions: {
        build: #reportBuildCUE & {
            app: client.filesystem.".".read.contents
        }

        push: docker.#Push & {
            image: image.output
            dest:  "registry.example.com/app"
            auth?: {
                username: client.env.AZURE_USER
                secret:   client.env.AZURE_PASSWORD
            }
        }
    }

}

#

That's the whole plan. I get a feeling that it's something easy, and I apologize if it is ๐Ÿ™‚

bright kite
#

Can you try:

push: docker.#Push & {
  image: build.image

```
wet flume
#

Just waiting for it to complete now...

#

Should the auth? have a question mark?

#

Interesting. I'm getting: FTL failed to execute plan: task failed: actions.push._push: failed to authorize: failed to fetch anonymous token: unexpected status: 401 Unauthorized

#

@hollow stirrup pinging as requested ๐Ÿ™‚

hollow stirrup
#

Thank you, can you give me a quick reminder of your problem?
You want to push an image to azure registry but it's doesn't work and you have the following error โฌ‡๏ธ

FTL failed to execute plan: task failed: actions.push._push: failed to authorize: failed to fetch anonymous token: unexpected status: 401 Unauthorized

That's right or do I miss something?

wet flume
hollow stirrup
#

Okay, maybe it's because to push an image to azure registry, you must use a token as password instead of your user password
I know that's how it works for amazon, you use a token

#

And that's maybe why you have failed to fetch anonymous token error

wet flume
hollow stirrup
#

You can also log in with docker login. For example, you might have assigned a service principal to your registry for an automation scenario. When you run the following command, interactively provide the service principal appID (username) and password when prompted. For best practices to manage login credentials, see the docker login command reference:
From azure Doc

#

Are you using correct credentials according to the doc? Can you try a manual docker login outside dagger to verify?

wet flume
#

.. bit relates to all of the other options in the document that you've shown me?

#

If I'm understanding your link correctly, I need to supply the tenantid and subscription as well, or am I missing something?

hybrid hill
#

Hi ๐Ÿ™‚ I see that you've set AZURE_USER as a secret, but it should be a string. Also, remove the ? in auth. It's only for the definition, not when using it.

hollow stirrup
wet flume
#

Hopefully it will now complete without errors

#

It worked! Thank you ๐Ÿ™‚