From 3716b52cb20de454828c26f3c405c75118f7570f Mon Sep 17 00:00:00 2001 From: Chimezie Enyinnaya Date: Mon, 9 Sep 2024 21:18:20 +0100 Subject: [PATCH] dockerize app --- .dockerignore | 57 +++++++++++++++++++++++++++++++++++++++++++++ Dockerfile | 29 +++++++++++++++++++++++ app/Models/User.php | 4 ++-- 3 files changed, 88 insertions(+), 2 deletions(-) create mode 100644 .dockerignore create mode 100644 Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..5374029 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,57 @@ +# Ignore version control system directories +.git +.gitignore +.gitattributes + +# Ignore development and build files +node_modules +npm-debug.log +yarn-error.log +*.log +*.cache + +# Ignore environment files +.env +.env.* +!.env.example + +# Ignore editor and IDE files +.idea +.vscode +*.swp +*.swo +*.sublime-* + +# Ignore testing and documentation +tests +phpunit.xml +README.md +CHANGELOG.md +LICENSE + +# Ignore other unnecessary files +*.md +*.yml +*.yaml +.editorconfig +.styleci.yml +phpstan.neon +psalm.xml + +# Ignore backup files +*.bak +*.backup + +# Ignore Docker related files (except Dockerfile) +docker-compose*.yml +.dockerignore + +# Ignore Laravel specific files that are not needed in production +storage/framework/cache/* +storage/framework/sessions/* +storage/framework/views/* +storage/logs/* +bootstrap/cache/* + +# Keep .gitkeep files to preserve directory structure +!.gitkeep diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..50711e1 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,29 @@ +FROM serversideup/php:8.3-fpm-nginx + +ENV PHP_OPCACHE_ENABLE=1 + +USER root + +# Install Node.js +RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \ + && apt-get update \ + && apt-get install -y nodejs \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* + +# Copy application files +COPY --chown=www-data:www-data . /var/www/html + +# Switch to non-root user +USER www-data + +# Install dependencies and build +RUN npm ci \ + && npm run build \ + && rm -rf /var/www/html/.npm + +# Install PHP dependencies +RUN composer install --no-interaction --optimize-autoloader --no-dev + +# Remove composer cache +RUN rm -rf /var/www/html/.composer/cache diff --git a/app/Models/User.php b/app/Models/User.php index def621f..bb4d66c 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -2,14 +2,14 @@ namespace App\Models; -// use Illuminate\Contracts\Auth\MustVerifyEmail; +use Illuminate\Contracts\Auth\MustVerifyEmail; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Foundation\Auth\User as Authenticatable; use Illuminate\Notifications\Notifiable; class User extends Authenticatable { - use HasFactory, Notifiable; + use HasFactory, Notifiable, MustVerifyEmail; /** * The attributes that are mass assignable.