dokploy icon indicating copy to clipboard operation
dokploy copied to clipboard

Support isolated deployment / randomized compose for compose deployment using a git provider

Open yergom opened this issue 8 months ago • 1 comments

What problem will this feature address?

As an example, I have the following compose in a repository:

services:
  openobserve:
    image: openobserve/openobserve:v0.14.7-simd
    restart: always
    depends_on:
      db:
        condition: service_healthy
    environment:
      - ZO_ROOT_USER_EMAIL=${ZO_ROOT_USER_EMAIL}
      - ZO_ROOT_USER_PASSWORD=${ZO_ROOT_USER_PASSWORD}
      - ZO_TELEMETRY=false
      - ZO_META_STORE=postgres
      - ZO_META_POSTGRES_DSN=postgres://postgres:postgres@db:5432/openobserve
      - ZO_DATA="/data"
    volumes:
      - openobserve-data:/data
  db:
    image: postgres:17.5
    restart: always
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U $${POSTGRES_USER} -d $${POSTGRES_DB}"]
      interval: 5s
      timeout: 5s
      retries: 5
    volumes:
      - db-data:/var/lib/postgresql/data
    environment:
      POSTGRES_DB: openobserve
      POSTGRES_USER: postgres
      POSTGRES_PASSWORD: postgres
volumes:
  openobserve-data:
  db-data:

The resulting compose after adding a domain is

services:
  openobserve:
    image: openobserve/openobserve:v0.14.7-simd
    restart: always
    depends_on:
      db:
        condition: service_healthy
    environment:
      - ZO_ROOT_USER_EMAIL=${ZO_ROOT_USER_EMAIL}
      - ZO_ROOT_USER_PASSWORD=${ZO_ROOT_USER_PASSWORD}
      - ZO_TELEMETRY=false
      - ZO_META_STORE=postgres
      - ZO_META_POSTGRES_DSN=postgres://postgres:postgres@db:5432/openobserve
      - ZO_DATA="/data"
    volumes:
      - openobserve-data:/data
    labels:
      - traefik.docker.network=dokploy-network
      - traefik.http.routers.services-openobserve-ywyve7-jh34f4-5-web.rule=Host(`host)
      - traefik.http.routers.services-openobserve-ywyve7-jh34f4-5-web.entrypoints=web
      - traefik.http.services.services-openobserve-ywyve7-jh34f4-5-web.loadbalancer.server.port=5080
      - traefik.http.routers.services-openobserve-ywyve7-jh34f4-5-web.service=services-openobserve-ywyve7-jh34f4-5-web
      - traefik.http.routers.services-openobserve-ywyve7-jh34f4-5-web.middlewares=redirect-to-https@file
      - traefik.http.routers.services-openobserve-ywyve7-jh34f4-5-websecure.rule=Host(`host`)
      - traefik.http.routers.services-openobserve-ywyve7-jh34f4-5-websecure.entrypoints=websecure
      - traefik.http.services.services-openobserve-ywyve7-jh34f4-5-websecure.loadbalancer.server.port=5080
      - traefik.http.routers.services-openobserve-ywyve7-jh34f4-5-websecure.service=services-openobserve-ywyve7-jh34f4-5-websecure
      - traefik.http.routers.services-openobserve-ywyve7-jh34f4-5-websecure.tls.certresolver=letsencrypt
      - traefik.enable=true
    networks:
      - dokploy-network
  db:
    image: postgres:17.5
    restart: always
    healthcheck:
      test:
        - CMD-SHELL
        - pg_isready -U $${POSTGRES_USER} -d $${POSTGRES_DB}
      interval: 5s
      timeout: 5s
      retries: 5
    volumes:
      - db-data:/var/lib/postgresql/data
    environment:
      POSTGRES_DB: openobserve
      POSTGRES_USER: postgres
      POSTGRES_PASSWORD: postgres
volumes:
  openobserve-data: null
  db-data: null
networks:
  dokploy-network:
    external: true

Since the db and openobserve are in different networks, they cannot communicate. Also volumes are not randomized/isolated.

Describe the solution you'd like

I would like to have the possibility of configuring how the compose file is isolated/randomized when using a git provider.

Describe alternatives you've considered

For now, I cannot depend on the git provider and have to use the raw provider.

Additional context

Using latest version 0.22.3

Will you send a PR to implement it?

No

yergom avatar May 09 '25 08:05 yergom

I believe you should be able to create a docker network inside the compose, and add it to both services. Then they should be able to communicate using their service names. Hope this helps!

timmy-time avatar May 25 '25 02:05 timmy-time

I'd also like to second this. My use case is simple: I want to be able to deploy multiple versions of the same app, and right now this means I have to trick with env variables for the network name so they don't clash which is pretty annoying.

depado avatar Aug 05 '25 15:08 depado

Is there a way to interpolate a service name in env variables / compose file with this?

Say, I have two copies of a similar composes (prod / testing), each has my-app service and db service. my-app service needs DB_HOST to connect to the db.

Without isolated deployment I had to use postgres://user:pass@prod-db:5432/ and postgres://user:pass@test-db:5432/. With isolated deployment I'll be able to use postgres://user:pass@db:5432/ for each of them (but only if I remove networks: ['dokploy-network']. But how can I now add domain and let Traefik route traffic to the service?

luixo avatar Aug 28 '25 01:08 luixo