How to roll back a Dokku deployment

Search for a command to run...

No comments yet. Be the first to comment.
Introduction So, you want to have your own infrastructure while having the best commodities to push your code to production, right? Then you have found your guide. We will go through every single thing that you will need. We will set up a server on D...
Introduction I run a large WhatsApp group and I often need to mention everyone in the group. But there are no real solutions for mentioning all members. WhatsApp does not natively do it, and there was a Firefox browser extension, but it was abandoned...

Introduction This past week I was toying around with the HTML5 canvas element, trying to join two images together. At first, it seemed fine, but when I tried to reload the website, it was a mess. One image would load, but the other wouldn't. Investig...

Introduction I have worked on projects that required the production and testing database to be the same. This could be because some features work in MariaDB, but not in SQLite. Or some bugs appear in MySQL, but not in PostgreSQL. When you're working ...

Introduction I'm going to explain how to build a free plan for your Laravel Spark Next application. I will be using Paddle as the payment gateway, but the steps are almost identical with Stripe. Best of all? No credit card required for the free plan....

Sometimes you end up deploying an application to Dokku and then realize that you want to revert the changes you made.
In this tutorial we'll go over how to roll back a Dokku deployment.
Keep in mind that rolling back a deployment is a dangerous operation, proceed with caution.
Don't have a Dokku server? Check out my Dokku tutorial.
First well need to get the hash of the commit that we want to roll back to.
To accomplish that, list out the last 10 commits that have been made to the repository.
git log --pretty=format:"%h - %s" -10
You will get an output similar to this:
3cacb03 - Revert "build: broaden possible purged files"
25e3b2b - chore: move node dependency to dev dependencies
6a42416 - Revert "ci: run npm "build" script in predeploy stage"
0b53fdd - ci: execute php buildpack first
2d27d60 - ci: run npm "build" script in predeploy stage
1bc1276 - build: broaden possible purged files
1bed300 - style: lint
5ab255c - Revert "build: only run tailwind JIT mode on local"
23b0c4b - build: fix data-tables styles getting purged
52ca32e - ci: move scripts back to app.json
Now copy the hash of the commit that you want to roll back to.
For example 2d27d60.
Now that we have the commit hash, we can roll back to it.
Just force push to Dokku with the commit hash, instead of the local branch.
# git push --force <remote> <local branch>:<remote branch>
git push --force dokku de7fc85:master
That is it! Now Dokku will build the application from that commit. Effectively rolling back to that commit.
That was easy, wasn't it?
If you have found this useful, then you should follow me, I will be posting more interesting content! 🥰
Or support me financially. 💸
Congratulations, today you have learned how to roll back a Dokku deployment.
Let me know if the tutorial was useful to you in the comments!