Skip to content

slimani-dev/.deployer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Laravel Deployer Scripts

This repository contains modular Deployer scripts for provisioning servers and deploying Laravel applications. It includes configurations for Nginx, PHP-FPM, Supervisor, Node.js + Puppeteer, Redis, and a self-hosted Garage S3 storage cluster.

Installation into a Project

The best way to use these scripts is to add this repository as a git submodule to your Laravel project. Run the following command from the root of your project:

git submodule add git@github.com:slimani-dev/.deployer.git .deployer

Next, copy the deploy.php.example file to the root of your Laravel project:

cp .deployer/deploy.php.example deploy.php

Finally, open deploy.php in your editor and update the configuration block with your repository, domain, server IP, and secrets.

⚠️ Security & Git Guidelines

You MUST add the following to your root project's .gitignore file to avoid leaking credentials:

/.deployer
deploy.php

Note: The garage/secrets.json file auto-generated by this module is already ignored by this module's local .gitignore, but it's best to secure the whole folder out of your main codebase.

Prerequisites

To provision a brand new server, you only need exactly two things:

  1. Root user access to the target destination.
  2. SSH keys properly configured for the root user.

You will also need Deployer installed on your local machine.

Global Installation (Recommended):

composer global require deployer/deployer

You can then run commands simply using dep provision.

Local Installation:

composer require deployer/deployer --dev

If installed locally, you must prefix commands with your vendor binary: vendor/bin/dep provision.

Deployment Workflow

The entire infrastructure setup and code rollout is handled in just two commands. Run these from your local machine.

1. Provision the Server

dep provision

This command installs all required packages (PHP, Node, Nginx, Redis, Supervisor, Garage, Chrome/Puppeteer), sets up the deployer user, and applies permissions.

At the very end of this process, the script will output a public SSH key, which looks similar to this:

================= GIT DEPLOY KEY =================
Copy the following key and add it to your Git repository (GitHub/GitLab) Deploy Keys:

ssh-ed25519 AAAAC3NzaC1lZT....... root@YourServer

==================================================

CRITICAL: You must copy this public key and add it to your project's repository settings as a Deploy Key (or to your personal Git account) before running dep deploy, otherwise the server will be rejected when trying to clone your code!

2. Deploy the Project

dep deploy

This command pulls the code, installs PHP and JS vendors, maps .env variables, and restarts the backend services.

First-Run Checklist

Because the .env file is generated from your .env.example, make sure your .env.example is fully filled out with the structural defaults your application expects!

Crucial Environment Settings: Before your app goes live, verify the copied .env file has these fundamental production values:

  • APP_ENV=production
  • APP_DEBUG=false
  • APP_URL=https://your-domain.com

After your very first deploy finishes, you should manually generate the application key and cache:

dep artisan:key:generate
dep artisan:config:cache

You only need to do this once on the initial setup because the APP_KEY is not generated by default.

Auto-injected Environment Variables

During the provisioning and deployment processes, the deployer scripts will automatically inject and update several variables in your project's .env file (located at shared/.env on the server).

Make sure these keys exist with empty or default values in your local .env.example so the scripts can safely find and replace them!

Database (dep env:db)

These are populated using the target host configuration in deploy.php:

  • DB_DATABASE
  • DB_USERNAME
  • DB_PASSWORD

Garage S3 (dep deploy:garage)

These are generated dynamically via Garage on the server, assigning an isolated bucket and dedicated user keys for your application:

  • AWS_ACCESS_KEY_ID
  • AWS_SECRET_ACCESS_KEY
  • AWS_DEFAULT_REGION (Always set to garage)
  • AWS_BUCKET
  • AWS_USE_PATH_STYLE_ENDPOINT (Always set to true)
  • AWS_URL
  • AWS_ENDPOINT

Puppeteer / Chrome (dep provision:puppeteer)

This specifies the path to the downloaded Chrome binary which Puppeteer or Spatie Browsershot can use to generate PDFs and screenshots:

  • CHROME_PATH (Typically /usr/bin/puppeteer-chrome)

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages