Closed lorenzomigliorero closed 3 months ago
@lorenzomigliorero The problem here is that doing so may be a non-trivial solution to temporarily store the volumes, In docker compose there are different ways to declare volumes
version: '3'
services:
servicio:
image: imagen
volumes:
- nombre_volumen:/ruta/en/contenedor
volumes:
nombre_volumen:
services:
servicio:
image: imagen
volumes:
- /ruta/host:/ruta/contenedor
services:
servicio:
image: imagen
volumes:
- type: volume
source: nombre_volumen
target: /ruta/en/contenedor
- type: bind
source: /ruta/host
target: /ruta/contenedor
volumes:
nombre_volumen:
services:
servicio:
image: imagen
volumes:
- ./route:/ruta/en/contenedor:ro
volumes:
nombre_volumen:
services:
servicio:
image: imagen
volumes:
- type: volume
source: logs
target: /var/log
volume:
nocopy: true
volumes:
logs:
services:
servicio:
image: imagen
volumes:
- ${VOLUME_NAME}:/ruta/en/contenedor
volumes:
${VOLUME_NAME}:
I know there are more ways to define than just those
That's why copying the volumes and saved to a .tmp cannot be the best solution since the cases we can have could be alot and also I don't feel very confident to deleting and saving to a another folder, also let's suppose the volumes are very weight, it could take minutes just to copy
with the fix we did was as follows:
we have this structure for each docker compose:
root-folter/
/code
/files
So when you clone from a git repo or raw we need the folder clean, because you can have old files which can make to cause unexpected behaviors
the files folder is used to store the volumes created from the UI in the advanced section, however you can combine them with the docker compose volumes.
so if you do this in each deployment the volumes will be wiped
version: "3.8"
services:
pocketbase:
image: spectado/pocketbase:0.22.12
volumes:
- ./data:/pb_data ❌
- ./public:/pb_public ❌
- ./migrations:/pb_migrations ❌
networks:
dokploy-network:
external: true
but if you do this, you are ensuring you have the volumes on a folder that doesnt delete in any way
version: "3.8"
services:
pocketbase:
image: spectado/pocketbase:0.22.12
volumes:
- ../files/data:/pb_data ✅
- ../files/public:/pb_public ✅
- ../files/migrations:/pb_migrations ✅
networks:
dokploy-network:
external: true
Oh! I'm sorry, I missed this syntax. I got the idea. Files are copied into the parent directory. This works perfectly, thanks! Perhaps something to document? (if not already)
Yeah let's move to the docs repo to add this information
To Reproduce
I reopen this, because it is still not fixed.
Steps
1. Create a compose service
Repository URL: https://github.com/verdaccio/verdaccio.git Branch: master Compose Path: docker-examples/v4/docker-local-storage-volume/docker-compose.yaml
2. Run a deployment
3. Create new content inside the storage volume
SSH into the server and create a new folder inside the docker-examples/v4/docker-local-storage-volume/storage volume. This is not the normal scenario, however verdaccio will do exactly that once you publish a new pkg.
Now the storage directory has 4 packages:
4. Re-run a deployment
The new folder disappeared.
Current vs. Expected behavior
New contents in mounted volumes should persist across deployments.
Provide environment information
Which area(s) are affected? (Select all that apply)
Docker Compose
Additional context
@Siumauricio The way I envision this is:
https://github.com/Dokploy/dokploy/blob/canary/server/utils/providers/git.ts#L43
Before cloning the directory, detect mounts from docker-compose and store them in a .tpm folder. After cloning, restore the volumes. We can perhaps provide a flag for that. It could be useful to reset volumes in certain cases (current behavior). This will be valid for every provider, except docker.ts.
I can work on a PR, but I need your thumbs-up first.