dockerize app

This commit is contained in:
Chimezie Enyinnaya
2024-09-09 21:18:20 +01:00
parent 886f5bcae9
commit 3716b52cb2
3 changed files with 88 additions and 2 deletions

57
.dockerignore Normal file
View File

@@ -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

29
Dockerfile Normal file
View File

@@ -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

View File

@@ -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.