Skip to Main Content

Forge, Digital Ocean, and Craft CMS

How to resolve a deployment issue when using Laravel Forge and Digital Ocean.

Two years ago I wrote about how to resolve an issue with mysql 5.7 and Craft 2, that issue no longer exists in Craft 3.

Recently I decided to put all my new client hosting on Forge servers rather than Server Pilot for two reasons. First I'm not a fan of the new pricing model Server Pilot introduced earlier this year. Second I liked the idea of built in deployments with Forge, which is a feature missing from Server Pilot. Additionally this means eventually I can drop another paid service, deploybot for deployments.

Last week I discovered that Forge deployments work differently from services such as Deploybot. With Deploybot when it sees a change in your git repo it sshs/sftps into your server and transfers the files over. All good.

Mistakes Made When Using Forge

Often when first setting up a server/site there will be little things, in your CMS settings, that need to be tweaked before they work correctly. What I do in these cases is ftp into the server make changes and test until I have it working, then copy those changes locally and commit to my repo.

I find it's faster than commiting, pushing, commiting again, pushing again and repeating until the issue is fixed. I did this when setting up my Forge server for the first time and thought I was good.

Chuttersnap 478260 Unsplash

I broke deployments by editing files live on the server. With deploybot it deploys the files and ftp's them overwriting the existing files assuming everything is good and that always worked for me.

Forge however does a git pull and pulls the repo changes onto the server. However when forge did this it discovered merge conflicts and cancelled the deployment. The fix is quite simple.

SSH into the server, go to the site directory and run this command.

      git reset --hard && git clean -df

Then login to forge, click the deploy button and everything is good.

Lesson learned, deployments with Forge are using git commands, do not edit files live on the server.

More posts of interest