#Even with a "with_mounted_directory" the returning container has an empty folder

1 messages · Page 1 of 1 (latest)

rustic ridge
#

I'm trying to have a container with python and poetry:

@function
async def build_and_publish(
self,
src: dagger.Directory,
registry_username: str,
registry_password: dagger.Secret,
):
"""Build and publish"""

    await (
        dag.container()
        .from_("python:3.11")
        .with_mounted_directory("/app", src)
        .with_workdir("/app")
        .with_exec(["pip", "install", "poetry"])
        .with_exec(["poetry", "install"])
        .with_default_args(["fastapi", "run", "myapp/main.py", "--port", "80"])
        .with_registry_auth(
            "ghcr.io/username/myapp:latest",
            registry_username,
            registry_password,
        )
        .publish("ghcr.io/username/myapp:latest")
    )

The container is succesfully published to Github registry but when I start it with:
docker run -it --pull always ghcr.io/username/myapp bash

The /app folder is empty !
What I missed ?

final robin
#

Hey!

You need to use .with_directory instead

The difference between withDirectory and withMountedDirectory is that withDirectory will include a directory in an image if you export it, and withMountedDirectory will not.

I think we can do a better job explaining this in the docs, ill make a note to do that.

rustic ridge
#

It works ! Thanks