Skip to content

Commit 99f8b82

Browse files
committed
init commit
0 parents  commit 99f8b82

12 files changed

+511
-0
lines changed

Dockerfile

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
FROM php:7.1-fpm
2+
3+
# Update packages and install composer and PHP dependencies.
4+
RUN apt-get update && \
5+
DEBIAN_FRONTEND=noninteractive apt-get install -y \
6+
postgresql-client \
7+
libpq-dev \
8+
libfreetype6-dev \
9+
libjpeg62-turbo-dev \
10+
libmcrypt-dev \
11+
libpng12-dev \
12+
libbz2-dev \
13+
&& pecl channel-update pecl.php.net \
14+
&& pecl install apcu
15+
16+
# PHP Extensions
17+
RUN docker-php-ext-install mcrypt zip bz2 mbstring pdo pdo_pgsql pcntl \
18+
&& docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \
19+
&& docker-php-ext-install gd
20+
21+
# Memory Limit
22+
RUN echo "memory_limit=2048M" > $PHP_INI_DIR/conf.d/memory-limit.ini
23+
RUN echo "max_execution_time=900" >> $PHP_INI_DIR/conf.d/memory-limit.ini
24+
RUN echo "extension=apcu.so" > $PHP_INI_DIR/conf.d/apcu.ini
25+
RUN echo "post_max_size=20M" >> $PHP_INI_DIR/conf.d/memory-limit.ini
26+
RUN echo "upload_max_filesize=20M" >> $PHP_INI_DIR/conf.d/memory-limit.ini
27+
28+
# Time Zone
29+
RUN echo "date.timezone=${PHP_TIMEZONE:-UTC}" > $PHP_INI_DIR/conf.d/date_timezone.ini
30+
31+
# Display errors in stderr
32+
RUN echo "display_errors=stderr" > $PHP_INI_DIR/conf.d/display-errors.ini
33+
34+
# Disable PathInfo
35+
RUN echo "cgi.fix_pathinfo=0" > $PHP_INI_DIR/conf.d/path-info.ini
36+
37+
# Disable expose PHP
38+
RUN echo "expose_php=0" > $PHP_INI_DIR/conf.d/path-info.ini
39+
40+
# Install Composer
41+
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
42+
43+
ADD . /var/www/html
44+
WORKDIR /var/www/html
45+
46+
RUN mkdir storage/logs
47+
RUN touch storage/logs/laravel.log
48+
49+
RUN composer install
50+
RUN php artisan optimize --force
51+
RUN php artisan route:cache
52+
53+
RUN chmod -R 777 /var/www/html/storage
54+
55+
# CMD ["php-fpm"]
56+
57+
CMD ["/bin/sh", "-c", "php-fpm -D | tail -f storage/logs/laravel.log"],

Dockerfile-cron

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
FROM php:7.1-fpm
2+
3+
# Update packages and install composer and PHP dependencies.
4+
RUN apt-get update && \
5+
DEBIAN_FRONTEND=noninteractive apt-get install -y \
6+
postgresql-client \
7+
libpq-dev \
8+
libfreetype6-dev \
9+
libjpeg62-turbo-dev \
10+
libmcrypt-dev \
11+
libpng12-dev \
12+
libbz2-dev \
13+
php-pear \
14+
cron \
15+
&& pecl channel-update pecl.php.net \
16+
&& pecl install apcu
17+
18+
# PHP Extensions
19+
RUN docker-php-ext-install mcrypt zip bz2 mbstring pdo pdo_pgsql pcntl \
20+
&& docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \
21+
&& docker-php-ext-install gd
22+
23+
# Memory Limit
24+
RUN echo "memory_limit=1024M" > $PHP_INI_DIR/conf.d/memory-limit.ini
25+
RUN echo "max_execution_time=900" >> $PHP_INI_DIR/conf.d/memory-limit.ini
26+
RUN echo "extension=apcu.so" > $PHP_INI_DIR/conf.d/apcu.ini
27+
28+
# Time Zone
29+
RUN echo "date.timezone=${PHP_TIMEZONE:-UTC}" > $PHP_INI_DIR/conf.d/date_timezone.ini
30+
31+
# Display errors in stderr
32+
RUN echo "display_errors=stderr" > $PHP_INI_DIR/conf.d/display-errors.ini
33+
34+
# Disable PathInfo
35+
RUN echo "cgi.fix_pathinfo=0" > $PHP_INI_DIR/conf.d/path-info.ini
36+
37+
# Disable expose PHP
38+
RUN echo "expose_php=0" > $PHP_INI_DIR/conf.d/path-info.ini
39+
40+
# Install Composer
41+
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
42+
43+
ADD . /var/www/html
44+
WORKDIR /var/www/html
45+
46+
RUN mkdir storage/logs
47+
RUN touch storage/logs/laravel.log
48+
49+
RUN composer install
50+
51+
RUN chmod -R 777 /var/www/html/storage
52+
53+
RUN touch /var/log/cron.log
54+
55+
ADD deploy/cron/artisan-schedule-run /etc/cron.d/artisan-schedule-run
56+
RUN chmod 0644 /etc/cron.d/artisan-schedule-run
57+
RUN chmod +x /etc/cron.d/artisan-schedule-run
58+
RUN touch /var/log/cron.log
59+
# RUN crontab /etc/cron.d/artisan-schedule-run
60+
61+
CMD env /bin/bash -o posix -c 'export -p' > /etc/cron.d/project_env.sh && chmod +x /etc/cron.d/project_env.sh && crontab /etc/cron.d/artisan-schedule-run && cron && tail -f /var/log/cron.log

