some docker adjustments, fix brotli comprpession

This commit is contained in:
Willyb321
2018-12-23 07:51:42 +11:00
parent 001fed67b7
commit 03020743b3
5 changed files with 94 additions and 194 deletions

View File

@@ -1,96 +0,0 @@
worker_processes 1;
user nobody nobody;
error_log /tmp/error.log;
pid /tmp/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
sendfile on;
client_body_temp_path /tmp/client_body;
fastcgi_temp_path /tmp/fastcgi_temp;
proxy_temp_path /tmp/proxy_temp;
scgi_temp_path /tmp/scgi_temp;
uwsgi_temp_path /tmp/uwsgi_temp;
access_log /tmp/access.log;
error_log /tmp/error.log;
# https://nginx.org/en/docs/http/ngx_http_gzip_module.html
# Enable gzip compression.
# Default: off
gzip on;
# Compression level (1-9).
# 5 is a perfect compromise between size and CPU usage, offering about
# 75% reduction for most ASCII files (almost identical to level 9).
# Default: 1
gzip_comp_level 5;
# Don't compress anything that's already small and unlikely to shrink much
# if at all (the default is 20 bytes, which is bad as that usually leads to
# larger files after gzipping).
# Default: 20
gzip_min_length 256;
# Compress data even for clients that are connecting to us via proxies,
# identified by the "Via" header (required for CloudFront).
# Default: off
gzip_proxied any;
# Tell proxies to cache both the gzipped and regular version of a resource
# whenever the client's Accept-Encoding capabilities header varies;
# Avoids the issue where a non-gzip capable client (which is extremely rare
# today) would display gibberish if their proxy gave them the gzipped version.
# Default: off
gzip_vary on;
# Compress all output labeled with one of the following MIME-types.
# text/html is always compressed by gzip module.
# Default: text/html
gzip_types *;
brotli on;
# brotli_static on;
brotli_types *;
# This should be turned on if you are going to have pre-compressed copies (.gz) of
# static files available. If not it should be left off as it will cause extra I/O
# for the check. It is best if you enable this in a location{} block for
# a specific directory, or on an individual server{} level.
# gzip_static on;
keepalive_timeout 3000;
server {
listen 80;
listen [::]:80;
index index.html;
server_name localhost;
root /usr/share/nginx/html;
autoindex on;
location ~* \.(?:manifest|appcache|html?|xml|json|css|js|map|jpg|jpeg|gif|png|ico|svg|eot|ttf|woff|woff2)$ {
add_header Access-Control-Allow-Origin *;
add_header Access-Control-Allow-Credentials true;
add_header Access-Control-Allow-Methods 'GET, POST, OPTIONS';
add_header Access-Control-Allow-Headers 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
access_log off;
}
location /service-worker.js {
expires -1;
add_header Access-Control-Allow-Origin *;
add_header Access-Control-Allow-Credentials true;
add_header Access-Control-Allow-Methods 'GET, POST, OPTIONS';
add_header Access-Control-Allow-Headers 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
access_log off;
}
location / {
try_files $uri $uri/ /index.html =404;
}
location /iframe.html {
try_files $uri $uri/ /iframe.html =404;
}
}
}

View File

