coollabsio / coolify

An open-source & self-hostable Heroku / Netlify / Vercel alternative.
https://coolify.io
Apache License 2.0
31.68k stars 1.63k forks source link

[Bug]: Nixpack variables are not passed down to phases commands #2828

Open Christopher2K opened 2 months ago

Christopher2K commented 2 months ago

Description

When deploying using this Nixpacks, variables are not passed down anymore. I just upgraded to beta v4.0.0-beta.313. The same nixpacks works on local when building with nixpack build .

Minimal Reproduction (if possible, example repository)

When using this nixpack file definition:

providers = ["node"]

[variables]
    NPM_CONFIG_UPDATE_NOTIFIER = 'false'
    NPM_CONFIG_FUND = 'false'
    NPM_CONFIG_PRODUCTION = 'false'
    CADDY_VERSION = '2.8.2' # specify the caddy version to use here, without a 'v' prefix. https://github.com/caddyserver/caddy/releases
    NIXPACKS_NODE_VERSION = '20'

# download and untar caddy
[phases.caddy]
    dependsOn = ['setup']
    cmds = [
        'curl -fsSLo caddy.tar.gz "https://github.com/caddyserver/caddy/releases/download/v${CADDY_VERSION}/caddy_${CADDY_VERSION}_linux_amd64.tar.gz"',
        'tar -zxvf caddy.tar.gz caddy',
        'chmod +x caddy'
    ]
...

The CADDY_VERSION is not resolved in my download command.

Exception or Error

[COMMAND] docker exec g80gsgk bash -c 'bash /artifacts/build.sh'
[OUTPUT]
Dockerfile:19
--------------------
17 | # caddy phase
18 | COPY . /app/.
19 | >>> RUN curl -fsSLo caddy.tar.gz "[https://github.com/caddyserver/caddy/releases/download/v${CADDY_VERSION}/caddy_${CADDY_VERSION}_linux_amd64.tar.gz"](https://github.com/caddyserver/caddy/releases/download/v$%7BCADDY_VERSION%7D/caddy_$%7BCADDY_VERSION%7D_linux_amd64.tar.gz)
20 | RUN tar -zxvf caddy.tar.gz caddy
21 | RUN chmod +x caddy
--------------------
ERROR: failed to solve: process "/bin/bash -ol pipefail -c curl -fsSLo caddy.tar.gz \"[https://github.com/caddyserver/caddy/releases/download/v${CADDY_VERSION}/caddy_${CADDY_VERSION}_linux_amd64.tar.gz\""](https://github.com/caddyserver/caddy/releases/download/v$%7BCADDY_VERSION%7D/caddy_$%7BCADDY_VERSION%7D_linux_amd64.tar.gz/) did not complete successfully: exit code: 22

Version

v4.0.0-beta.313

Christopher2K commented 2 months ago

Rolling back to v4.0.0-beta.277 fixes the issue

ErlendEllingsen commented 1 month ago

Just wanted to confirm this behavior.

{
  "providers": ["python"],
  "buildImage": "ghcr.io/railwayapp/nixpacks:ubuntu-1721088222",
  "variables": {
    "NIXPACKS_METADATA": "python,django,postgres,poetry",
    "NIXPACKS_POETRY_VERSION": "1.3.1",
    "PIP_DEFAULT_TIMEOUT": "100",
    "PIP_DISABLE_PIP_VERSION_CHECK": "1",
    "PIP_NO_CACHE_DIR": "1",
    "PYTHONDONTWRITEBYTECODE": "1",
    "PYTHONFAULTHANDLER": "1",
    "PYTHONHASHSEED": "random",
    "PYTHONUNBUFFERED": "1"
  },
  "phases": {
    "install": {
      "dependsOn": [
        "setup"
      ],
      "cmds": [
        "python -m venv --copies /opt/venv && . /opt/venv/bin/activate && pip install poetry==$NIXPACKS_POETRY_VERSION && poetry install --no-dev --no-interaction --no-ansi"
      ],
      "cacheDirectories": [
        "/root/.cache/pip"
      ],
      "paths": [
        "/opt/venv/bin"
      ]
    },
    "setup": {
      "nixPkgs": [
        "python3",
        "postgresql",
        "gcc"
      ],
      "nixLibs": [
        "zlib",
        "stdenv.cc.cc.lib"
      ],
      "nixOverlays": [],
      "nixpkgsArchive": "bf446f08bff6814b569265bef8374cfdd3d8f0e0"
    }
  },
  "start": {
    "cmd": "python manage.py migrate && gunicorn renmod.wsgi"
  }
}

Does not work with $NIXPACKS_POETRY_VERSION not resolving to anything despite being present in variables. Building locally with latest nixpacks seems to work correct with the same nixpacks.json file.

VCasecnikovs commented 1 month ago

@ErlendEllingsen, hi, how have you fixed this error. I have problem with poetry and nixpacks right now. It depends on NIXPACKS_POETRY_VERSION env, but this env is empty even if I set it

RUN --mount=type=cache,id=kk04cww0ogkckw0g484k4400-/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
VCasecnikovs commented 1 month ago

I have this line of code in file, which was created using nixpacks

ERROR: failed to solve: process "/bin/bash -ol pipefail -c python -m venv --copies /opt/venv && . /opt/venv/bin/activate && pip install poetry==$NIXPACKS_POETRY_VERSION && poetry install --no-dev --no-interaction --no-ansi" did not complete successfully: exit code: 1

This file has variable $NIXPACKS_POETRY_VERSION

It looks like this variable is not set

[stage-0 7/9] RUN --mount=type=cache,id=kk04cww0ogkckw0g484k4400-/root/cache/pip,target=/root/.cache/pip python -m venv --copies /opt/venv && . /opt/venv/bin/activate && pip install poetry== && poetry install --no-dev --no-interaction --no-ansi: 10.13 ERROR: Could not find a version that satisfies the requirement poetry==

How can I set this variable in nixpacks or make it be set automatically