I have been using Sage (Roots) for quite a while now and started to use Bedrock in my projects too.
The workflow I’m used to right now consists of compiling files locally with Gulp (Grunt) and FTP them to my shared hosting environments. My development and production sites are therefore not in sync in content, so I only use my development site to test changes in my theme before uploading them to production.
But I’m ready for the next step and in automating my deployments with Trellis.
I’m already using the Trellis setup in my current project and successfully run my VM with vagrant on my local machine. I checked out the Digital Ocean droplet options and I roughly understand how everything works.
Before diving into this new chapter, I have a few (probably very nooby) questions:
How would this new workflow look like? Let’s say you have your local development site running and want to make some changes in your theme templates and change some backend settings in WP (add some new ACF fields for instance). Will a ‘deployment’ only push the physical file changes or will it also sync the database changes to production? In other words, is the development and production environment normally identical in content? Or are those still separated and are you suppose to only use your development environment for testing purposes and make the content changes in your production server?
How should you handle wordpress and plugin updates? In your development environment with composer or via the WP interface? And will a deployment after handle all the updates on your production server too?
Can you only access your database on your production server through ssh and mysql terminal commands? Same goes for your remote files, can you still (if necessary) access them through a FTP interface?
How dependent is your production environment from your local development environment? Let’s say for instance your computer crashes with all your local Trellis, Bedrock and Sage files that are not on your remote server, could you easily reconstruct your local setup or are you screwed in that case?
Sorry if any of these questions are too obvious, but I couldn’t find any documentation for dummies about how these deployments exactly work in practice…
Best advice I can give is to give it a try. However, an Ansible deploy is very similar to Capistrano, which may have more discussion and documentation on it. But no, by default, there is no database interaction, it’s all code. There has been quite a few discussions around deploying the database as well. For many, they don’t want the database deployed, since others may be working on the site while they are updating code.
Well with Bedrock, by default you can’t update WP or plugins via the dashboard on staging and production, so the default is to do all updates with Composer. However this doesn’t work for everyone, and it’s very easy to turn this off.
Yes, generally you SSH. You can still use SFTP since that works over SSH. You could use any of the SQL GUI clients like Sequel Pro to SSH and connect to the database with the same credentials as you set up your WP site’s environment with.
If you’ve deployed your site, then all your code and database are on a remote server, correct? If you’re not using version control like Git though, that should really be your next step to learn. Other than the database and uploads which are not generally version controlled and should be backed up with any number of WP backup tools, your code should be safe in a remote version control repository.
The whole idea with using Vagrant is to be able to open up your project on any computer with Vagrant installed, so it really shouldn’t be dependent on your local computer at all. I’m able to continue working on projects whether I’m on my desktop computer running Ubuntu or my Macbook out of the house, because I have the same environments thanks to Vagrant for each project. The biggest worry generally is whether I’ve added an extra key binding to PhpStorm and I haven’t added it yet to the other computer
So update with Composer locally and then run a deployment to stage and/or production environment? But if you update plugins and your WP version, then the database also is altered right? If there’s no database interaction, how is this handled then?
Ah ok clear, thanks! I’m so used to logging in to phpMyAdmin and DirectAdmin environments, that this is something I really need to get used too the most I think.
Not ALL your code in your theme folder. node_modules, assets, bower_components etc are not deployed right? What about the ansible directory? Is that copied over completely?
My code in the Sage theme is version controlled through Github yes, but not the Trellis or Bedrock folder. Not sure if you are supposed to sync them too with Github?
Yeah but the database of your local project is ‘embedded’ in the local VM on that computer, so if you want to continue working on that project on a different computer, you can’t really unless you export/import right?
It’s been five months since my last post in this thread and I have learned a lot since then, so I can answer these myself now (but please correct me if I’m wrong):
As far as I know now, the database doesn’t change when you update a plugin so it’s fine to update your plugins locally and deploy them.[quote=“Twansparant, post:3, topic:4877”]
Not ALL your code in your theme folder. node_modules, assets, bower_components etc are not deployed right?
[/quote]
No they are not, but as long as your assets, package.json & bower.json are in a remote version control repository, then you can always recompile your dist, node_modules & bower_components locally.
Don’t think so, you don’t need it on the droplet since that already is a vm box.[quote=“Twansparant, post:3, topic:4877”]
Not sure if you are supposed to sync them too with Github?
[/quote]
Yes that is best practice. I have a separate private repo for my Trellis clone, and one for my Bedrock clone (including the Sage theme), but it’s recommended to have a separate Sage repo too, so you can update all three separately more easily.[quote=“Twansparant, post:3, topic:4877”]
Yeah but the database of your local project is ‘embedded’ in the local VM on that computer, so if you want to continue working on that project on a different computer, you can’t really unless you export/import right?
[/quote]
This is true, but I found a way to automatically import & export the database with Vagrant triggers and keep everything synced through dropbox: Keep database synced between computers in Trellis/Bedrock/Sage setup - #40 by Twansparant