Skip to content

Target when logging in to a private registry in a build requires a repo? #1105

@helderco

Description

@helderco

It appears that when I connect to my private registry for a build, I get an unauthorized response unless the target includes a repo (even if it doesn't exist).

package main

import (
    "alpha.dagger.io/dagger"
    "alpha.dagger.io/dagger/op"
)

#Auth: {
    target: dagger.#Input & {string}
    username: dagger.#Input & {string}
    secret: dagger.#Input & {dagger.#Secret | string}
}

// Add `auths` to `docker.#Build`
#Build: {
    source: dagger.#Input & {dagger.#Artifact}
    dockerfile: dagger.#Input & {*null | string}
    args?: [string]: string | dagger.#Secret
    auths: [...#Auth]

    #up: [
        for auth in auths {
            op.#DockerLogin & {
                for k, v in auth {
                    "\(k)": v
                }
            }
        },
        op.#DockerBuild & {
            context: source
            if dockerfile != null {
                "dockerfile": dockerfile
            }
            if args != _|_ {
                buildArg: args
            }
        },
    ]
}

image: #Build & {
    source: null
    dockerfile: """
    FROM registry.example.net/php:7.4
    """
    auths: [
        #Auth & {
            target: "registry.example.net"
            username: "example"
        }
    ]
}

This returns a 401 Unauthorized:

$ dagger up
[✗] image                                                                                                                                                                                            0.4s
6:32PM FTL failed to up environment: task failed: registry.example.net/php:7.4: unexpected status code [manifests 7.4]: 401 Unauthorized

But this works:

image: #Build & {
    source: null
    dockerfile: """
    FROM registry.example.net/php:7.4
    """
    auths: [
        #Auth & {
            target: "registry.example.net/wat"  // repo doesn't exist in the registry
            username: "example"
        }
    ]
}

Although with docker.io it isn't required. The following works:

image: #Build & {
    source: null
    dockerfile: """
    FROM helder/private-repo
    """
    auths: [
        #Auth & {
            target: "docker.io"
            username: "helder"
        }
    ]
}

I'm running a registry:2 container with basic auth behind an Nginx reverse proxy.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions