diff --git a/shit-show/.dockerignore b/shit-show/.dockerignore new file mode 100644 index 0000000..d0f964c --- /dev/null +++ b/shit-show/.dockerignore @@ -0,0 +1,15 @@ +.env +**/.gitignore +.git/ +.idea/ +bootstrap/cache/* +database/*.sqlite +laradock/ +node_modules/ +storage/app/public/* +storage/framework/cache/data/* +storage/framework/sessions/* +storage/framework/testing/* +storage/framework/views/* +storage/logs/* +vendor/ diff --git a/shit-show/Dockerfile b/shit-show/Dockerfile new file mode 100644 index 0000000..2bfdf92 --- /dev/null +++ b/shit-show/Dockerfile @@ -0,0 +1,37 @@ +FROM php:8.0-apache + +WORKDIR /var/www/laravel + +RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer + +RUN apt-get update \ + && apt-get install -y \ + cron \ + icu-devtools \ + jq \ + libfreetype6-dev libicu-dev libjpeg62-turbo-dev libpng-dev libsasl2-dev libssl-dev libwebp-dev libxpm-dev libzip-dev \ + unzip \ + zlib1g-dev \ + && apt-get clean \ + && apt-get autoclean \ + && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* + +RUN cp /usr/local/etc/php/php.ini-production /usr/local/etc/php/php.ini \ + && yes '' | pecl install redis \ + && docker-php-ext-configure gd --with-freetype --with-jpeg --with-webp --with-xpm \ + && docker-php-ext-install gd intl pdo_mysql zip \ + && docker-php-ext-enable opcache redis + +COPY composer.json composer.lock ./ +RUN composer install --no-autoloader --no-scripts --no-dev + +COPY docker/ / +RUN a2enmod rewrite headers \ + && a2ensite laravel \ + && a2dissite 000-default \ + && chmod +x /usr/local/bin/docker-laravel-entrypoint + +COPY . /var/www/laravel +RUN composer install --optimize-autoloader --no-dev + +CMD ["docker-laravel-entrypoint"] diff --git a/shit-show/composer.json b/shit-show/composer.json index 691a25a..faba614 100644 --- a/shit-show/composer.json +++ b/shit-show/composer.json @@ -15,6 +15,7 @@ "require-dev": { "facade/ignition": "^2.5", "fakerphp/faker": "^1.9.1", + "laravel-fans/docker": "^0.3.3", "laravel/breeze": "^1.4", "laravel/sail": "^1.0.1", "mockery/mockery": "^1.4.2", diff --git a/shit-show/composer.lock b/shit-show/composer.lock index 4f0b31b..5c649bc 100644 --- a/shit-show/composer.lock +++ b/shit-show/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "d5eb247c97e4a9329a5afbacc0a5ec82", + "content-hash": "4c0937594ef93f2149288491e673d577", "packages": [ { "name": "asm89/stack-cors", @@ -5748,6 +5748,56 @@ }, "time": "2020-07-09T08:09:16+00:00" }, + { + "name": "laravel-fans/docker", + "version": "0.3.3", + "source": { + "type": "git", + "url": "https://github.com/laravel-fans/laravel-docker.git", + "reference": "200cfc4130845babee90fb09b9a03dc2e9742f43" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/laravel-fans/laravel-docker/zipball/200cfc4130845babee90fb09b9a03dc2e9742f43", + "reference": "200cfc4130845babee90fb09b9a03dc2e9742f43", + "shasum": "" + }, + "require": { + "laravel/framework": ">=v5.5.50" + }, + "require-dev": { + "orchestra/testbench": ">=v3.5.6" + }, + "type": "library", + "extra": { + "laravel": { + "providers": [ + "LaravelFans\\Docker\\DockerServiceProvider" + ] + } + }, + "autoload": { + "psr-4": { + "LaravelFans\\Docker\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "sinkcup", + "email": "sinkcup@gmail.com" + } + ], + "description": "Full Laravel production environment for Docker", + "support": { + "issues": "https://github.com/laravel-fans/laravel-docker/issues", + "source": "https://github.com/laravel-fans/laravel-docker/tree/0.3.3" + }, + "time": "2021-04-28T13:38:23+00:00" + }, { "name": "laravel/breeze", "version": "v1.4.1", diff --git a/shit-show/docker-compose.yml b/shit-show/docker-compose.yml new file mode 100644 index 0000000..24ef2f1 --- /dev/null +++ b/shit-show/docker-compose.yml @@ -0,0 +1,10 @@ +version: '3.3' +services: + laravel: + ports: + - '8000:80' + environment: + - APP_ENV=local + - DB_CONNECTION=sqlite + - 'APP_KEY=base64:L+3avOYCfuq8nnDpHs74+5Et3sx27TssucHQIyqfpDY=' + build: . diff --git a/shit-show/docker/etc/apache2/sites-available/laravel.conf b/shit-show/docker/etc/apache2/sites-available/laravel.conf new file mode 100644 index 0000000..f1cc794 --- /dev/null +++ b/shit-show/docker/etc/apache2/sites-available/laravel.conf @@ -0,0 +1,24 @@ + + ServerName laravel-demo.localhost + DocumentRoot /var/www/laravel/public + + ErrorLog /var/log/apache2/error.log + CustomLog /var/log/apache2/access.log combined + + RewriteEngine On + + # optional: redirect www to no-www + RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC] + RewriteRule ^(.*)$ https://%1$1 [L,R=permanent] + + # optional: redirect http to https + RewriteCond %{HTTP:X-Forwarded-Proto} =http + RewriteRule .* https://%{HTTP:Host}%{REQUEST_URI} [L,R=permanent] + + RewriteCond %{HTTP:Authorization} . + RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] + + RewriteCond "%{DOCUMENT_ROOT}%{REQUEST_FILENAME}" !-d + RewriteCond "%{DOCUMENT_ROOT}%{REQUEST_FILENAME}" !-f + RewriteRule "^" "/index.php" [L] + diff --git a/shit-show/docker/usr/local/bin/docker-laravel-entrypoint b/shit-show/docker/usr/local/bin/docker-laravel-entrypoint new file mode 100644 index 0000000..c22ec10 --- /dev/null +++ b/shit-show/docker/usr/local/bin/docker-laravel-entrypoint @@ -0,0 +1,43 @@ +#!/usr/bin/env bash + +set -e + +role=${CONTAINER_ROLE:-app} +env=${APP_ENV:-production} + +cd /var/www/laravel + +chown www-data:www-data bootstrap/cache +chown -R www-data:www-data storage/ + +if [[ "$DB_CONNECTION" = "sqlite" ]]; then + touch database/database.sqlite + chown -R www-data:www-data database/ +fi +php artisan migrate --force + +if [[ "$env" != "local" ]]; then + echo "Caching configuration..." + php artisan config:cache + php artisan route:cache +fi + +if [[ "$role" = "app" ]]; then + + exec apache2-foreground + +elif [[ "$role" = "scheduler" ]]; then + + echo "start cron" + crontab /var/spool/cron/crontabs/root + cron -f + +elif [[ "$role" = "queue" ]]; then + + echo "Running the queue..." + php artisan queue:work --queue={default} --verbose --tries=3 --timeout=90 + +else + echo "Could not match the container role: $role" + exit 1 +fi diff --git a/shit-show/docker/var/spool/cron/crontabs/root b/shit-show/docker/var/spool/cron/crontabs/root new file mode 100644 index 0000000..d81b5c0 --- /dev/null +++ b/shit-show/docker/var/spool/cron/crontabs/root @@ -0,0 +1 @@ +* * * * * /usr/local/bin/php /var/www/laravel/artisan schedule:run