coollabsio / coolify

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

[Bug]: "This variable is not found in the compose file, so it won't be used." is misleading #2361

Open hades200082 opened 1 month ago

hades200082 commented 1 month ago

Description

When adding environment variables to a github integrated deployment, every environment variable (that are used by the app I'm deploying) is flagged with a yellow warning that states "This variable is not found in the compose file, so it won't be used."

This is misleading since these variables are used. Just not in the compose file.

Minimal Reproduction (if possible, example repository)

Any compose-based application that needs environment variables that are not referenced in the compose.

Exception or Error

N/A

Version

v4.0.0-beta.294

andrasbacsai commented 1 month ago

Can you show me an example compose file?

hades200082 commented 1 month ago

This is the docker-compose from Coolify after I setup my repo to deploy to Coolify via the Private Github integration as a docker compose.

services:
  healthchecks:
    image: healthchecks
    build: .
    environment:
      - SERVICE_FQDN_HEALTHCHECKS
      - 'ConnectionStrings__HealthCheckSql=Data Source=sqlserver;Initial Catalog=Distinction_HealthChecks;Integrated Security=False;User ID=sa;Password=${SERVICE_PASSWORD_SQL};Connect Timeout=60'
    ports:
      - '${PORT-7080}:80'
    networks:
      fk4kwsw: null
    labels:
      - traefik.enable=true
      - traefik.http.middlewares.gzip.compress=true
      - traefik.http.middlewares.redirect-to-https.redirectscheme.scheme=https
      - traefik.http.routers.http-0-is8s40c.entryPoints=http
      - 'traefik.http.routers.http-0-is8s40c.rule=Host(`healthchecks.distinctionserver.com`) && PathPrefix(`/`)'
      - traefik.http.routers.https-0-is8s40c.entryPoints=https
      - traefik.http.routers.https-0-is8s40c.middlewares=gzip
      - 'traefik.http.routers.https-0-is8s40c.rule=Host(`healthchecks.distinctionserver.com`) && PathPrefix(`/`)'
      - traefik.http.routers.https-0-is8s40c.tls.certresolver=letsencrypt
      - traefik.http.routers.https-0-is8s40c.tls=true
      - 'caddy_0.encode=zstd gzip'
      - 'caddy_0.handle_path.0_reverse_proxy={{upstreams}}'
      - 'caddy_0.handle_path=/*'
      - caddy_0.header=-Server
      - 'caddy_0.try_files={path} /index.html /index.php'
      - 'caddy_0=https://healthchecks.distinctionserver.com'
      - caddy_ingress_network=fk4kwsw
      - coolify.managed=true
      - coolify.version=4.0.0-beta.294
      - coolify.applicationId=4
      - coolify.type=application
      - coolify.name=healthchecks-fk4kwsw-153248842035
      - coolify.pullRequestId=0
    restart: unless-stopped
    container_name: healthchecks-fk4kwsw-153248842035
  sqlserver:
    image: 'mcr.microsoft.com/mssql/server:2022-latest'
    environment:
      - MSSQL_SA_PASSWORD=$SERVICE_PASSWORD_SQL
      - ACCEPT_EULA=Y
    volumes:
      - '/data/healthchecks/mssql:/opt/mssql/data'
    networks:
      fk4kwsw: null
    labels:
      - coolify.managed=true
      - coolify.version=4.0.0-beta.294
      - coolify.applicationId=4
      - coolify.type=application
      - coolify.name=sqlserver-fk4kwsw-153248842423
      - coolify.pullRequestId=0
    restart: unless-stopped
    container_name: sqlserver-fk4kwsw-153248842423
volumes: {  }
networks:
  fk4kwsw:
    name: fk4kwsw
    external: true

The application is a .Net 7 web-app and I used a standard .Net 7 Dockerfile for the build.

The .Net application uses Microsoft's Configuration packages to load environment variables within the application code and use them internally in the application. We have a lot of environment variables configured in Coolify that the app uses, but which are not part of the docker-compose yaml.

It's those environment variables that I'm talking about in this issue.

hades200082 commented 1 month ago

That said, even the SQL password variable is showing that it won't be used (ven though it is used)

image

EleosOS commented 3 weeks ago

Hi, I just came across this. I specifically added all environment variables to my docker-compose.yml after I got this warning for every env var I added in Coolify (I had them in a separate .env file before that).

This is the compose content that Coolify generated:

services:
  mariadb:
    image: mariadb
    environment:
      MARIADB_DATABASE: palmdb
      MARIADB_USER: palm
      MARIADB_PASSWORD: changeme
      MARIADB_ROOT_PASSWORD: changeme
    volumes:
      - 'mariadb-data:/var/lib/mysql'
    networks:
      vkc8kso: null
    labels:
      - coolify.managed=true
      - coolify.version=4.0.0-beta.297
      - coolify.applicationId=4
      - coolify.type=application
      - coolify.name=mariadb-vkc8kso-194612065835
      - coolify.pullRequestId=0
    restart: unless-stopped
    container_name: mariadb-vkc8kso-194612065835
  lpt:
    build: .
    depends_on:
      - mariadb
    environment:
      DISCORD_TOKEN: null
      GUILD_ID: null
      VC_NOTIFY_PING_CHANNEL_ID: null
      WEBHOOK_SERVER_IMAGE_HUE: null
      WEBHOOK_CUSTOM_ROLES: null
      WEBHOOK_COMMAND_USE: null
      WEBHOOK_GUILD_MEMBER_REMOVE: null
      WEBHOOK_VC_NOTIFY_LOG: null
      WEBHOOK_BOOST_LOST: null
      TYPEORM_DB_TYPE: mariadb
      DB_HOST_URI: mariadb
      DB_PORT: 3306
      DB_NAME: palmdb
      DB_USERNAME: palm
      DB_PASSWORD: changeme
    networks:
      vkc8kso: null
    labels:
      - coolify.managed=true
      - coolify.version=4.0.0-beta.297
      - coolify.applicationId=4
      - coolify.type=application
      - coolify.name=lpt-vkc8kso-194612065960
      - coolify.pullRequestId=0
    restart: unless-stopped
    container_name: lpt-vkc8kso-194612065960
volumes:
  mariadb-data:
    name: mariadb-data
networks:
  vkc8kso:
    name: vkc8kso
    external: true

Even after adding them to the compose file Coolify still shows the warning on every variable, despite them being used just fine.

hades200082 commented 3 weeks ago

@EleosOS You're not actually using them in that file.

This is how you use them in the way Coolify should see:

MARIADB_DATABASE: ${MARIADB_DATABASE-palmdb} # Defaults to palmdb if not set in Coolify

or just

MARIADB_DATABASE: ${MARIADB_DATABASE} # No default

The issue in this bug though is that not all environment variables will be for coolify. Many will be for the app that's running in the container coolify is managing. Coolify can't know about these so always shows the message which is misleading.

hades200082 commented 5 days ago

@andrasbacsai Feedback is above