Deployment intro

Published

Updated

🚀

Deploy code via Git.

On fortrabbit, a Git push deploys. The push reaches GitHub, the deployment service builds the code, and the result goes into the storage of the environment. Content and uploads stay out of Git.

Git holds the versions of the code and also carries the changes to fortrabbit.

High-level concept

1 Local   2 Git provider   3 fortrabbit       4 environment
┌─────┐   ┌────────────┐   ┌──────────────┐   ┌──────────────┐
│ Git ├───▶  Git repo  ├───▶  Deployment  ├───▶   storage    │
└─────┘   └────────────┘   └──────────────┘   └──────────────┘
raw
  1. Work in the local Git repo.
  2. Push to GitHub. The push triggers a deployment, see deployment trigger.
  3. The deployment service of fortrabbit builds the code.
  4. The result goes into the storage of the environment.

Deployment steps

A deployment passes these steps, shown in the dashboard:

  1. Pending: waiting for a free slot.
  2. Preparing: the deployment container starts and pulls the code from the Git repo.
  3. Building: the build commands run, such as composer install and npm run build.
  4. Distributing: the result goes into the storage, according to the deployment strategy, then the post deploy commands run.
  5. Succeeded or failed: the deploy log shows the output of every step.

After each successful deployment, all jobs, workers and crons, restart and run the new code.

Code moves up, content moves down

Development happens in the local development environment, and code changes are pushed up. Content often comes from the other side: an editor adds a blog post in production.

WhatGit deploymentAlternative
Code and dependenciesYes-
Database contentsNodump
Image uploads and other filesNorsync

Code access by SSH and SFTP moves content in both directions.

What the storage contains

The storage is not a copy of the Git repo. It holds:

  1. The code from the latest deployment
  2. Build results, such as the vendor folder and compiled assets
  3. Changes made by code access
  4. Runtime data like uploads, logs and cache files

The deployment strategy decides what happens to files that are not in the deployment: replace deletes them, merge keeps them. Exclude patterns protect runtime data with both.

Git only syncs up

Git deployment goes one way, from the repo to the environment. A file uploaded by SFTP cannot be pulled into the Git repo with git pull. This keeps uploads, binaries and other runtime data out of the repo: Git holds the code, SSH and SFTP handle the content.

Software and Git

Git deployment works best with software that keeps code and content in separate folders and installs its dependencies with Composer. Laravel, Symfony and Craft CMS work this way. WordPress and other CMS mix code and content in one folder and need exclude patterns to deploy by Git.

Frequently asked

Can I pull files uploaded by SFTP back into Git on fortrabbit?

No. Git deployment only goes from the repository to the environment. Download files changed on the environment with SFTP, SSH or rsync instead.

#

Written by humans and AI in collaboration.

AI use & editorial processEdit on GitHub ↗