@@ -8,7 +8,9 @@ Laravel is a web application framework with expressive, elegant syntax. We belie
88
99Example repository [ here] ( https://github.com/coollabsio/coolify-examples/tree/main/laravel ) .
1010
11- ## Requirements
11+ ## Deploy with Nixpacks
12+
13+ ### Requirements
1214
1315- Set ` Build Pack ` to ` nixpacks `
1416- Set the required [ environment variables] ( #environment-variables )
@@ -265,3 +267,107 @@ stderr_logfile=/var/log/worker-inertia-ssr.log
265267stdout_logfile=/var/log/worker-inertia-ssr.log
266268'''
267269```
270+
271+
272+ ## Deploy with Dockerfile and Nginx Unit
273+
274+ ### Prerequisites
275+
276+ 1 . Create a new resource from a private or public repository.
277+ 2 . Set the ` Ports Exposes ` field to ` 8000 ` , for exemple.
278+ 3 . Set default environnement variables using ` Developer view ` in ` Environment Variables ` :
279+
280+ ``` Environnement variables
281+ APP_DEBUG=false
282+ APP_ENV=staging
283+ APP_KEY= #YourAppKey
284+ APP_MAINTENANCE_DRIVER=file
285+ APP_NAME=Laravel
286+ CACHE_STORE=file
287+ DB_CONNECTION= #YourDbConnection
288+ DB_DATABASE= #YourDb
289+ DB_HOST= #YourDbHost
290+ DB_PASSWORD= #YourDbPassword
291+ DB_PORT= #YourDbPort
292+ DB_USERNAME= #YourDbUsername
293+ FILESYSTEM_DISK=public
294+ MAIL_MAILER=log
295+ SESSION_DRIVER=file
296+ ```
297+
298+ 4 . Create a ` Dockerfile ` in the root of your project with the following content:
299+
300+ ``` Dockerfile
301+ FROM unit:1.34.1-php8.3
302+
303+ RUN apt update && apt install -y \
304+ curl unzip git libicu-dev libzip-dev libpng-dev libjpeg-dev libfreetype6-dev libssl-dev \
305+ && docker-php-ext-configure gd --with-freetype --with-jpeg \
306+ && docker-php-ext-install -j$(nproc) pcntl opcache pdo pdo_mysql intl zip gd exif ftp bcmath \
307+ && pecl install redis \
308+ && docker-php-ext-enable redis
309+
310+ RUN echo "opcache.enable=1" > /usr/local/etc/php/conf.d/custom.ini \
311+ && echo "opcache.jit=tracing" >> /usr/local/etc/php/conf.d/custom.ini \
312+ && echo "opcache.jit_buffer_size=256M" >> /usr/local/etc/php/conf.d/custom.ini \
313+ && echo "memory_limit=512M" > /usr/local/etc/php/conf.d/custom.ini \
314+ && echo "upload_max_filesize=64M" >> /usr/local/etc/php/conf.d/custom.ini \
315+ && echo "post_max_size=64M" >> /usr/local/etc/php/conf.d/custom.ini
316+
317+ COPY --from=composer:latest /usr/bin/composer /usr/local/bin/composer
318+
319+ WORKDIR /var/www/html
320+
321+ RUN chown -R unit:unit /var/www/html/storage bootstrap/cache && chmod -R 775 /var/www/html/storage
322+
323+ COPY . .
324+
325+ RUN chown -R unit:unit storage bootstrap/cache && chmod -R 775 storage bootstrap/cache
326+
327+ RUN composer install --prefer-dist --optimize-autoloader --no-interaction
328+
329+ COPY unit.json /docker-entrypoint.d/unit.json
330+
331+ EXPOSE 8000
332+
333+ CMD ["unitd" , "--no-daemon" ]
334+ ```
335+
336+ 3 . Create a ` unit.json ` file (lowercase) at the root of your project with the following content:
337+
338+ ``` unit.json
339+ {
340+ "listeners" : {
341+ "*:8000" : {
342+ "pass" : " routes"
343+ }
344+ },
345+
346+ "routes" : [
347+ {
348+ "match" : {
349+ "uri" : " !/index.php"
350+ },
351+ "action" : {
352+ "share" : " /var/www/html/public$uri" ,
353+ "fallback" : {
354+ "pass" : " applications/laravel"
355+ }
356+ }
357+ }
358+ ],
359+
360+ "applications" : {
361+ "laravel" : {
362+ "type" : " php" ,
363+ "root" : " /var/www/html/public/" ,
364+ "script" : " index.php"
365+ }
366+ }
367+ }
368+ ```
369+ 4 . Set Post-deployment to :
370+ ```
371+ php artisan optimize:clear && php artisan config:clear && php artisan route:clear && php artisan view:clear && php artisan optimize
372+
373+
0 commit comments