From db6bbf1ffacf6bb3c663849765db80c89f7e9b9c Mon Sep 17 00:00:00 2001 From: Felix Date: Sat, 15 Feb 2020 17:36:06 +0100 Subject: [PATCH] Optimize Docker build and loading performance --- ansible/templates/nginx.conf | 4 ++++ docker/Dockerfile | 12 +++++++++++- docker/nginx.conf | 8 +++----- src/views/Home.vue | 2 +- 4 files changed, 19 insertions(+), 7 deletions(-) diff --git a/ansible/templates/nginx.conf b/ansible/templates/nginx.conf index f58f042..62df112 100644 --- a/ansible/templates/nginx.conf +++ b/ansible/templates/nginx.conf @@ -29,6 +29,10 @@ server { # Hide nginx version server_tokens off; + gzip on; + gzip_types text/css application/javascript application/json text/vtt text/html image/svg+xml; + gzip_vary on; + # Only connect to this site via HTTPS add_header Strict-Transport-Security "max-age=63072000"; diff --git a/docker/Dockerfile b/docker/Dockerfile index 3783045..7f34119 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -3,20 +3,30 @@ FROM node:13-alpine as build-stage WORKDIR /app COPY package.json . +COPY yarn.lock . + +RUN apk add python2 make g++ + RUN yarn install --pure-lockfile \ && yarn cache clean COPY src/ src/ COPY public/ public/ -COPY yarn.lock . COPY .eslintrc.js . +COPY vue.config.js . + +COPY Makefile . +COPY .babelrc . # TODO: the build works fine with only the above files, does that mean we can delete everything else? +#COPY babel.config.js . #COPY vue.config.js . #COPY postcss.config.js . #COPY .eslintrc . +ENV NODE_ENV=production + RUN yarn run build FROM nginx as production-stage diff --git a/docker/nginx.conf b/docker/nginx.conf index 9707049..9103f87 100644 --- a/docker/nginx.conf +++ b/docker/nginx.conf @@ -21,17 +21,15 @@ http { # Hide nginx version server_tokens off; - # TODO: this is not really working - gzip on; - gzip_types text/css application/javascript application/json text/vtt text/html image/svg+xml; - gzip_vary on; - # TODO: maybe setup cache as well location / { root /app; index index.html; try_files $uri $uri/ /index.html; + expires 1d; + add_header Pragma public; + add_header Cache-Control "public"; } error_page 500 502 503 504 /50x.html; location = /50x.html { diff --git a/src/views/Home.vue b/src/views/Home.vue index e995eaa..c87b77f 100644 --- a/src/views/Home.vue +++ b/src/views/Home.vue @@ -305,7 +305,7 @@ const currentLanguage = this.$language.current.split('_')[0] const params = '?subtitle=' + currentLanguage - return 'https://framatube.org/videos/embed/9c9de5e8-0a1e-484a-b099-e80766180a6d' + params + return 'https://peertube.social/videos/embed/9c9de5e8-0a1e-484a-b099-e80766180a6d' + params } }, components: {