Absolutely, you can deploy a Laravel application without using Docker! Docker is just one way to package and deploy applications, but it's not required. Many teams deploy Laravel apps using more "traditional" methods, especially on shared hosting or VPS environments.
Is it a good idea?
Yes, it's perfectly fine, especially for small to medium projects or when your infrastructure doesn't require containerization. Docker is great for consistency and scaling, but it adds complexity. If you don't need those benefits, you can skip it.
Is it possible?
Yes, and it's very common.
How to do that?
Here’s a typical workflow for deploying a Laravel app automatically without Docker:
1. Use a CI/CD Service
You can use GitHub Actions, GitLab CI, Bitbucket Pipelines, etc. These services can run your tests and, if successful, deploy your code.
2. Deployment Strategies
- SSH & Git Pull: The CI/CD pipeline connects to your server via SSH and pulls the latest code.
- rsync/FTP: The pipeline uploads the new code to your server.
- Deployment Tools: Use tools like Deployer or Laravel Envoyer for zero-downtime deployments.
3. Example: GitHub Actions + SSH
Here’s a simple example using GitHub Actions to deploy to your server via SSH when you push to the main branch:
# .github/workflows/deploy.yml
name: Deploy Laravel App
on:
push:
branches:
- main
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Run tests
run: |
composer install --no-interaction --prefer-dist --optimize-autoloader
cp .env.example .env
php artisan key:generate
php artisan test
- name: Deploy to Production Server
uses: appleboy/[email protected]
with:
host: ${{ secrets.SERVER_HOST }}
username: ${{ secrets.SERVER_USER }}
key: ${{ secrets.SERVER_SSH_KEY }}
script: |
cd /path/to/your/app
git pull origin main
composer install --no-interaction --prefer-dist --optimize-autoloader
php artisan migrate --force
php artisan config:cache
php artisan route:cache
php artisan view:cache
What you need:
- Your server must allow SSH access.
- Your code should be on the server (cloned from Git).
- Set up SSH keys and add them to your GitHub repository secrets.
4. Deployment Tools
If you want more features (like zero-downtime), check out:
- Laravel Envoyer (paid, but very easy)
- Deployer (open-source, PHP-based)
5. Summary
- You do NOT need Docker to automate Laravel deployments.
- Use CI/CD pipelines to run tests and deploy via SSH, rsync, or a deployment tool.
- Keep your
.envand storage files safe—don’t overwrite them unless you intend to.
Let me know if you want a more detailed example for your specific setup!