@@ -6,29 +6,28 @@ WORKDIR /src/app
RUN mkdir -p /src/app/coriolis RUN mkdir -p /src/app/coriolis
RUN mkdir -p /src/app/coriolis-data RUN mkdir -p /src/app/coriolis-data
COPY ./coriolis/ /src/app/coriolis RUN apk add --update git
COPY ./coriolis-data/ /src/app/coriolis-data
RUN apk update COPY . /src/app/coriolis
RUN apk add git
RUN npm i -g npm RUN npm i -g npm
# Set up coriolis-data # Set up coriolis-data
WORKDIR /src/app/coriolis-data WORKDIR /src/app/coriolis-data
RUN git fetch --all RUN git clone https://github.com/EDCD/coriolis-data.git .
RUN git checkout ${BRANCH}
RUN npm install --no-package-lock RUN npm install --no-package-lock
RUN npm start RUN npm start
# Set up coriolis
WORKDIR /src/app/coriolis WORKDIR /src/app/coriolis
RUN git fetch --all
RUN npm install --no-package-lock RUN npm install --no-package-lock
RUN npm run build RUN npm run build
### STAGE 2: Production Environment ### ### STAGE 2: Production Environment ###
FROM fholzer/nginx-brotli as web FROM fholzer/nginx-brotli as web
COPY coriolis/.docker/nginx.conf /etc/nginx/nginx.conf COPY nginx.conf /etc/nginx/nginx.conf
COPY --from=builder /src/app/coriolis/build /usr/share/nginx/html COPY --from=builder /src/app/coriolis/build /usr/share/nginx/html
WORKDIR /usr/share/nginx/html WORKDIR /usr/share/nginx/html
EXPOSE 80 EXPOSE 80

View File

