#Publishing Docker image with Python SDK

1 messages · Page 1 of 1 (latest)

umbral seal
#

Hi everyone,

I'm building a docker image via python sdk, and I would like to publish the image to a private registry.

How can I handle it? I don't know if this is correctly, Im begining with dagger. I didn't find any command() function or something similar to execute the "docker login"

Thanks in advance

"""
Execute a command
"""

import sys
import anyio
import dagger

async def build():

    async with dagger.Connection(dagger.Config(log_output=sys.stderr)) as client:

        # get reference to the local project
        src_id = await client.host().workdir(".").id()

        # create empty directory to put build outputs
        outputs = client.directory()

        nodeApp = (

            client.container()

            # pull container
            .from_("node:18")

            # mount cloned repository into image
            .with_mounted_directory("/app", src_id)

            # set working directory
            .with_workdir("/app")

            # run command to install dependencies
            .exec(["npm", "install"])

            # run command to test
            .exec(["npm", "run", "test"])

        )

        await nodeApp.publish("my-remote-repository/dagger:latest")

if __name__ == "__main__":
    anyio.run(build)

rich sluice
#

AFAIK, if you're already logged into the private registry from the same host using docker login, Dagger will use those same credentials. You don't need to run docker login again from your SDK code.

proper adder
#

as Vikram says, doing docker login in the machine where your dagger pipelines run should be enough