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]: env vars don't work for docker-compose based Preview Deployments #2127

Open
ton77v opened this issue May 3, 2024 · 2 comments
Open
Assignees

Comments

@ton77v
Copy link

ton77v commented May 3, 2024

Description

At least the "Build variable" ones, even though it works fine in normal deployments and I declare/consume them in docker-compose.yaml

Example:

services:
  something:
    build:
      context: .
      args:
        NPM_TOKEN: ${NPM_TOKEN:?NPM_TOKEN not set}
        # ...
    ports:
      - "3333:3000"
    environment:
      - NPM_TOKEN=${NPM_TOKEN:?NPM_TOKEN not set}
      # ...

Works as expected with regular deployments, however for Preview Deployments I'm getting the following error:

[2024-May-03 03:17:50.638004] error while interpolating services.something-pr-75.build.args.NPM_TOKEN: required variable NPM_TOKEN is missing a value: NPM_TOKEN not set

Switching the same resource to the Nixpacks build where nixpacks.toml relies on the same env variables solves the issue

Minimal Reproduction (if possible, example repository)

  1. Add a GitHub repo
  2. Configure the repo-based resource choosing Docker Compose build pack
  3. Add some environment variables and declare them in docker-compose
  4. Add e.g. a custom build command to see the env vars: printenv && docker compose build
  5. Enable Preview Deployments, create PR and push there.

See your env vars missing in the logs e.g. below

Exception or Error

[COMMAND] docker exec XXXXXX bash -c 'cd /artifacts/XXXXXX && printenv && docker compose build'
[OUTPUT]
HOSTNAME=...
PWD=/artifacts/XXXXXX
HOME=/root
SHLVL=1
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
OLDPWD=/artifacts
_=/bin/printenv

Version

v4.0.0-beta.271

@andrasbacsai andrasbacsai self-assigned this May 4, 2024
@maurobender
Copy link
Contributor

I'm also seeing this issue on version v4.0.0-beta.276. Running the env command inside de container only shows variables defined in the docker-compose file but not those defined in the Configuration > Environment Variables > Preview Deployments.

@K4M1s
Copy link

K4M1s commented May 17, 2024

Same problem on version v4.0.0-beta.283

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants