#push azure
1 messages ยท Page 1 of 1 (latest)
Hi,
docker.#Push doesn't work ?
Here is an example from the go on docker swarm doc: https://github.com/dagger/dagger/blob/1c36f8ea99d67bda479a312014eede676f11f49a/docs/tests/use-cases/go-docker-swarm/full/particubes.docs.cue#L132-L136.
It also accepts these fields: https://github.com/dagger/dagger/blob/1c36f8ea99d67bda479a312014eede676f11f49a/pkg/universe.dagger.io/docker/push.cue#L17-L20, for auth purposes
Thanks, I'll give it a go. I think I might have asked my question prematurely ๐
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"
},
Could someone give me a syntax example of pushing with authentication please?
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
Dagger stands as a powerful CI/CD tool that works on any environment.
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)"
}
}
The auth part doesn't happen in a shell, you cannot set the env like that. You need to directly reference the client.env... key in the username and secret fields
auth?: {
username: "\(AZURE_USER)"
secret: "\(AZURE_PASSWORD)"
}
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
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 ๐
Can you try:
push: docker.#Push & {
image: build.image
```
Thank you! that worked ๐
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 ๐
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?
Yes, that's exactly correct. I also had an issue with compiling, but @bright kite solved that one for me ๐
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
I remember we had that kind of things on v0.1.0: https://github.com/dagger/dagger/blob/v0.1.0/pkg/alpha.dagger.io/azure/azure.cue
Yes, I believe that to be correct, however, I am actually using the password listed in the Azure registry part, along with the username, so I'm a bit stumped.
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?
Yes, I can log in fine manualy. What I'm not understanding is t how:```
auth?: {
username: client.env.AZURE_USER
secret: client.env.AZURE_PASSWORD
}
.. 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?
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.
It's just an old definition of azure package, I thought it could help but do not follow it as a source of truth
Perfect! Thank you! It's "pushing" now ๐
Hopefully it will now complete without errors
It worked! Thank you ๐