Deploying Applications

Serverfluent can manage your application deployments on servers provisioned via Serverfluent.

Currently the following application types are supported:

  • Laravel

The following application type support is in works and will be available soon:

  • Symfony
  • Frameworkless PHP applications
  • Wordpress websites
  • Node.js apps

# Deploying apps on provisioned server

Once Serverfluent is done provisioning your server you will see applications link in the sidebar on server overview page. On Applications page you can find the “New Application” button which will direct you to new application creation page.

Creating a new application is pretty straight-forward. Connect your github or other supported git provider by clicking on one of “Choose git provider” options. Fill in the details of your application, select the repository and start the initial deployment.

The following is the list of official Serverfluent git provider applications. Make sure that you are granting access to your repositories only for the following list of application:

When connecting your git provider, it is recommended to grant access only to the repositories that you are planning to use for application deployments.

# Deployment process

There are 2 different deployments that can happen:

  • Inital deployment is the very first time the application is deployed on selected server
  • Basic deployment happens after the initial deployment by either a manual trigger or by a push to repository on specified deploy branch

Once you create the application, Serverfluent will set it up on your provisioned server.

A deployment key to allow access to clone application repository will be created on your connected repository and added on the selected server.

If composer.json file is present in deployment directory, the following command will be executed to install any required composer packages:

composer install --no-interaction

If .env.example is present in the deployment directory, it will be copied to .env. This happens only on the initial deployment. Subsequent automatic or manual deployments will set the contents of .env file to the values that are stored on Configuration > Environment page in application overview. These values are encrypted when stored on Serverfluent side.

Based on application type some additional specific actions might be performed on initial deploymet.

# Deployment script

You can set up a deployment script which will be executed at the end of each deployment. You can find the deployment script page in App overview > Configuration section.

Deployment script is executed after a deployment process pulls the latest changes from your application’s git repository. This script is run as bash script.

You should use deployment script to perform actions that are required for the deployment of your application. This could be reloading php-fpm, clearing caches, rebuilding configuration files, running composer install and performing any deployment tasks that are necessary to bootstrap and make your application operational.

By default, deployment script will be set to sensible default for the selected application type.

Here is an example deployment script for a Laravel application:

# Install composer dependencies
composer install --no-interaction --no-dev

# Clear caches
php artisan cache:clear
php artisan config:clear
php artisan route:clear

# Migrate and rebuild caches
php artisan migrate --force
php artisan route:cache
php artisan config:cache
php artisan view:cache
php artisan optimize

# Reload the php-fpm service
echo '' | sudo -S service php8.2-fpm reload

# Advanced features

# Deployment path

You can customize your application deployment path relative to the root of repository. This is helpful in monorepo structure or when your actual application entrypoint - for example the Laravel application resides in a non root directory on your repository. Provided deployment path will be set as the root directory of all deployments for this application.

For example if you have a repostitory with the following structure:

repo
├── config
├── frontend
└── laravel-backend

And if laravel-backend is the directory where your Laravel application resides. You would then put the “laravel-backend” path into the Deployment path field: