Skip to content

Commit 7460459

Browse files
author
Кравченко Игорь Александрович
committed
add docker
1 parent e4cf6a3 commit 7460459

File tree

5 files changed

+263
-0
lines changed

5 files changed

+263
-0
lines changed

Dockerfile.csr

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
FROM node::8-alpine as buildContainer
2+
3+
COPY . /app
4+
WORKDIR /app
5+
RUN yarn install
6+
RUN npm run build:prod
7+
8+
FROM nginx:alpine
9+
COPY --from=buildContainer /app/dist /app
10+
COPY --from=buildContainer /app/nginx.conf /etc/nginx/nginx.conf
11+
COPY --from=buildContainer /app/mime.types /etc/nginx/mime.types
12+
COPY --from=buildContainer /app/gzip.conf /etc/nginx/gzip.conf
13+
14+
EXPOSE 9000/tcp

Dockerfile.ssr

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
FROM node::8-alpine as buildContainer
2+
3+
COPY . /app
4+
WORKDIR /app
5+
RUN yarn install
6+
RUN npm run build:universal
7+
8+
FROM node:8-alpine
9+
10+
WORKDIR /app
11+
# Copy dependency definitions
12+
COPY --from=buildContainer /app/package.json /app
13+
COPY --from=buildContainer /app/server.js /app
14+
15+
# Get all the code needed to run the app
16+
COPY --from=buildContainer /app/dist /app/dist
17+
COPY --from=buildContainer /app/dist-server /app/dist-server
18+
19+
# Expose the port the app runs in
20+
EXPOSE 4000
21+
22+
# Serve the app
23+
CMD ["npm", "run", "server"]

gzip.conf

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Enable Gzip compressed.
2+
gzip on;
3+
4+
# Enable compression both for HTTP/1.0 and HTTP/1.1 (required for CloudFront).
5+
gzip_http_version 1.0;
6+
7+
# Compression level (1-9).
8+
# 5 is a perfect compromise between size and cpu usage, offering about
9+
# 75% reduction for most ascii files (almost identical to level 9).
10+
gzip_comp_level 5;
11+
12+
# Don't compress anything that's already small and unlikely to shrink much
13+
# if at all (the default is 20 bytes, which is bad as that usually leads to
14+
# larger files after gzipping).
15+
gzip_min_length 256;
16+
17+
# Compress data even for clients that are connecting to us via proxies,
18+
# identified by the "Via" header (required for CloudFront).
19+
gzip_proxied any;
20+
21+
# Tell proxies to cache both the gzipped and regular version of a resource
22+
# whenever the client's Accept-Encoding capabilities header varies;
23+
# Avoids the issue where a non-gzip capable client (which is extremely rare
24+
# today) would display gibberish if their proxy gave them the gzipped version.
25+
gzip_vary on;
26+
27+
# Compress all output labeled with one of the following MIME-types.
28+
gzip_types
29+
application/atom+xml
30+
application/javascript
31+
application/json
32+
application/rss+xml
33+
application/vnd.ms-fontobject
34+
application/x-font-ttf
35+
application/x-web-app-manifest+json
36+
application/xhtml+xml
37+
application/xml
38+
font/opentype
39+
image/svg+xml
40+
image/x-icon
41+
text/css
42+
text/plain
43+
text/x-component;
44+
# text/html is always compressed by HttpGzipModule