@@ -1,99 +1,96 @@
worker_processes 2; worker_processes 1;
error_log ./nginx.error.log; user nobody nobody;
worker_rlimit_nofile 8192; error_log /tmp/error.log;
pid nginx.pid; pid /tmp/nginx.pid;
events { events {
worker_connections 1024;
multi_accept on; worker_connections 1024;
} }
http { http {
access_log off; include /etc/nginx/mime.types;
charset UTF-8; default_type application/octet-stream;
sendfile on;
client_body_temp_path /tmp/client_body;
fastcgi_temp_path /tmp/fastcgi_temp;
proxy_temp_path /tmp/proxy_temp;
scgi_temp_path /tmp/scgi_temp;
uwsgi_temp_path /tmp/uwsgi_temp;
access_log /tmp/access.log;
error_log /tmp/error.log;
types { # https://nginx.org/en/docs/http/ngx_http_gzip_module.html
text/html html htm shtml; # Enable gzip compression.
text/css css; # Default: off
text/xml xml rss; gzip off;
image/gif gif;
image/jpeg jpeg jpg;
application/x-javascript js;
text/plain txt;
image/png png;
image/svg+xml svg;
image/x-icon ico;
application/pdf pdf;
text/cache-manifest appcache;
}
# ---------------------------------------------------------------------- # Compression level (1-9).
# | Compression | # 5 is a perfect compromise between size and CPU usage, offering about
# ---------------------------------------------------------------------- # 75% reduction for most ASCII files (almost identical to level 9).
# Default: 1
gzip_comp_level 5;
# https://nginx.org/en/docs/http/ngx_http_gzip_module.html # Don't compress anything that's already small and unlikely to shrink much
brotli on; # if at all (the default is 20 bytes, which is bad as that usually leads to
# brotli_static on; # larger files after gzipping).
brotli_types *; # Default: 20
# Enable gzip compression. gzip_min_length 256;
# Default: off
gzip on;
# Compression level (1-9). # Compress data even for clients that are connecting to us via proxies,
# 5 is a perfect compromise between size and CPU usage, offering about # identified by the "Via" header (required for CloudFront).
# 75% reduction for most ASCII files (almost identical to level 9). # Default: off
# Default: 1 gzip_proxied any;
gzip_comp_level 5;
# Don't compress anything that's already small and unlikely to shrink much # Tell proxies to cache both the gzipped and regular version of a resource
# if at all (the default is 20 bytes, which is bad as that usually leads to # whenever the client's Accept-Encoding capabilities header varies;
# larger files after gzipping). # Avoids the issue where a non-gzip capable client (which is extremely rare
# Default: 20 # today) would display gibberish if their proxy gave them the gzipped version.
gzip_min_length 256; # Default: off
gzip_vary on;
# Compress data even for clients that are connecting to us via proxies, # Compress all output labeled with one of the following MIME-types.
# identified by the "Via" header (required for CloudFront). # text/html is always compressed by gzip module.
# Default: off # Default: text/html
gzip_proxied any; gzip_types *;
brotli on;
# brotli_static on;
brotli_types *;
# This should be turned on if you are going to have pre-compressed copies (.gz) of
# static files available. If not it should be left off as it will cause extra I/O
# for the check. It is best if you enable this in a location{} block for
# a specific directory, or on an individual server{} level.
# gzip_static on;
keepalive_timeout 3000;
server {
listen 80;
listen [::]:80;
index index.html;
server_name localhost;
root /usr/share/nginx/html;
autoindex on;
# Tell proxies to cache both the gzipped and regular version of a resource location ~* \.(?:manifest|appcache|html?|xml|json|css|js|map|jpg|jpeg|gif|png|ico|svg|eot|ttf|woff|woff2)$ {
# whenever the client's Accept-Encoding capabilities header varies; add_header Access-Control-Allow-Origin *;
# Avoids the issue where a non-gzip capable client (which is extremely rare add_header Access-Control-Allow-Credentials true;
# today) would display gibberish if their proxy gave them the gzipped version. add_header Access-Control-Allow-Methods 'GET, POST, OPTIONS';
# Default: off add_header Access-Control-Allow-Headers 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
gzip_vary on; access_log off;
}
# Compress all output labeled with one of the following MIME-types. location /service-worker.js {
# text/html is always compressed by gzip module. expires -1;
# Default: text/html add_header Access-Control-Allow-Origin *;
gzip_types *;
# This should be turned on if you are going to have pre-compressed copies (.gz) of
# static files available. If not it should be left off as it will cause extra I/O
# for the check. It is best if you enable this in a location{} block for
# a specific directory, or on an individual server{} level.
# gzip_static on;
server {
listen 3301;
server_name localhost;
root ./build/;
index index.html;
location ~* \.(?:manifest|appcache|html?|xml|json|css|js|map|jpg|jpeg|gif|png|ico|svg|eot|ttf|woff|woff2)$ {
add_header Access-Control-Allow-Origin *;
add_header Access-Control-Allow-Credentials true; add_header Access-Control-Allow-Credentials true;
add_header Access-Control-Allow-Methods 'GET, POST, OPTIONS'; add_header Access-Control-Allow-Methods 'GET, POST, OPTIONS';
add_header Access-Control-Allow-Headers 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type'; add_header Access-Control-Allow-Headers 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
access_log off; access_log off;
} }
location / {
location / { try_files $uri $uri/ /index.html =404;
try_files $uri $uri/ /index.html =404; }
} location /iframe.html {
location /iframe.html { try_files $uri $uri/ /iframe.html =404;
try_files $uri $uri/ /iframe.html =404; }
} }
}
} }

View File

@@ -50,15 +50,15 @@ module.exports = {
disable: false, disable: false,
allChunks: true allChunks: true
}), }),
new BugsnagBuildReporterPlugin({ // new BugsnagBuildReporterPlugin({
apiKey: 'ba9fae819372850fb660755341fa6ef5', // apiKey: 'ba9fae819372850fb660755341fa6ef5',
appVersion: `${pkgJson.version}-${buildDate.toISOString()}` // appVersion: `${pkgJson.version}-${buildDate.toISOString()}`
}, { /* opts */ }), // }, { /* opts */ }),
new BugsnagSourceMapUploaderPlugin({ // new BugsnagSourceMapUploaderPlugin({
apiKey: 'ba9fae819372850fb660755341fa6ef5', // apiKey: 'ba9fae819372850fb660755341fa6ef5',
overwrite: true, // overwrite: true,
appVersion: `${pkgJson.version}-${buildDate.toISOString()}` // appVersion: `${pkgJson.version}-${buildDate.toISOString()}`
}), // }),
new InjectManifest({ new InjectManifest({
swSrc: './src/sw.js', swSrc: './src/sw.js',
importWorkboxFrom: 'cdn', importWorkboxFrom: 'cdn',