Skip to content

Commit c4bc0cc

Browse files
committed
Add Docker and NGINX configuration
1 parent 27a895d commit c4bc0cc

File tree

4 files changed

+105
-0
lines changed

4 files changed

+105
-0
lines changed

.dockerignore

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/node_modules
2+
/public/hot
3+
/public/storage
4+
/storage/*.key
5+
/vendor
6+
.env
7+
.phpunit.result.cache
8+
Homestead.json
9+
Homestead.yaml
10+
npm-debug.log
11+
yarn-error.log

Dockerfile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
FROM richarvey/nginx-php-fpm:1.7.2
2+
3+
COPY . .
4+
5+
# Image config
6+
ENV SKIP_COMPOSER 1
7+
ENV WEBROOT /var/www/html/public
8+
ENV PHP_ERRORS_STDERR 1
9+
ENV RUN_SCRIPTS 1
10+
ENV REAL_IP_HEADER 1
11+
12+
# Laravel config
13+
ENV APP_ENV production
14+
ENV APP_DEBUG false
15+
ENV LOG_CHANNEL stderr
16+
17+
# Allow composer to run as root
18+
ENV COMPOSER_ALLOW_SUPERUSER 1
19+
20+
CMD ["/start.sh"]

conf/nginx/nginx-site.conf

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
server {
2+
# Render provisions and terminates SSL
3+
listen 80;
4+
5+
# Make site accessible from http://localhost/
6+
server_name _;
7+
8+
root /var/www/html/public;
9+
index index.html index.htm index.php;
10+
11+
# Disable sendfile as per https://docs.vagrantup.com/v2/synced-folders/virtualbox.html
12+
sendfile off;
13+
14+
# Add stdout logging
15+
error_log /dev/stdout info;
16+
access_log /dev/stdout;
17+
18+
# block access to sensitive information about git
19+
location /.git {
20+
deny all;
21+
return 403;
22+
}
23+
24+
add_header X-Frame-Options "SAMEORIGIN";
25+
add_header X-XSS-Protection "1; mode=block";
26+
add_header X-Content-Type-Options "nosniff";
27+
28+
charset utf-8;
29+
30+
location / {
31+
try_files $uri $uri/ /index.php?$query_string;
32+
}
33+
34+
location = /favicon.ico { access_log off; log_not_found off; }
35+
location = /robots.txt { access_log off; log_not_found off; }
36+
37+
error_page 404 /index.php;
38+
39+
location ~* \.(jpg|jpeg|gif|png|css|js|ico|webp|tiff|ttf|svg)$ {
40+
expires 5d;
41+
}
42+
43+
location ~ \.php$ {
44+
fastcgi_split_path_info ^(.+\.php)(/.+)$;
45+
fastcgi_pass unix:/var/run/php-fpm.sock;
46+
fastcgi_index index.php;
47+
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
48+
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
49+
include fastcgi_params;
50+
}
51+
52+
# deny access to . files
53+
location ~ /\. {
54+
log_not_found off;
55+
deny all;
56+
}
57+
58+
location ~ /\.(?!well-known).* {
59+
deny all;
60+
}
61+
}

scripts/00-laravel-deploy.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/usr/bin/env bash
2+
echo "Running composer"
3+
composer global require hirak/prestissimo
4+
composer install --no-dev --working-dir=/var/www/html
5+
6+
echo "Caching config..."
7+
php artisan config:cache
8+
9+
echo "Caching routes..."
10+
php artisan route:cache
11+
12+
echo "Running migrations..."
13+
php artisan migrate --force

0 commit comments

Comments
 (0)