Deploy Laravel
A Laravel application with its database, cache, queues, scheduler and migrations, on Fransys.
What you need
Section titled “What you need”- A project attached to a cluster (First deployment).
- Your application in a GitHub or GitLab repository, or a Docker image that’s already built.
The application service
Section titled “The application service”Add an Application: Fransys runs it from a Docker image, either the one your Dockerfile builds or an image that’s already published. Connect the repository and the CI: see From GitHub or GitLab.
Set the Container port to the one your web server listens on (for example 8080 with the serversideup/php images, 80 with a standard nginx).
The database
Section titled “The database”Add a PostgreSQL or MariaDB database linked to the application. The application receives its connection variables: open the Variables tab to see their names.
Laravel expects DB_HOST, DB_PORT, DB_DATABASE, DB_USERNAME and DB_PASSWORD. Two ways to match them:
- rename each received variable in this service (Name in this service);
- or add
DB_HOST=${…}referencing the received variable, with Allow ${VAR} references.
Add DB_CONNECTION=pgsql (or mariadb).
The application’s variables
Section titled “The application’s variables”Import your .env.example (Multiple variables (.env) mode), then fill in:
APP_KEY: generate it on your machine withphp artisan key:generate --show, and add it protected;APP_ENV=production,APP_DEBUG=false;APP_URL: the service’s address, onfransysapp.comor your own domain.
Keep secrets (API keys, SMTP passwords) as protected variables.
Redis for cache, sessions and queues
Section titled “Redis for cache, sessions and queues”Add a Redis linked to the application: it receives REDIS_HOST, REDIS_PORT and REDIS_PASSWORD, the names Laravel expects. Then CACHE_STORE=redis, SESSION_DRIVER=redis, QUEUE_CONNECTION=redis.
Migrations
Section titled “Migrations”In Deployment commands, add php artisan migrate --force to After the first install and to After an update. Add php artisan optimize in the same place if you cache your configuration.
The scheduler
Section titled “The scheduler”Add a scheduled task php artisan schedule:run every minute (* * * * *). Your tasks stay defined in your code (routes/console.php or app/Console/Kernel.php).
Queue workers
Section titled “Queue workers”Fransys doesn’t change the container command. Have your entrypoint read a role:
#!/bin/shif [ "$CONTAINER_ROLE" = "worker" ]; then exec php artisan queue:work --tries=3fiexec "$@"Then copy the application service and add CONTAINER_ROLE=worker to the copy. Your agent can prepare this copy in a plan.
Files uploaded by your users
Section titled “Files uploaded by your users”A container restarts without its files. For storage/app, add a volume in Storage (mount point /var/www/html/storage/app, depending on your image), or use S3-compatible object storage.
Real time
Section titled “Real time”For broadcasting, add a WebSocket service linked to the application, and the Pusher driver. See Other services.
Let your agent do it
Section titled “Let your agent do it”Open the agent in the repository folder and give it the instruction from the launch guide: it reads the Dockerfile, the docker-compose file and the .env.example, then prepares the port, variables, databases, scheduler and workers in a plan, which you review. See Deploy your code.