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

feat(env): added COOLIFY_RESOURCE_UUID environment variable #4945

Merged

Conversation

nktnet1
Copy link
Contributor

@nktnet1 nktnet1 commented Jan 24, 2025

Changes

  • injects the COOLIFY_RESOURCE_UUID environment variable

Issues


Use Case

When a docker compose stack has the following:

  1. uses redis
  2. have Connect to Predefined Networks enabled
  3. has a file mount config (e.g. superset_config.py) which needs to reference the redis service

Because of (2), the docker compose's redis service will be overshadowed by Coolify's redis when referenced in (3), the file mount config.

The workaround is as described in my #4891 (comment) - basically, in the file mount config, extract the UUID such as:

# superset_config.py
 
COOLIFY_UUID = os.getenv('COOLIFY_CONTAINER_NAME').strip('"').split('-')[-1]

Then use this to reference the correct redis (and postgres) containers, e.g.

# use redis-{COOLIFY_UUID}
CACHE_REDIS_URL =  f"redis://:{os.getenv('REDIS_PASSWORD')}@redis-{COOLIFY_UUID}:6379/1"

# use db-{COOLIFY_UUID}
SQLALCHEMY_DATABASE_URI = f"postgresql+psycopg2://{os.getenv('POSTGRES_USER')}:{os.getenv('POSTGRES_PASSWORD')}@db-{COOLIFY_UUID}:5432/{os.getenv('POSTGRES_DB')}"

This pull request simplifies this process by providing the UUID directly as an environment variable, rather than requiring manual parsing from COOLIFY_CONTAINER_NAME to extract this value.

Copy link

sentry-io bot commented Jan 24, 2025

🔍 Existing Issues For Review

Your pull request is modifying functions with the following pre-existing issues:

📄 File: bootstrap/helpers/shared.php

Function Unhandled Issue
parseDockerComposeFile Exception: Unable to parse at line 1 (near " n8n:"). livewire?component=project.service.n...
Event Count: 1

Did you find this useful? React with a 👍 or 👎

@andrasbacsai
Copy link
Member

Thank you for the PR! It makes sense.

@andrasbacsai andrasbacsai merged commit 55fb4e5 into coollabsio:next Jan 28, 2025
1 check passed
nktnet1 added a commit to nktnet1/coolify that referenced this pull request Jan 28, 2025
@nktnet1
Copy link
Contributor Author

nktnet1 commented Jan 28, 2025

Thank you @andrasbacsai!

I've made a corresponding PR for documentation-coolify here:

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

Successfully merging this pull request may close these issues.

2 participants