Craft Deploy Guide
You can deploy Craft 5 via Git Deploys.
- Existing Craft 5 Sites
- If you already have a git repository setup for your Craft 5 site, you do not need to do anything else at this stage
- Else, create a new git repository on your preferred git hosting platform
- Add your Craft 5 site files into the repository, ensuring that the site files are within a singular top level folder. This can be named whatever you like
- New Craft 5 Sites
- If you want to start from our provided template, you can fork/clone/copy the repository and work from there
- Else, follow the above steps for the existing site, following the Craft install guide to get the site files
- You should not include the
vendorfolder that composer creates when installing Craft and it’s dependencies, instead create a build script that runs the install command during the deploy. Add thevendorfolder to your.gitignore- See the template repository for an example of what this build script should look like
- Once you have a git repository setup, navigate to the Webslice console in your browser
- Select the Project you wish to create your website under
- Find the
+ Addbutton and press it - Fill in the details as prompted, ensuring that you pick a PHP version >=
8.1(or whatever version your existing site runs on, if you are restoring an existing site) and that you set theDocument Rootto the name of the folder you created which contains your Craft 5 site files - Hit create and wait for the site to create
- We recommend using the Webslice Environment Variables (Env Vars) tab to store secrets like database usernames/passwords, if you wish to do this, then you can copy how we setup our
.envfile in the template repository- The pattern for this is
CRAFT_DB_PASSWORD=${DB_PASSWORD}, with${DB_PASSWORD}referencing the env var name set in theEnv Varstab
- The pattern for this is
- If you are using a build script, navigate to the
Settingstab, and scroll to the bottom. You can then set the path to the script you wish to run during the deploys - Once the website is online, navigate to the
Databasestab, and clickAdd New Database - Fill in the details as prompted, ensuring that the region is the same as what you selected for the website
- If you are restoring an existing site, make sure the database name and user match your current setup. You may need to change the database host to
localhostin your Craft 5 config
- If you are restoring an existing site, make sure the database name and user match your current setup. You may need to change the database host to
- Hit create and wait for the database to be created and linked to your website
- Navigate to the
Settingstab - Scroll down and press the
Setup Git Deploymentsbutton - You will need to find the SSH clone URL for your repository, for the template repository this is
git@github.com:webslicehq/craft-5-demo.git, and input it into theRepository URLinput box - Generate a deploy key, then add it to your git repository. Your git hosting provider should have instructions on how to add these keys to the repository
- Once the key has been added, hit
Verify Git Accessand wait for access to be verified - Once verified, you can go through and setup the webhooks to allow for future commits to be deployed for your site. Your git hosting provider should also have instructions for this process
- Review the other options shown, changing what you need, then hit save
- Navigate back to the
Deploystab, and the latest commit should be present - Hit the Upload icon button next to the
AVAILABLEicon - Wait for the website to deploy your Craft 5 site, then once the website is
Onlineyou can visit the site via theonwebslice.com- You can also setup DNS for the
onwebslice.comin theDomainstab, but this is not required
- You can also setup DNS for the
- You should now either be at the Craft 5 setup page (You may need to visit
/admin/installto begin the install process), if you are setting up a fresh Craft 5 site, or at your existing sites homepage!