From a74b46ae318a67ebf41ef3bc3971347d7e9eb8b6 Mon Sep 17 00:00:00 2001 From: erishBRBS Date: Wed, 26 Mar 2025 22:43:00 +0800 Subject: [PATCH] Major Configuration --- .editorconfig | 0 .gitattributes | 0 .gitignore | 0 README.md | 0 app/Http/Controllers/Controller.php | 0 app/Models/User.php | 0 app/Providers/AppServiceProvider.php | 0 bootstrap/app.php | 0 bootstrap/providers.php | 0 composer.json | 0 composer.lock | 0 config/app.php | 0 config/auth.php | 0 config/cache.php | 0 config/database.php | 0 config/filesystems.php | 0 config/logging.php | 0 config/mail.php | 0 config/queue.php | 0 config/services.php | 0 config/session.php | 0 database/.gitignore | 0 database/factories/UserFactory.php | 0 .../0001_01_01_000000_create_users_table.php | 0 .../0001_01_01_000001_create_cache_table.php | 0 .../0001_01_01_000002_create_jobs_table.php | 0 database/seeders/DatabaseSeeder.php | 0 docker-compose.yml | 76 +++++++------------ docker/nginx/default.conf | 4 +- docker/php/Dockerfile | 15 ++-- docker/php/entrypoint.sh | 21 +++++ package.json | 0 phpunit.xml | 0 public/.htaccess | 0 public/favicon.ico | 0 public/index.php | 0 public/robots.txt | 0 resources/css/app.css | 0 resources/js/app.js | 0 resources/js/bootstrap.js | 0 resources/views/welcome.blade.php | 0 routes/console.php | 0 routes/web.php | 0 tests/Feature/ExampleTest.php | 0 tests/TestCase.php | 0 tests/Unit/ExampleTest.php | 0 vite.config.js | 0 47 files changed, 57 insertions(+), 59 deletions(-) mode change 100644 => 100755 .editorconfig mode change 100644 => 100755 .gitattributes mode change 100644 => 100755 .gitignore mode change 100644 => 100755 README.md mode change 100644 => 100755 app/Http/Controllers/Controller.php mode change 100644 => 100755 app/Models/User.php mode change 100644 => 100755 app/Providers/AppServiceProvider.php mode change 100644 => 100755 bootstrap/app.php mode change 100644 => 100755 bootstrap/providers.php mode change 100644 => 100755 composer.json mode change 100644 => 100755 composer.lock mode change 100644 => 100755 config/app.php mode change 100644 => 100755 config/auth.php mode change 100644 => 100755 config/cache.php mode change 100644 => 100755 config/database.php mode change 100644 => 100755 config/filesystems.php mode change 100644 => 100755 config/logging.php mode change 100644 => 100755 config/mail.php mode change 100644 => 100755 config/queue.php mode change 100644 => 100755 config/services.php mode change 100644 => 100755 config/session.php mode change 100644 => 100755 database/.gitignore mode change 100644 => 100755 database/factories/UserFactory.php mode change 100644 => 100755 database/migrations/0001_01_01_000000_create_users_table.php mode change 100644 => 100755 database/migrations/0001_01_01_000001_create_cache_table.php mode change 100644 => 100755 database/migrations/0001_01_01_000002_create_jobs_table.php mode change 100644 => 100755 database/seeders/DatabaseSeeder.php mode change 100644 => 100755 docker-compose.yml mode change 100644 => 100755 docker/nginx/default.conf mode change 100644 => 100755 docker/php/Dockerfile create mode 100755 docker/php/entrypoint.sh mode change 100644 => 100755 package.json mode change 100644 => 100755 phpunit.xml mode change 100644 => 100755 public/.htaccess mode change 100644 => 100755 public/favicon.ico mode change 100644 => 100755 public/index.php mode change 100644 => 100755 public/robots.txt mode change 100644 => 100755 resources/css/app.css mode change 100644 => 100755 resources/js/app.js mode change 100644 => 100755 resources/js/bootstrap.js mode change 100644 => 100755 resources/views/welcome.blade.php mode change 100644 => 100755 routes/console.php mode change 100644 => 100755 routes/web.php mode change 100644 => 100755 tests/Feature/ExampleTest.php mode change 100644 => 100755 tests/TestCase.php mode change 100644 => 100755 tests/Unit/ExampleTest.php mode change 100644 => 100755 vite.config.js diff --git a/.editorconfig b/.editorconfig old mode 100644 new mode 100755 diff --git a/.gitattributes b/.gitattributes old mode 100644 new mode 100755 diff --git a/.gitignore b/.gitignore old mode 100644 new mode 100755 diff --git a/README.md b/README.md old mode 100644 new mode 100755 diff --git a/app/Http/Controllers/Controller.php b/app/Http/Controllers/Controller.php old mode 100644 new mode 100755 diff --git a/app/Models/User.php b/app/Models/User.php old mode 100644 new mode 100755 diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php old mode 100644 new mode 100755 diff --git a/bootstrap/app.php b/bootstrap/app.php old mode 100644 new mode 100755 diff --git a/bootstrap/providers.php b/bootstrap/providers.php old mode 100644 new mode 100755 diff --git a/composer.json b/composer.json old mode 100644 new mode 100755 diff --git a/composer.lock b/composer.lock old mode 100644 new mode 100755 diff --git a/config/app.php b/config/app.php old mode 100644 new mode 100755 diff --git a/config/auth.php b/config/auth.php old mode 100644 new mode 100755 diff --git a/config/cache.php b/config/cache.php old mode 100644 new mode 100755 diff --git a/config/database.php b/config/database.php old mode 100644 new mode 100755 diff --git a/config/filesystems.php b/config/filesystems.php old mode 100644 new mode 100755 diff --git a/config/logging.php b/config/logging.php old mode 100644 new mode 100755 diff --git a/config/mail.php b/config/mail.php old mode 100644 new mode 100755 diff --git a/config/queue.php b/config/queue.php old mode 100644 new mode 100755 diff --git a/config/services.php b/config/services.php old mode 100644 new mode 100755 diff --git a/config/session.php b/config/session.php old mode 100644 new mode 100755 diff --git a/database/.gitignore b/database/.gitignore old mode 100644 new mode 100755 diff --git a/database/factories/UserFactory.php b/database/factories/UserFactory.php old mode 100644 new mode 100755 diff --git a/database/migrations/0001_01_01_000000_create_users_table.php b/database/migrations/0001_01_01_000000_create_users_table.php old mode 100644 new mode 100755 diff --git a/database/migrations/0001_01_01_000001_create_cache_table.php b/database/migrations/0001_01_01_000001_create_cache_table.php old mode 100644 new mode 100755 diff --git a/database/migrations/0001_01_01_000002_create_jobs_table.php b/database/migrations/0001_01_01_000002_create_jobs_table.php old mode 100644 new mode 100755 diff --git a/database/seeders/DatabaseSeeder.php b/database/seeders/DatabaseSeeder.php old mode 100644 new mode 100755 diff --git a/docker-compose.yml b/docker-compose.yml old mode 100644 new mode 100755 index d685f92..3d42b40 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,42 +1,37 @@ services: - # Laravel App app: build: - context: ./docker/php - dockerfile: Dockerfile - container_name: laravel-12-docker - restart: always - working_dir: /var/www + context: . + dockerfile: ./docker/php/Dockerfile + container_name: laravel-app + restart: unless-stopped volumes: - - .:/var/www + - .:/var/www/html + - ./storage:/var/www/html/storage + - ./bootstrap/cache:/var/www/html/bootstrap/cache depends_on: db_mysql: condition: service_healthy - command: > - sh -c " - while ! nc -z db_mysql 3306; do - sleep 2; - done; - php artisan migrate --force && php-fpm" + command: + [ "sh", "-c", "/var/www/html/docker/php/entrypoint.sh" ] healthcheck: - test: ["CMD", "sh", "-c", "pgrep php-fpm"] + test: ["CMD", "pgrep", "php-fpm"] interval: 30s timeout: 10s - retries: 10 + retries: 5 networks: - app_network - # MySQL + db_mysql: image: mysql:8.2 - container_name: mysql-db - restart: always + container_name: db_mysql + restart: unless-stopped environment: - MYSQL_ROOT_PASSWORD: ${DB_ROOT_PASSWORD} - MYSQL_DATABASE: ${DB_DATABASE} - MYSQL_PASSWORD: ${DB_PASSWORD} - ports: - - ${DB_PORT}:3306 + MYSQL_ROOT_PASSWORD: laravel + MYSQL_DATABASE: laravel-docker + MYSQL_USER: laravel + MYSQL_PASSWORD: laravel12 volumes: - mysql-data:/var/lib/mysql healthcheck: @@ -47,44 +42,25 @@ services: networks: - app_network - # Phpmyadmin - phpmyadmin: - image: phpmyadmin/phpmyadmin - container_name: phpmyadmin - restart: always + nginx: + image: nginx:alpine + container_name: nginx + restart: unless-stopped ports: - - "8080:80" - environment: - PMA_HOST: db_mysql - MYSQL_ROOT_PASSWORD: ${DB_ROOT_PASSWORD} - APACHE_SERVER_NAME: 0.0.0.0 - networks: - - app_network - - - # Nginx - web: - image: nginx:1.26.3-alpine - container_name: nginx-web - restart: always - ports: - - "8000:80" + - "80:80" volumes: - - .:/var/www + - .:/var/www/html - ./docker/nginx/default.conf:/etc/nginx/conf.d/default.conf:ro depends_on: app: condition: service_healthy - healthcheck: - test: ["CMD", "curl", "-f", "http://localhost"] - interval: 30s - timeout: 10s - retries: 5 networks: - app_network volumes: mysql-data: + storage-volume: + driver: local networks: app_network: diff --git a/docker/nginx/default.conf b/docker/nginx/default.conf old mode 100644 new mode 100755 index e7ae0c0..d2237bd --- a/docker/nginx/default.conf +++ b/docker/nginx/default.conf @@ -2,8 +2,7 @@ server { listen 80; server_name localhost; - root /var/www/public; - + root /var/www/html/public; index index.php index.html; location / { @@ -24,4 +23,3 @@ server { error_log /var/log/nginx/error.log; access_log /var/log/nginx/access.log; } - diff --git a/docker/php/Dockerfile b/docker/php/Dockerfile old mode 100644 new mode 100755 index f9ea09e..615b09f --- a/docker/php/Dockerfile +++ b/docker/php/Dockerfile @@ -8,16 +8,19 @@ RUN docker-php-ext-install pdo pdo_mysql bcmath COPY --from=composer:2.7 /usr/bin/composer /usr/bin/composer # Set working directory -WORKDIR /var/www +WORKDIR /var/www/html # Copy app files -COPY . /var/www +COPY . /var/www/html -# Set permissions -RUN chown -R www-data:www-data /var/www +# Ensure entrypoint script is +RUN chmod +x /var/www/html/docker/php/entrypoint.sh + +# Set permissions for app files +RUN chown -R www-data:www-data /var/www/html # Expose PHP-FPM port EXPOSE 9000 -# Start PHP-FPM -CMD ["php-fpm"] +# Start PHP-FPM (Handled in entrypoint.sh) +CMD ["sh", "-c", "/var/www/html/docker/php/entrypoint.sh"] diff --git a/docker/php/entrypoint.sh b/docker/php/entrypoint.sh new file mode 100755 index 0000000..5b8e77b --- /dev/null +++ b/docker/php/entrypoint.sh @@ -0,0 +1,21 @@ +#!/bin/sh + +# Exit script on any error +set -e + +# Ensure we are in the right directory +cd /var/www/html + +# Install dependencies +composer install --no-dev --optimize-autoloader + +# Set correct permissions for storage and cache +chown -R www-data:www-data storage bootstrap/cache +chmod -R 775 storage bootstrap/ + +# Run migrations +php artisan migrate --force + +# Start PHP-FPM +php-fpm + diff --git a/package.json b/package.json old mode 100644 new mode 100755 diff --git a/phpunit.xml b/phpunit.xml old mode 100644 new mode 100755 diff --git a/public/.htaccess b/public/.htaccess old mode 100644 new mode 100755 diff --git a/public/favicon.ico b/public/favicon.ico old mode 100644 new mode 100755 diff --git a/public/index.php b/public/index.php old mode 100644 new mode 100755 diff --git a/public/robots.txt b/public/robots.txt old mode 100644 new mode 100755 diff --git a/resources/css/app.css b/resources/css/app.css old mode 100644 new mode 100755 diff --git a/resources/js/app.js b/resources/js/app.js old mode 100644 new mode 100755 diff --git a/resources/js/bootstrap.js b/resources/js/bootstrap.js old mode 100644 new mode 100755 diff --git a/resources/views/welcome.blade.php b/resources/views/welcome.blade.php old mode 100644 new mode 100755 diff --git a/routes/console.php b/routes/console.php old mode 100644 new mode 100755 diff --git a/routes/web.php b/routes/web.php old mode 100644 new mode 100755 diff --git a/tests/Feature/ExampleTest.php b/tests/Feature/ExampleTest.php old mode 100644 new mode 100755 diff --git a/tests/TestCase.php b/tests/TestCase.php old mode 100644 new mode 100755 diff --git a/tests/Unit/ExampleTest.php b/tests/Unit/ExampleTest.php old mode 100644 new mode 100755 diff --git a/vite.config.js b/vite.config.js old mode 100644 new mode 100755