mime.types

Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
types {
2+
3+
# Data interchange
4+
5+
application/atom+xml atom;
6+
application/json json map topojson;
7+
application/ld+json jsonld;
8+
application/rss+xml rss;
9+
application/vnd.geo+json geojson;
10+
application/xml rdf xml;
11+
12+
13+
# JavaScript
14+
15+
# Normalize to standard type.
16+
# https://tools.ietf.org/html/rfc4329#section-7.2
17+
application/javascript js;
18+
19+
20+
# Manifest files
21+
22+
application/manifest+json webmanifest;
23+
application/x-web-app-manifest+json webapp;
24+
text/cache-manifest appcache;
25+
26+
27+
# Media files
28+
29+
audio/midi mid midi kar;
30+
audio/mp4 aac f4a f4b m4a;
31+
audio/mpeg mp3;
32+
audio/ogg oga ogg opus;
33+
audio/x-realaudio ra;
34+
audio/x-wav wav;
35+
image/bmp bmp;
36+
image/gif gif;
37+
image/jpeg jpeg jpg;
38+
image/png png;
39+
image/svg+xml svg svgz;
40+
image/tiff tif tiff;
41+
image/vnd.wap.wbmp wbmp;
42+
image/webp webp;
43+
image/x-jng jng;
44+
video/3gpp 3gp 3gpp;
45+
video/mp4 f4p f4v m4v mp4;
46+
video/mpeg mpeg mpg;
47+
video/ogg ogv;
48+
video/quicktime mov;
49+
video/webm webm;
50+
video/x-flv flv;
51+
video/x-mng mng;
52+
video/x-ms-asf asf asx;
53+
video/x-ms-wmv wmv;
54+
video/x-msvideo avi;
55+
56+
# Serving `.ico` image files with a different media type
57+
# prevents Internet Explorer from displaying then as images:
58+
# https://github.com/h5bp/html5-boilerplate/commit/37b5fec090d00f38de64b591bcddcb205aadf8ee
59+
60+
image/x-icon cur ico;
61+
62+
63+
# Microsoft Office
64+
65+
application/msword doc;
66+
application/vnd.ms-excel xls;
67+
application/vnd.ms-powerpoint ppt;
68+
application/vnd.openxmlformats-officedocument.wordprocessingml.document docx;
69+
application/vnd.openxmlformats-officedocument.spreadsheetml.sheet xlsx;
70+
application/vnd.openxmlformats-officedocument.presentationml.presentation pptx;
71+
72+
73+
# Web fonts
74+
75+
application/font-woff woff;
76+
application/font-woff2 woff2;
77+
application/vnd.ms-fontobject eot;
78+
79+
# Browsers usually ignore the font media types and simply sniff
80+
# the bytes to figure out the font type.
81+
# https://mimesniff.spec.whatwg.org/#matching-a-font-type-pattern
82+
#
83+
# However, Blink and WebKit based browsers will show a warning
84+
# in the console if the following font types are served with any
85+
# other media types.
86+
87+
application/x-font-ttf ttc ttf;
88+
font/opentype otf;
89+
90+
91+
# Other
92+
93+
application/java-archive ear jar war;
94+
application/mac-binhex40 hqx;
95+
application/octet-stream bin deb dll dmg exe img iso msi msm msp safariextz;
96+
application/pdf pdf;
97+
application/postscript ai eps ps;
98+
application/rtf rtf;
99+
application/vnd.google-earth.kml+xml kml;
100+
application/vnd.google-earth.kmz kmz;
101+
application/vnd.wap.wmlc wmlc;
102+
application/x-7z-compressed 7z;
103+
application/x-bb-appworld bbaw;
104+
application/x-bittorrent torrent;
105+
application/x-chrome-extension crx;
106+
application/x-cocoa cco;
107+
application/x-java-archive-diff jardiff;
108+
application/x-java-jnlp-file jnlp;
109+
application/x-makeself run;
110+
application/x-opera-extension oex;
111+
application/x-perl pl pm;
112+
application/x-pilot pdb prc;
113+
application/x-rar-compressed rar;
114+
application/x-redhat-package-manager rpm;
115+
application/x-sea sea;
116+
application/x-shockwave-flash swf;
117+
application/x-stuffit sit;
118+
application/x-tcl tcl tk;
119+
application/x-x509-ca-cert crt der pem;
120+
application/x-xpinstall xpi;
121+
application/xhtml+xml xhtml;
122+
application/xslt+xml xsl;
123+
application/zip zip;
124+
text/css css;
125+
text/html htm html shtml;
126+
text/mathml mml;
127+
text/plain txt;
128+
text/vcard vcard vcf;
129+
text/vnd.rim.location.xloc xloc;
130+
text/vnd.sun.j2me.app-descriptor jad;
131+
text/vnd.wap.wml wml;
132+
text/vtt vtt;
133+
text/x-component htc;
134+
135+
}

nginx.conf

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
user nginx;
2+
worker_processes 4;
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+
log_format gzip '[$time_local] ' '"$request" $status $bytes_sent';
15+
16+
include /etc/nginx/mime.types;
17+
default_type application/octet-stream;
18+
19+
access_log /dev/stdout;
20+
charset utf-8;
21+
22+
sendfile on;
23+
keepalive_timeout 65;
24+
25+
#include /etc/nginx/conf.d/*.conf;
26+
27+
server {
28+
listen 9000;
29+
server_name localhost;
30+
31+
access_log /dev/stdout;
32+
33+
root /app;
34+
35+
location / {
36+
try_files $uri$args $uri$args/ /index.html;
37+
}
38+
39+
error_page 500 502 503 504 /50x.html;
40+
location = /50x.html {
41+
root /usr/share/nginx/html;
42+
}
43+
44+
}
45+
# Compression
46+
include /etc/nginx/gzip.conf;
47+
}

0 commit comments

Comments
 (0)