@@ -87643,19 +87643,6 @@ vendor/
8764387643*.DS_Store
8764487644``````
8764587645
87646- ## File: deploy.sh
87647- ``````bash
87648- #!/usr/bin/env bash
87649- echo "Running composer"
87650- composer install --no-dev --working-dir=/var/www/html
87651- echo "Caching config..."
87652- php artisan config:cache
87653- echo "Caching routes..."
87654- php artisan route:cache
87655- echo "Running migrations..."
87656- php artisan migrate --force
87657- ``````
87658-
8765987646## File: local.ini
8766087647``````
8766187648; Custom PHP settings for production
@@ -88662,65 +88649,102 @@ services:
8866288649 sizeGB: 1 # Size of the disk in GB, integer
8866388650``````
8866488651
88665- ## File: Dockerfile
88666- ``````dockerfile
88667- # Stage 1: Compile Frontend Assets
88668- FROM node:20-alpine AS node_builder
88669-
88670- WORKDIR /app/frontend
88671-
88672- # Copy package files and essential build configuration
88673- COPY package.json package-lock.json* webpack.mix.js tailwind.config.js postcss.config.js* .babelrc* ./
88674- # Ensure postcss.config.js and .babelrc are optional by using * in case they don't exist
88675-
88676- # Install all dependencies (including devDependencies like laravel-mix)
88677- RUN npm ci
88678-
88679- # Copy frontend source code (js, css, images, etc.)
88680- COPY resources/js ./resources/js
88681- COPY resources/css ./resources/css
88682- COPY resources/img ./resources/img
88683- # Add other relevant resource directories if needed
88684-
88685- # Compile assets for production
88686- RUN npm run production
88687-
88688- # Stage 2: Setup PHP Application Environment using richarvey/nginx-php-fpm
88689- FROM richarvey/nginx-php-fpm:3.1.6 AS app
88690-
88691- # Set Laravel Environment Variables as per the article
88692- ENV APP_ENV production
88693- ENV APP_DEBUG false
88694- ENV LOG_CHANNEL stderr
88695- ENV APP_KEY ${APP_KEY}
88696- ENV SKIP_COMPOSER 1
88697- ENV WEBROOT /var/www/html/public
88698- ENV PHP_ERRORS_STDERR 1 # Send PHP errors to stderr for Docker logging
88699- ENV RUN_SCRIPTS 1 # Enable execution of scripts in /scripts directory
88700- ENV REAL_IP_HEADER 1 # If behind a proxy, trust X-Forwarded-For
88701- ENV COMPOSER_ALLOW_SUPERUSER 1 # Allow composer to run as root if needed by scripts
88702-
88703- # Set working directory
88704- WORKDIR /var/www/html
88705-
88706- # Copy all application files
88707- COPY . .
88708-
88709- # Copy compiled assets from the node_builder stage
88710- COPY --from=node_builder /app/frontend/public ./public
88711-
88712- # Copy our Nginx site configuration to the standard location for richarvey images
88713- COPY nginx-site.conf /etc/nginx/sites-available/default
88714-
88715- # Copy our deploy script to the location where richarvey image expects to run scripts
88716- # Ensure deploy.sh has necessary commands (composer install, migrations, cache)
88717- RUN mkdir -p /scripts
88718- COPY deploy.sh /scripts/00-laravel-deploy.sh
88719- RUN chmod +x /scripts/00-laravel-deploy.sh
88652+ ## File: deploy.sh
88653+ ``````bash
88654+ #!/bin/sh
88655+ set -ex # Exit immediately if a command exits with a non-zero status and print commands.
88656+ echo "Running composer"
88657+ # Attempt to clear composer cache first, then install
88658+ composer clear-cache --working-dir=/var/www/html || echo "Failed to clear composer cache, continuing..."
88659+ composer install --no-dev --no-interaction --no-progress --optimize-autoloader --working-dir=/var/www/html
88660+ echo "Checking for vendor/autoload.php..."
88661+ if [ -f "/var/www/html/vendor/autoload.php" ]; then
88662+ echo "vendor/autoload.php found."
88663+ else
88664+ echo "ERROR: vendor/autoload.php NOT found after composer install!"
88665+ echo "Listing contents of /var/www/html/vendor/ if it exists:"
88666+ ls -la /var/www/html/vendor/ || echo "/var/www/html/vendor/ directory does not exist."
88667+ exit 1 # Exit if autoload is missing
88668+ fi
88669+ echo "Caching config..."
88670+ php artisan config:cache
88671+ echo "Caching routes..."
88672+ php artisan route:cache
88673+ echo "Running migrations..."
88674+ php artisan migrate --force
88675+ echo "Deployment script finished successfully."
88676+ ``````
8872088677
88721- # The base image (richarvey/nginx-php-fpm) handles starting Nginx, PHP-FPM,
88722- # and running scripts from /scripts. Its default CMD is /start.sh.
88723- CMD ["/start.sh"]
88678+ ## File: composer.json
88679+ ``````json
88680+ {
88681+ "name": "laravel/laravel",
88682+ "type": "project",
88683+ "description": "The Laravel Framework.",
88684+ "keywords": [
88685+ "framework",
88686+ "laravel"
88687+ ],
88688+ "license": "MIT",
88689+ "require": {
88690+ "php": "8.2.10",
88691+ "guzzlehttp/guzzle": "7.8.1",
88692+ "laravel/cashier": "^15.0",
88693+ "laravel/framework": "10.41.0",
88694+ "laravel/sanctum": "3.3.3",
88695+ "laravel/tinker": "2.9.0"
88696+ },
88697+ "require-dev": {
88698+ "fakerphp/faker": "1.23.1",
88699+ "laravel/dusk": "7.12.1",
88700+ "laravel/pint": "1.13.11",
88701+ "laravel/sail": "1.28.0",
88702+ "mockery/mockery": "1.6.12",
88703+ "nunomaduro/collision": "7.10.0",
88704+ "phpunit/phpunit": "10.5.36",
88705+ "spatie/laravel-ignition": "2.4.1",
88706+ "squizlabs/php_codesniffer": "3.8.1"
88707+ },
88708+ "autoload": {
88709+ "psr-4": {
88710+ "App\\": "app/",
88711+ "Database\\Factories\\": "database/factories/",
88712+ "Database\\Seeders\\": "database/seeders/"
88713+ }
88714+ },
88715+ "autoload-dev": {
88716+ "psr-4": {
88717+ "Tests\\": "tests/"
88718+ }
88719+ },
88720+ "scripts": {
88721+ "post-autoload-dump": [
88722+ "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
88723+ "@php artisan package:discover --ansi"
88724+ ],
88725+ "post-update-cmd": [
88726+ "@php artisan vendor:publish --tag=laravel-assets --ansi --force"
88727+ ],
88728+ "post-root-package-install": [
88729+ "@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
88730+ ],
88731+ "post-create-project-cmd": [
88732+ "@php artisan key:generate --ansi"
88733+ ]
88734+ },
88735+ "extra": {
88736+ "laravel": {
88737+ "dont-discover": []
88738+ }
88739+ },
88740+ "config": {
88741+ "optimize-autoloader": true,
88742+ "preferred-install": "dist",
88743+ "sort-packages": true
88744+ },
88745+ "minimum-stability": "dev",
88746+ "prefer-stable": true
88747+ }
8872488748``````
8872588749
8872688750## File: .circleci/config.yml
@@ -88806,76 +88830,68 @@ workflows:
8880688830 - vue-tests
8880788831``````
8880888832
88809- ## File: composer.json
88810- ``````json
88811- {
88812- "name": "laravel/laravel",
88813- "type": "project",
88814- "description": "The Laravel Framework.",
88815- "keywords": [
88816- "framework",
88817- "laravel"
88818- ],
88819- "license": "MIT",
88820- "require": {
88821- "php": "8.2.10",
88822- "guzzlehttp/guzzle": "7.8.1",
88823- "laravel/cashier": "^15.0",
88824- "laravel/framework": "10.41.0",
88825- "laravel/sanctum": "3.3.3",
88826- "laravel/tinker": "2.9.0"
88827- },
88828- "require-dev": {
88829- "fakerphp/faker": "1.23.1",
88830- "laravel/dusk": "7.12.1",
88831- "laravel/pint": "1.13.11",
88832- "laravel/sail": "1.28.0",
88833- "mockery/mockery": "1.6.12",
88834- "nunomaduro/collision": "7.10.0",
88835- "phpunit/phpunit": "10.5.36",
88836- "spatie/laravel-ignition": "2.4.1",
88837- "squizlabs/php_codesniffer": "3.8.1"
88838- },
88839- "autoload": {
88840- "psr-4": {
88841- "App\\": "app/",
88842- "Database\\Factories\\": "database/factories/",
88843- "Database\\Seeders\\": "database/seeders/"
88844- }
88845- },
88846- "autoload-dev": {
88847- "psr-4": {
88848- "Tests\\": "tests/"
88849- }
88850- },
88851- "scripts": {
88852- "post-autoload-dump": [
88853- "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
88854- "@php artisan package:discover --ansi"
88855- ],
88856- "post-update-cmd": [
88857- "@php artisan vendor:publish --tag=laravel-assets --ansi --force"
88858- ],
88859- "post-root-package-install": [
88860- "@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
88861- ],
88862- "post-create-project-cmd": [
88863- "@php artisan key:generate --ansi"
88864- ]
88865- },
88866- "extra": {
88867- "laravel": {
88868- "dont-discover": []
88869- }
88870- },
88871- "config": {
88872- "optimize-autoloader": true,
88873- "preferred-install": "dist",
88874- "sort-packages": true
88875- },
88876- "minimum-stability": "dev",
88877- "prefer-stable": true
88878- }
88833+ ## File: Dockerfile
88834+ ``````dockerfile
88835+ # Stage 1: Compile Frontend Assets
88836+ FROM node:20-alpine AS node_builder
88837+
88838+ WORKDIR /app/frontend
88839+
88840+ # Copy package files and essential build configuration
88841+ COPY package.json package-lock.json* webpack.mix.js tailwind.config.js postcss.config.js* .babelrc* ./
88842+ # Ensure postcss.config.js and .babelrc are optional by using * in case they don't exist
88843+
88844+ # Install all dependencies (including devDependencies like laravel-mix)
88845+ RUN npm ci
88846+
88847+ # Copy frontend source code (js, css, images, etc.)
88848+ COPY resources/js ./resources/js
88849+ COPY resources/css ./resources/css
88850+ COPY resources/img ./resources/img
88851+ # Add other relevant resource directories if needed
88852+
88853+ # Compile assets for production
88854+ RUN npm run production
88855+
88856+ # Stage 2: Setup PHP Application Environment using richarvey/nginx-php-fpm
88857+ FROM richarvey/nginx-php-fpm:3.1.6 AS app
88858+
88859+ # Set Laravel Environment Variables as per the article
88860+ ENV APP_ENV production
88861+ ENV APP_DEBUG false
88862+ ENV LOG_CHANNEL stderr
88863+ ENV APP_KEY ${APP_KEY}
88864+ ENV SKIP_COMPOSER 1
88865+ ENV WEBROOT /var/www/html/public
88866+ ENV PHP_ERRORS_STDERR 1 # Send PHP errors to stderr for Docker logging
88867+ ENV RUN_SCRIPTS 1 # Enable execution of scripts in /scripts directory
88868+ ENV REAL_IP_HEADER 1 # If behind a proxy, trust X-Forwarded-For
88869+ ENV COMPOSER_ALLOW_SUPERUSER 1 # Allow composer to run as root if needed by scripts
88870+
88871+ # Set working directory
88872+ WORKDIR /var/www/html
88873+
88874+ # Copy all application files
88875+ COPY . .
88876+
88877+ # Copy compiled assets from the node_builder stage
88878+ COPY --from=node_builder /app/frontend/public ./public
88879+
88880+ # Copy our Nginx site configuration to the standard location for richarvey images
88881+ COPY nginx-site.conf /etc/nginx/sites-available/default
88882+
88883+ # Copy our deploy script to the location where richarvey image expects to run scripts
88884+ # Ensure deploy.sh has necessary commands (composer install, migrations, cache)
88885+ RUN mkdir -p /scripts
88886+ COPY deploy.sh /scripts/00-laravel-deploy.sh
88887+ # Install dos2unix, convert line endings, and ensure the script is executable
88888+ RUN apk add --no-cache dos2unix && \
88889+ dos2unix /scripts/00-laravel-deploy.sh && \
88890+ chmod +x /scripts/00-laravel-deploy.sh
88891+
88892+ # The base image (richarvey/nginx-php-fpm) handles starting Nginx, PHP-FPM,
88893+ # and running scripts from /scripts. Its default CMD is /start.sh.
88894+ CMD ["/start.sh"]
8887988895``````
8888088896
8888188897## File: package.json
0 commit comments