Add docker

This commit is contained in:
2021-09-10 23:01:33 +02:00
parent 617fe1c21b
commit 38780c8484
8 changed files with 182 additions and 1 deletions

15
shit-show/.dockerignore Normal file
View File

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

37
shit-show/Dockerfile Normal file
View File

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

View File

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

View File

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

View File

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

View File

@@ -0,0 +1,24 @@
<VirtualHost *:80>
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]
</VirtualHost>

View File

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

View File

@@ -0,0 +1 @@
* * * * * /usr/local/bin/php /var/www/laravel/artisan schedule:run