dokploy icon indicating copy to clipboard operation
dokploy copied to clipboard

Environments bug, maybe?

Open Sparo opened this issue 3 months ago • 3 comments

To Reproduce

  1. Create applications in production (default) env with DB and maybe Redis (im my case it was directus app)
  2. Create new env for example "sandbox"
  3. Copy services into same project but "sandbox" env
  4. Start DB services (Pg & Redis)
  5. Rename directus into directus-sandbox in docker-compose.yml, update env variables if needed
  6. Start Directus service

Video attachement:

https://github.com/user-attachments/assets/81e0f798-a269-410b-b607-272d72f1a60c

Current vs. Expected behavior

Currently running service in "sandbox" env. restarts and replaces service from "production" env. and vice-versa. I expect to have two different envs. and can have independent services with the same (similar) configuration that can be on different domains cms.example.com and cms-sandbox.example.com need same structure of the DB. Idea is to have one env to test features, and then propagate via git or by other means deploy to prod. env.

This probably can be solved with multiple projects... and manual copy-paste of the configuration... suppose...

Provide environment information

Ubuntu 22.04
Dokploy Version v0.25.4
VPS Provider: SSD Nodes
trying to deploy Directus CMS with DBs on parallel ENV

Which area(s) are affected? (Select all that apply)

Docker Compose

Are you deploying the applications where Dokploy is installed or on a remote server?

Same server where Dokploy is installed

Additional context

No response

Will you send a PR to fix it?

Maybe, need help

@Siumauricio

Sparo avatar Oct 04 '25 18:10 Sparo

Can you share the exact docker compose you are using for both compose services?

Siumauricio avatar Oct 05 '25 21:10 Siumauricio

sorry for delay...

ENV 1:

services:
  directus:
    image: directus/directus:latest
    volumes:
      - directus_uploads:/directus/uploads
      - directus_extensions:/directus/extensions
    deploy:
      replicas: 3
      update_config:
        parallelism: 1
        order: start-first
        delay: 10s
      restart_policy:
        condition: on-failure
    environment:
      SECRET: ${DIRECTUS_SECRET}
      
      # DB Setup
      DB_CLIENT: "pg"
      DB_CONNECTION_STRING: ${DB_CONNECTION_STRING}
      
      # Cache setup
      CACHE_ENABLED: true
      CACHE_AUTO_PURGE: true
      CACHE_STORE: "redis"
      REDIS: ${REDIS_CONNECTION_STRING}


      STORAGE_LOCATIONS: $STORAGE_LOCATIONS
      STORAGE_CLOUDFLARE_DRIVER: $STORAGE_CLOUDFLARE_DRIVER
      STORAGE_CLOUDFLARE_KEY: $STORAGE_CLOUDFLARE_KEY
      STORAGE_CLOUDFLARE_SECRET: $STORAGE_CLOUDFLARE_SECRET
      STORAGE_CLOUDFLARE_ENDPOINT: $STORAGE_CLOUDFLARE_ENDPOINT
      STORAGE_CLOUDFLARE_BUCKET: $STORAGE_CLOUDFLARE_BUCKET
      STORAGE_CLOUDFLARE_REGION: $STORAGE_CLOUDFLARE_REGION

      PUBLIC_URL: "https://cms.somesite.com"

volumes:
  directus_uploads:
  directus_extensions:

ENV 2:

services:
  directus-sandbox:
    image: directus/directus:latest
    volumes:
      - directus_uploads_sandbox:/directus/uploads
      - directus_extensions_sandbox:/directus/extensions
    deploy:
      replicas: 3
      update_config:
        parallelism: 1
        order: start-first
        delay: 10s
      restart_policy:
        condition: on-failure
    environment:
      SECRET: ${DIRECTUS_SECRET}
      
      # DB Setup
      DB_CLIENT: "pg"
      DB_CONNECTION_STRING: ${DB_CONNECTION_STRING}
      
      # Cache setup
      CACHE_ENABLED: true
      CACHE_AUTO_PURGE: true
      CACHE_STORE: "redis"
      REDIS: ${REDIS_CONNECTION_STRING}

      STORAGE_LOCATIONS: $STORAGE_LOCATIONS
      STORAGE_CLOUDFLARE_DRIVER: $STORAGE_CLOUDFLARE_DRIVER
      STORAGE_CLOUDFLARE_KEY: $STORAGE_CLOUDFLARE_KEY
      STORAGE_CLOUDFLARE_SECRET: $STORAGE_CLOUDFLARE_SECRET
      STORAGE_CLOUDFLARE_ENDPOINT: $STORAGE_CLOUDFLARE_ENDPOINT
      STORAGE_CLOUDFLARE_BUCKET: $STORAGE_CLOUDFLARE_BUCKET
      STORAGE_CLOUDFLARE_REGION: $STORAGE_CLOUDFLARE_REGION

      PUBLIC_URL: "https://cms-sandbox.somesite.com"

volumes:
  directus_uploads_sandbox:
  directus_extensions_sandbox:

Sparo avatar Oct 07 '25 20:10 Sparo

Unfortunately, I couldn't replicate it. I don't know if you've continued to have the problem?

Siumauricio avatar Nov 28 '25 05:11 Siumauricio

Hi @Siumauricio,

I gave up long time ago from that approach, didn't have time to investigate since I needed to go to the production asap.

It would be nice if there is maybe video tutorial or something similar like blog post with images that we can follow to setup multiple environments. I didn't have luck trying that feature myself, but maybe I have missed idea how that should work. I assume that my setup - related to multiple services in one env is typical one.

Since you cannot reproduce this bug, it's better to close this issue, so it does not create noise. When I have time in some future I will try again and test.

If you maybe have time I would appreciate short 4-5 minutes video for setting up env-s with custom docker-compose file.

best, Nenad

Sparo avatar Dec 02 '25 07:12 Sparo

@Sparo Hey

To be clear: There's nothing "special" you need to do to use environments. They're simply a way to group and isolate your resources. When you associate services with an environment in Dokploy, those services are tied exclusively to that environment

Think of it this way: you're working with Docker containers. Starting services in a "sandbox" environment simply means new, separate containers are launched for that environment, independent of your "production" ones. If they were interfering, it would indicate a configuration issue or a bug, as they should be isolated.

Siumauricio avatar Dec 13 '25 07:12 Siumauricio