Skip to content
This repository was archived by the owner on Apr 1, 2021. It is now read-only.

Commit d73fdc2

Browse files
committed
improve dockerfile for https in production
1 parent dc29e8a commit d73fdc2

File tree

7 files changed

+70
-30
lines changed

7 files changed

+70
-30
lines changed

Dockerfile

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,27 @@ COPY composer.json composer.json
3535
COPY composer.lock composer.lock
3636
RUN composer config -g repos.packagist composer https://packagist.jp
3737
RUN composer global require hirak/prestissimo
38-
RUN composer install --prefer-dist --no-scripts --no-dev --no-autoloader && rm -rf /root/.composer
38+
RUN composer install \
39+
--prefer-dist \
40+
--no-ansi \
41+
--no-dev \
42+
--no-interaction \
43+
--no-progress \
44+
--no-scripts \
45+
--no-autoloader \
46+
&& rm -rf /root/.composer
3947

4048
COPY deploy/web/site.conf /etc/nginx/sites-available/default
4149
COPY deploy/web/nginx.conf /etc/nginx/nginx.conf
4250
COPY deploy/web/mime.types /etc/nginx/mime.types
43-
COPY deploy/web/php.ini /usr/local/etc/php/
51+
COPY deploy/web/php.ini /usr/local/etc/php/php.ini
4452
COPY --from=compiler /var/www /var/www
4553

46-
RUN composer dump-autoload --no-scripts --no-dev --optimize
54+
RUN composer dump-autoload --no-dev --optimize
4755
RUN chown -R www-data:www-data /var/www
56+
RUN php artisan config:cache \
57+
&& php artisan route:cache \
58+
&& php artisan view:cache
4859
RUN rm -rf /var/www/html/ /var/www/deploy/
4960

5061
EXPOSE 80 443
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
3+
namespace App\Http\Controllers;
4+
5+
use Illuminate\Http\Request;
6+
7+
class AppController extends Controller
8+
{
9+
public function index (Request $request) {
10+
return view('app');
11+
}
12+
}

deploy/web/site.conf

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,36 @@ server {
77
root $root_path;
88
index index.php;
99

10+
add_header X-Frame-Options "SAMEORIGIN";
11+
add_header X-XSS-Protection "1; mode=block";
12+
add_header X-Content-Type-Options "nosniff";
13+
14+
charset utf-8;
15+
1016
location / {
11-
try_files $uri $uri/ /index.php?$args;
17+
try_files $uri $uri/ /index.php?$query_string;
1218
}
1319

14-
client_max_body_size 100m;
20+
client_max_body_size 100M;
21+
22+
location = /favicon.ico { access_log off; log_not_found off; }
23+
location = /robots.txt { access_log off; log_not_found off; }
24+
25+
error_page 404 /index.php;
1526

1627
location ~ \.php {
1728
include fastcgi_params;
1829

1930
fastcgi_index /index.php;
2031
fastcgi_pass 127.0.0.1:9000;
2132
fastcgi_split_path_info ^(.+\.php)(/.+)$;
22-
fastcgi_param PATH_INFO $fastcgi_path_info;
2333
fastcgi_intercept_errors on;
34+
fastcgi_param HTTPS on;
35+
fastcgi_param PATH_INFO $fastcgi_path_info;
2436
fastcgi_param SCRIPT_FILENAME $root_path$fastcgi_script_name;
2537
}
2638

27-
location ~ /\.git {
28-
deny all;
39+
location ~ /\.(?!well-known).* {
40+
deny all;
2941
}
3042
}

resources/views/app.blade.php

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -29,28 +29,34 @@
2929
<div class="app flex-row align-items-center">
3030
<div class="container">
3131
<div class="row justify-content-center">
32-
<div class="col-md-6">
33-
<div class="clearfix">
34-
<h1 class="float-left display-3 mr-4">
35-
<i class="fa fa-warning"></i>
36-
</h1>
37-
<h4 class="pt-3">Javascript Required</h4>
38-
<p class="text-muted">
39-
Please enabling Javascript or try with other browser which have Javascript Support.<br>
40-
<a class="btn btn-primary mt-3" href="{{ url()->current() }}">
41-
Reload Page
42-
</a>
43-
</p>
44-
</div>
32+
<div class="col-md-6 p-3">
33+
<h1 class="text-center text-md-left">
34+
<i class="fa fa-warning fa-2x"></i>
35+
</h1>
36+
<h4 class="pt-3">Browser not Support</h4>
37+
<p class="text-muted">
38+
Try other browser which have Javascript Support. Recommendation is
39+
<a href="https://www.google.com/chrome/?brand=CHBD&gclid=CjwKCAjw6-_eBRBXEiwA-5zHaa78eJ_HfOScWr1D4PzHFZY2k2zRHc9pcHZ9gvAaHbljCsSC1gv0jBoCKIUQAvD_BwE&gclsrc=aw.ds">
40+
Google Chrome
41+
</a>
42+
or
43+
<a href="https://www.mozilla.org/en-US/">
44+
Mozilla Firefox
45+
</a>
46+
<br>
47+
<a class="btn btn-primary mt-3" href="{{ url()->current() }}">
48+
Reload Page
49+
</a>
50+
</p>
4551
</div>
4652
</div>
4753
</div>
4854
</div>
4955
</noscript>
5056
</div>
51-
<script src="{{ asset(mix('js/manifest.js')) }}"></script>
52-
<script src="{{ asset(mix('js/vendor.js')) }}"></script>
53-
<script src="{{ asset(mix('js/app.js')) }}"></script>
57+
<script defer src="{{ asset(mix('js/manifest.js')) }}"></script>
58+
<script defer src="{{ asset(mix('js/vendor.js')) }}"></script>
59+
<script defer src="{{ asset(mix('js/app.js')) }}"></script>
5460
</body>
5561

5662
</html>

routes/api.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@
1313
|
1414
*/
1515

16-
Route::middleware('auth:api')->get('/user', function (Request $request) {
17-
return $request->user();
18-
});
16+
// Route::middleware('auth:api')->get('/user', function (Request $request) {
17+
// return $request->user();
18+
// });

routes/web.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,4 @@
1111
|
1212
*/
1313

14-
Route::get('/{vue_capture?}', function () {
15-
return view('app');
16-
})->where('vue_capture', '[\/\w\.\,\-]*');
14+
Route::get('/{vue_capture?}', 'AppController@index')->where('vue_capture', '[\/\w\.\,\-]*');

webpack.mix.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ mix.options({
8787
host: '0.0.0.0',
8888
port: 8080,
8989
},
90+
uglify: { parallel: true },
9091
})
9192

9293
if (mix.inProduction())

0 commit comments

Comments
 (0)