conda-incubator / conda-docker

Create minimal docker images from conda environments
BSD 3-Clause "New" or "Revised" License
60 stars 9 forks source link

Improve error-checking in `chroot_install` #23

Open nkaretnikov opened 10 months ago

nkaretnikov commented 10 months ago

Currently, it has this comment:

    # FIXME: this should reall be check_output(), but chroot or fakechroot is
    # giving some weird segfault after the install command completes ¯\_(ツ)_/¯
    subprocess.call(
        [
            "fakechroot",
            "chroot",
            new_root,
            "/_conda.exe",
            "install",
            "--offline",
            "--file",
            "/opt/conda/pkgs/env.txt",
            "-y",
            "--prefix",
            "/opt/conda",
        ],
        env=env,
        cwd=host_conda_opt,
        stdout=subprocess.DEVNULL,
        stderr=subprocess.DEVNULL,
    )

Suggestions:

nkaretnikov commented 10 months ago

Discovered this due to https://github.com/conda-incubator/conda-store/issues/666.

jaimergp commented 10 months ago

I think we can capture the output without having to check the returncode as done in check_output. IOW:

    process = subprocess.run(
        [
            "fakechroot",
            "chroot",
            new_root,
            "/_conda.exe",
            "install",
            "--offline",
            "--file",
            "/opt/conda/pkgs/env.txt",
            "-y",
            "--prefix",
            "/opt/conda",
        ],
        env=env,
        cwd=host_conda_opt,
        capture_output=True,
        text=True,
        check=False,
    )

And then log the output via process.stdout and process.stderr.

That said, we could also look into less hacky ways to build a docker image without docker. These days buildah, standalone buildkit and/or podman might be good alternatives.

jaimergp commented 10 months ago

Then, about using conda-standalone exe here... it's going to cause trouble one way or another. We could add an option for micromamba so it actually behaves like a binary.