uffizzi icon indicating copy to clipboard operation
uffizzi copied to clipboard

Escape env var substitution for env vars passed with an extra `$`, eg: `$$UFFIZZI_URL`

Open waveywaves opened this issue 2 years ago • 2 comments

Describe the bug When passing ENDPOINT=$$UFFIZZI_URL node start as a value in the docker-compose command spec, $$UFFIZZI_URL is not escaped. https://stackoverflow.com/questions/40447029/docker-compose-environment-variable-for-command

Expected behavior $$UFFIZZI_URL is not set during parsing the docker-compose an d is escaped instead. Instead $UFFIZZI_URL is then picked up from the container.

Additional context This is a workaround for https://github.com/UffizziCloud/uffizzi_app/issues/251

waveywaves avatar Sep 20 '22 13:09 waveywaves

docker-compose

command: "ENDPOINT=$$UFFIZZI_URL node start"

kubernetes manifest

container:
  command: "ENDPOINT=$UFFIZZI_URL node start"

waveywaves avatar Oct 03 '22 14:10 waveywaves

Docker Docs reference: https://docs.docker.com/compose/compose-file/#variable-substitution

gadkins avatar Oct 03 '22 14:10 gadkins

@waveywaves Can you please provide a compose file example to test?

moklidia avatar Nov 03 '22 12:11 moklidia

@moklidia here you go

# This compose file is for demonstration only, do not use in prod.
version: "3.9"

x-uffizzi:
  ingress:
    service: app
    port: 3001

services:
  app:
    depends_on:
      - "postgres"
    image: ghcr.io/logto-io/logto:prerelease
    ports:
      - 3001:3001
    environment:
      ALL_YES: 1
      NO_INQUIRY: 0
      TRUST_PROXY_HEADER: 1
      DB_URL_DEFAULT: postgres://postgres:p0stgr3s@localhost:5432
    deploy:
      resources:
        limits:
          memory: 2000M
    command: "ENDPOINT=$$UFFIZZI_URL node start"

  postgres:
    image: postgres:14-alpine
    user: postgres
    environment:
      POSTGRES_USER: "postgres"
      POSTGRES_PASSWORD: "p0stgr3s"
    deploy:
      resources:
        limits:
          memory: 500M

waveywaves avatar Nov 08 '22 10:11 waveywaves

@waveywaves I try to reproduce this case and it works



version: '3'

services:
  app:
    build:
      context: https://github.com/zipofar/test_node
      dockerfile: Dockerfile
    entrypoint: /bin/bash
    command:
      - "-c"
      - "ENDPOINT=$$UFFIZZI_URL node /app/app/app.js"

x-uffizzi:
  ingress:
    service: app
    port: 80

  continuous_preview:
    delete_preview_after: 10h

SCR-20221116-nwv-2

Describe:

I think this problem was because we should set entrypoint and set command like example above. It looks like the command prop does not user friendly at this moment.

My github repo

zipofar avatar Nov 16 '22 14:11 zipofar

This is helpful @zipofar. Glad to know its not really a bug then. I will test this out once. This helps reduce the configuration files for logto immediately. 🙂

waveywaves avatar Nov 16 '22 14:11 waveywaves

Closing this as this already works and we have found a way to use this from the docker-compose file.

waveywaves avatar Nov 23 '22 11:11 waveywaves

Reopening as https://github.com/UffizziCloud/uffizzi/issues/261#issuecomment-1317118658 only works on platform and not via the CLI

waveywaves avatar Nov 28 '22 12:11 waveywaves