dokploy icon indicating copy to clipboard operation
dokploy copied to clipboard

Feature: post/pre deployments commands

Open a-essawy opened this issue 1 year ago • 18 comments

Hello guys, Thanks for the hard work!

Can we implement such a feature? it would be useful for database seeding or sending a webhook request after deployment.

image

image source: coolify

a-essawy avatar May 29 '24 00:05 a-essawy

Hi , I think we will do something like this but now we have some features to finish.

Mr1Blaze avatar May 29 '24 06:05 Mr1Blaze

Hi, Thanks!

Currently the command we provide is based solely on docker, however could you give me use cases for pre deployment and post deployment, I want to see how good an idea it would be to implement this

Siumauricio avatar May 29 '24 19:05 Siumauricio

Hi, Thanks!

Currently the command we provide is based solely on docker, however could you give me use cases for pre deployment and post deployment, I want to see how good an idea it would be to implement this

I usually use them for seeding the database in dev/staging env, or for sending notifications (using webhooks) about the deployment life cycle.

example: post deployment command: node seeder.js && node scripts/notify-slack.js --project backend

image

a-essawy avatar May 29 '24 19:05 a-essawy

I understand that the post command should be run after the container is lifted, but in the case of the pre it would run a command in a container that does not exist yet.

Siumauricio avatar May 29 '24 22:05 Siumauricio

I believe the way Coolify handles pre commands is to run them on the last deployment container, right before killing it. if there is no previous deployments, the pre command gets ignored. someone could correct me if im wrong here.

example of running pre command: ls image

a-essawy avatar May 30 '24 03:05 a-essawy

I think pre-deploy is a container for testing and when you deploy to production will kill testing container.

Mr1Blaze avatar May 30 '24 17:05 Mr1Blaze

A related feature that could be useful a pre deploy action - backup db before deployment especially.

bgervan avatar Jun 10 '24 16:06 bgervan

I think the post deployment, we have it just when it is initialized at the moment you can pass it in advanced tab -> command, for the pre deployment we can validate if the container exists and it is running execute the command

Siumauricio avatar Jun 10 '24 17:06 Siumauricio

Regarding use cases:

As @bgervan says for pre deploy, backup db would be helpful.

For post deploy, I want to run a clear cache command.

I'd prefer not to add it to the docker image as I'd only like it to occur on deployment, not on container restarts.

benosman avatar Sep 16 '24 21:09 benosman

This feature is very crucial. Please add.

devius avatar Oct 06 '24 01:10 devius

Any updates on this?

fr3fou avatar Jan 26 '25 22:01 fr3fou

Is there any workaround for now? We want deploy Dokploy in our infrastructure but this is show stopper for us. We need to run database migrations as soon as container is in running state after deployment and we don't want execute migration command for every container restart.

BPavol avatar Aug 04 '25 12:08 BPavol

We need to run database migrations as soon as container is in running state ...

exact same for me here

Smurrlawa avatar Aug 06 '25 06:08 Smurrlawa

+1 this is important for db migrations, the current workaround is use an external container builder / registry like GCP or Github Actions that will run a migration job after building but before deploy. The command doesn't necessarily have to be run in a container. For simplicity it could require the user to do "docker run ..." themselves.

robgraeber avatar Sep 06 '25 10:09 robgraeber

+1

kipavy avatar Oct 17 '25 11:10 kipavy

+1

fongfan999 avatar Oct 21 '25 16:10 fongfan999

+1

designly1 avatar Nov 10 '25 19:11 designly1