Dockerfile-nginx

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
FROM nginx
2+
3+
ADD deploy/nginx/nginx.conf /etc/nginx/
4+
ADD deploy/nginx/default.conf /etc/nginx/conf.d/
5+
6+
ADD public /usr/share/nginx/html
7+
8+
WORKDIR /usr/share/nginx/html

deploy/cron/artisan-schedule-run

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
* * * * * root . /etc/cron.d/project_env.sh ; /usr/local/bin/php /var/www/html/artisan schedule:run &> /var/log/cron.log
2+
# An empty line is required at the end of this file for a valid cron file.
3+

deploy/nginx/default.conf

+123
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
fastcgi_cache_path /dev/shm levels=1:2 keys_zone=laravel:100m;
2+
fastcgi_cache_key "$scheme$request_method$host$request_uri$query_string";
3+
4+
#server {
5+
# listen 80;
6+
# server_name laravel.info;
7+
# rewrite ^ https://$server_name$request_uri? permanent;
8+
#}
9+
10+
#server {
11+
# listen 443;
12+
# server_name www.laravel.info;
13+
14+
# ssl on;
15+
# ssl_certificate /etc/ssl/certs/ssl.cert;
16+
# ssl_certificate_key /etc/ssl/private/ssl.key;
17+
18+
# rewrite ^ https://laravel.info$request_uri? permanent;
19+
#}
20+
21+
server {
22+
listen 80 default_server;
23+
server_name laravel.info;
24+
25+
#ssl on;
26+
#ssl_certificate /etc/ssl/certs/ssl.cert;
27+
#ssl_certificate_key /etc/ssl/private/ssl.key;
28+
29+
root /usr/share/nginx/html/;
30+
index index.php index.html;
31+
32+
client_max_body_size 5M;
33+
34+
# Compression
35+
36+
# Enable Gzip compressed.
37+
gzip on;
38+
39+
# Enable compression both for HTTP/1.0 and HTTP/1.1.
40+
gzip_http_version 1.1;
41+
42+
# Compression level (1-9).
43+
# 5 is a perfect compromise between size and cpu usage, offering about
44+
# 75% reduction for most ascii files (almost identical to level 9).
45+
gzip_comp_level 5;
46+
47+
# Don't compress anything that's already small and unlikely to shrink much
48+
# if at all (the default is 20 bytes, which is bad as that usually leads to
49+
# larger files after gzipping).
50+
gzip_min_length 256;
51+
52+
# Compress data even for clients that are connecting to us via proxies,
53+
# identified by the "Via" header (required for CloudFront).
54+
gzip_proxied any;
55+
56+
# Tell proxies to cache both the gzipped and regular version of a resource
57+
# whenever the client's Accept-Encoding capabilities header varies;
58+
# Avoids the issue where a non-gzip capable client (which is extremely rare
59+
# today) would display gibberish if their proxy gave them the gzipped version.
60+
gzip_vary on;
61+
62+
# Compress all output labeled with one of the following MIME-types.
63+
gzip_types
64+
application/atom+xml
65+
application/javascript
66+
application/json
67+
application/rss+xml
68+
application/vnd.ms-fontobject
69+
application/x-font-ttf
70+
application/x-web-app-manifest+json
71+
application/xhtml+xml
72+
application/xml
73+
font/opentype
74+
image/svg+xml
75+
image/x-icon
76+
text/css
77+
text/plain
78+
text/x-component;
79+
# text/html is always compressed by HttpGzipModule
80+
81+
# location /api {
82+
# auth_basic off;
83+
# try_files $uri $uri/ /index.php?$query_string;
84+
# }
85+
86+
location / {
87+
# auth_basic "Restricted access";
88+
# auth_basic_user_file /etc/nginx/.htpasswd;
89+
try_files $uri $uri/ /index.php?$query_string;
90+
}
91+
92+
location ~ \.php$ {
93+
root /var/www/html/public;
94+
fastcgi_cache laravel;
95+
fastcgi_cache_valid 200 204 1m;
96+
fastcgi_ignore_headers Cache-Control;
97+
fastcgi_no_cache $http_authorization $cookie_laravel_session;
98+
fastcgi_cache_lock on;
99+
fastcgi_cache_lock_timeout 10s;
100+
101+
add_header X-Proxy-Cache $upstream_cache_status;
102+
103+
fastcgi_pass app:9000;
104+
fastcgi_index index.php;
105+
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
106+
fastcgi_read_timeout 900s;
107+
include fastcgi_params;
108+
}
109+
110+
location ~* \.(jpg|jpeg|png|gif|ico|css|js|eot|ttf|woff|woff2)$ {
111+
# auth_basic off;
112+
expires max;
113+
add_header Cache-Control public;
114+
add_header Access-Control-Allow-Origin *;
115+
access_log off;
116+
try_files $uri $uri/ /index.php?$query_string;
117+
}
118+
119+
location ~ /\.ht {
120+
deny all;
121+
}
122+
}
123+

