Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Can't deploy a Python Poetry project #4582

Open
Nevsor opened this issue Dec 15, 2024 · 1 comment · May be fixed by #4598
Open

[Bug]: Can't deploy a Python Poetry project #4582

Nevsor opened this issue Dec 15, 2024 · 1 comment · May be fixed by #4598

Comments

@Nevsor
Copy link

Nevsor commented Dec 15, 2024

Error Message and Logs

Note: This is a separate issue from #4567 where the deploy fails earlier, because a .tool-versions file is present and nixpacks outputs an invalid toml file.

When trying to deploy a project using Poetry, Coolify tries to execute pip install poetry==$NIXPACKS_POETRY_VERSION, but $NIXPACKS_POETRY_VERSION has no value at that point leading to the invalid command pip install poetry==.

Image

Image

Other used env vars also not set:

Image

Steps to Reproduce

  1. Create a reposity containing an (emptry) poetry project (https://github.com/Nevsor/poetry_bug)
  2. Create and deploy a "Public git repository" resource.
  3. The deploy fails.

Example Repository URL

https://github.com/Nevsor/poetry_bug

Coolify Version

v4.0.0-beta.379

Are you using Coolify Cloud?

No (self-hosted)

Operating System and Version (self-hosted)

Debian GNU/Linux 12 (bookworm)

Additional Information

Investigation:

executeInDocker($this->deployment_uuid, "nixpacks build -c /artifacts/thegameplan.json --cache-key '{$this->application->uuid}' --no-error-without-start -n {$this->build_image_name} {$this->workdir} -o {$this->workdir}"),

will generate the files /artifacts/k04g0gc88c8cokwwck0ko0g4/.nixpacks/Dockerfile with content

FROM ghcr.io/railwayapp/nixpacks:ubuntu-1727136237

ENTRYPOINT ["/bin/bash", "-l", "-c"]
WORKDIR /app/


COPY .nixpacks/nixpkgs-bf446f08bff6814b569265bef8374cfdd3d8f0e0.nix .nixpacks/nixpkgs-bf446f08bff6814b569265bef8374cfdd3d8f0e0.nix
RUN nix-env -if .nixpacks/nixpkgs-bf446f08bff6814b569265bef8374cfdd3d8f0e0.nix && nix-collect-garbage -d


ARG NIXPACKS_METADATA NIXPACKS_POETRY_VERSION PIP_DEFAULT_TIMEOUT PIP_DISABLE_PIP_VERSION_CHECK PIP_NO_CACHE_DIR PYTHONDONTWRITEBYTECODE PYTHONFAULTHANDLER PYTHONHASHSEED PYTHONUNBUFFERED
ENV NIXPACKS_METADATA=$NIXPACKS_METADATA NIXPACKS_POETRY_VERSION=$NIXPACKS_POETRY_VERSION PIP_DEFAULT_TIMEOUT=$PIP_DEFAULT_TIMEOUT PIP_DISABLE_PIP_VERSION_CHECK=$PIP_DISABLE_PIP_VERSION_CHECK PIP_NO_CACHE_DIR=$PIP_NO_CACHE_DIR PYTHONDONTWRITEBYTECODE=$PYTHONDONTWRITEBYTECODE PYTHONFAULTHANDLER=$PYTHONFAULTHANDLER PYTHONHASHSEED=$PYTHONHASHSEED PYTHONUNBUFFERED=$PYTHONUNBUFFERED

# setup phase
# noop

# install phase
ENV NIXPACKS_PATH=/opt/venv/bin:$NIXPACKS_PATH
COPY . /app/.
RUN --mount=type=cache,id=j84gos4ok8o80s04gck8osok-/root/cache/pip,target=/root/.cache/pip python -m venv --copies /opt/venv && . /opt/venv/bin/activate && pip install poetry==$NIXPACKS_POETRY_VERSION && poetry install --no-dev --no-interaction --no-ansi


RUN printf '\nPATH=/opt/venv/bin:$PATH' >> /root/.profile

# start
COPY . /app

and /artifacts/k04g0gc88c8cokwwck0ko0g4/.nixpacks/build.sh with content

docker build /artifacts/k04g0gc88c8cokwwck0ko0g4 -f /artifacts/k04g0gc88c8cokwwck0ko0g4/.nixpacks/Dockerfile -t j84gos4ok8o80s04gck8osok:0a88fc211f1f89916aa6688501f9ee10d5136926 --build-arg NIXPACKS_METADATA=python,poetry --build-arg NIXPACKS_POETRY_VERSION=1.3.1 --build-arg PIP_DEFAULT_TIMEOUT=100 --build-arg PIP_DISABLE_PIP_VERSION_CHECK=1 --build-arg PIP_NO_CACHE_DIR=1 --build-arg PYTHONDONTWRITEBYTECODE=1 --build-arg PYTHONFAULTHANDLER=1 --build-arg PYTHONHASHSEED=random --build-arg PYTHONUNBUFFERED=1

Coolify will then use the generated Dockerfile, but ignore the build.sh that passes the --build-args and instead generates its own build.sh:

$build_command = "docker build {$this->addHosts} --network host -f {$this->workdir}/.nixpacks/Dockerfile {$this->build_args} --progress plain -t {$this->build_image_name} {$this->workdir}";
}
$base64_build_command = base64_encode($build_command);
$this->execute_remote_command(
[
executeInDocker($this->deployment_uuid, "echo '{$base64_build_command}' | base64 -d | tee /artifacts/build.sh > /dev/null"),
'hidden' => true,
],
[
executeInDocker($this->deployment_uuid, 'cat /artifacts/build.sh'),
'hidden' => true,
],
[
executeInDocker($this->deployment_uuid, 'bash /artifacts/build.sh'),
'hidden' => true,
]
);

Content of Coolify's build.sh:

docker build --add-host coolify:10.0.1.5 --add-host coolify-db:10.0.1.4 --add-host coolify-realtime:10.0.1.2 --add-host coolify-redis:10.0.1.3 --network host -f /artifacts/k04g0gc88c8cokwwck0ko0g4/.nixpacks/Dockerfile --build-arg SOURCE_COMMIT="0a88fc211f1f89916aa6688501f9ee10d5136926" --build-arg 'COOLIFY_URL=http://j84gos4ok8o80s04gck8osok.142.171.44.215.sslip.io'/ --build-arg 'COOLIFY_FQDN=j84gos4ok8o80s04gck8osok.142.171.44.215.sslip.io' --build-arg 'COOLIFY_BRANCH="main"' --build-arg 'COOLIFY_CONTAINER_NAME="j84gos4ok8o80s04gck8osok-094308368155"' --progress plain -t j84gos4ok8o80s04gck8osok:0a88fc211f1f89916aa6688501f9ee10d5136926 /artifacts/k04g0gc88c8cokwwck0ko0g4
@Nevsor Nevsor added 🐛 Bug Reported issues that need to be reproduced by the team. 🔍 Triage Issues that need assessment and prioritization. labels Dec 15, 2024
@andrasbacsai
Copy link
Member

This will be fixed in the upcoming version.

@github-actions github-actions bot removed 🐛 Bug Reported issues that need to be reproduced by the team. 🔍 Triage Issues that need assessment and prioritization. labels Dec 18, 2024
@andrasbacsai andrasbacsai linked a pull request Dec 18, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants