Skip to content

samirdjelal/deployer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

24 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Deployer

deployer crate test build issues Downloads MIT License deployer documentation dependency status

Laravel Zero Downtime Deployer

A Laravel deployment tool with zero downtime deployment and rollback capabilities, similar to deployer.org.

Features

  • Zero Downtime Deployment: Deploy your Laravel application without any downtime
  • Atomic Deployments: All deployments are atomic, meaning they either complete successfully or not at all
  • Release Management: Keep a configurable number of releases for easy rollbacks
  • Shared Resources: Share files and directories between releases
  • Rollback Capability: Easily rollback to previous releases if needed

Usage

Using the binary

# Install the deployer
$ cargo install deployer

# Create a new template configuration file
$ deployer init [config_file]

# Deploy your application
$ deployer [config_file]
# or
$ deployer deploy [config_file]

# List available releases
$ deployer list-releases [config_file]

# Rollback to the previous release
$ deployer rollback [config_file]

# Rollback to a specific release
$ deployer rollback [config_file] [release]

If config_file is not specified, deployer.yml will be used by default.

Using the crate

Add the following dependency to the Cargo.toml file:

[dependencies]
deployer = "0.0.2"
chrono = "0.4"

And then get started in your main.rs:

use deployer::Deployer;

fn main() {
    // Initialize deployer with configuration
    let config = "deployer.yml";
    let mut deployer = Deployer::new();
    deployer.configure(config);

    // Deploy the application
    deployer.deploy();

    // Or list available releases
    // deployer.list_releases();

    // Or rollback to the previous release
    // deployer.rollback(None);

    // Or rollback to a specific release
    // deployer.rollback(Some("20230101120000".to_string()));
}

Development

# Run in development mode
$ cargo run -- deployer.yml

# Build for production
$ cargo build --release
$ target/release/deployer deployer.yml

# Run tests
$ cargo test

How It Works

The deployer creates a directory structure on your server:

/path/to/deploy
β”œβ”€β”€ current -> /path/to/deploy/releases/20230101120000
β”œβ”€β”€ releases
β”‚   β”œβ”€β”€ 20230101120000
β”‚   β”œβ”€β”€ 20230101110000
β”‚   └── 20230101100000
└── shared
    β”œβ”€β”€ .env
    └── storage
  1. Each deployment creates a new timestamped release directory
  2. Shared files and directories are symlinked from the shared directory
  3. Once the deployment is complete, the "current" symlink is updated to point to the new release
  4. Old releases are cleaned up based on the keep_releases configuration

Configuration file deployer.yml

---
repository: git@github.com:samirdjelal/deployer.git
hostname: 127.0.0.1:22
username: root
password: password
deploy_path: /opt/deployer
keep_releases: 5
http_user: daemon
php_path:

shared_files:
  - .env

shared_dirs:
  - storage

writable_use_sudo: false
writable_recursive: true
writable_chmod_mode: 0777
writable_dirs:
  - bootstrap/cache
  - storage
  - storage/app
  - storage/app/public
  - storage/framework
  - storage/framework/cache
  - storage/framework/sessions
  - storage/framework/views
  - storage/logs

pre_deploy_commands:
  - ls -lah /opt/lampp/xampp
  - echo "Hello World" > /root/file.txt
  - cat /root/file.txt

post_deploy_commands:
  - echo "Good bye!"

License

This project is licensed under the MIT license.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in deployer by you, shall be licensed as MIT, without any additional terms or conditions.

Releases

No releases published

Sponsor this project

Packages

No packages published

Languages