deploy/nginx/index.php

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<?php
2+
3+
/**
4+
* Laravel - A PHP Framework For Web Artisans
5+
*
6+
* @package Laravel
7+
* @author Taylor Otwell <taylor@laravel.com>
8+
*/
9+
10+
/*
11+
|--------------------------------------------------------------------------
12+
| Register The Auto Loader
13+
|--------------------------------------------------------------------------
14+
|
15+
| Composer provides a convenient, automatically generated class loader for
16+
| our application. We just need to utilize it! We'll simply require it
17+
| into the script here so that we don't have to worry about manual
18+
| loading any of our classes later on. It feels nice to relax.
19+
|
20+
*/
21+
22+
require __DIR__.'/../bootstrap/autoload.php';
23+
24+
/*
25+
|--------------------------------------------------------------------------
26+
| Turn On The Lights
27+
|--------------------------------------------------------------------------
28+
|
29+
| We need to illuminate PHP development, so let us turn on the lights.
30+
| This bootstraps the framework and gets it ready for use, then it
31+
| will load up this application so that we can run it and send
32+
| the responses back to the browser and delight our users.
33+
|
34+
*/
35+
36+
$app = require_once __DIR__.'/../bootstrap/app.php';
37+
38+
/*
39+
|--------------------------------------------------------------------------
40+
| Run The Application
41+
|--------------------------------------------------------------------------
42+
|
43+
| Once we have the application, we can handle the incoming request
44+
| through the kernel, and send the associated response back to
45+
| the client's browser allowing them to enjoy the creative
46+
| and wonderful application we have prepared for them.
47+
|
48+
*/
49+
50+
$kernel = $app->make(Illuminate\Contracts\Http\Kernel::class);
51+
52+
$response = $kernel->handle(
53+
$request = Illuminate\Http\Request::capture()
54+
);
55+
56+
$response->send();
57+
58+
$kernel->terminate($request, $response);

deploy/nginx/nginx.conf

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
user nginx;
2+
worker_processes 1;
3+
4+
error_log /var/log/nginx/error.log warn;
5+
pid /var/run/nginx.pid;
6+
7+
8+
events {
9+
worker_connections 1024;
10+
}
11+
12+
13+
http {
14+
include /etc/nginx/mime.types;
15+
default_type application/octet-stream;
16+
17+
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
18+
'$status $body_bytes_sent "$http_referer" '
19+
'"$http_user_agent" "$http_x_forwarded_for"';
20+
21+
access_log /var/log/nginx/access.log main;
22+
23+
24+
sendfile on;
25+
#tcp_nopush on;
26+
27+
keepalive_timeout 65;
28+
29+
#gzip on;
30+
31+
server_tokens off;
32+
33+
include /etc/nginx/conf.d/*.conf;
34+
}

deploy/nginx/robots.txt

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
User-agent: *
2+
Disallow: /

deploy/php-fpm/configs/php-fpm.conf

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
[global]
2+
daemonize = no
3+
pid = /usr/local/etc/php7.1-fpm.pid
4+
5+
; Log level
6+
; Possible Values: alert, error, warning, notice, debug
7+
; Default Value: notice
8+
log_level = notice
9+
10+
; Error log file
11+
; If it's set to "syslog", log is sent to syslogd instead of being written
12+
; in a local file.
13+
; Note: the default prefix is /var
14+
; Default Value: log/php-fpm.log
15+
error_log = /proc/self/fd/2
16+
17+
include=/usr/local/etc/php-fpm.d/*.conf
18+

deploy/php-fpm/configs/php.ini

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
cgi.fix_pathinfo = 0;
2+
; Default Value: E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED
3+
; Development Value: E_ALL
4+
; Production Value: E_ALL & ~E_DEPRECATED & ~E_STRICT
5+
error_reporting = E_ALL
6+
7+
; Default Value: On
8+
; Development Value: On
9+
; Production Value: Off
10+
display_errors = On
11+
12+
variables_order = "EGPCS"
13+
default_charset = "UTF-8"
14+
15+
post_max_size = 25M
16+
upload_max_filesize = 20M

0 commit comments

Comments
 (0)