Environments bug, maybe?
To Reproduce
- Create applications in production (default) env with DB and maybe Redis (im my case it was directus app)
- Create new env for example "sandbox"
- Copy services into same project but "sandbox" env
- Start DB services (Pg & Redis)
- Rename
directusintodirectus-sandboxindocker-compose.yml, update env variables if needed - 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
Can you share the exact docker compose you are using for both compose services?
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:
Unfortunately, I couldn't replicate it. I don't know if you've continued to have the problem?
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 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.