Skip to content

Commit 6766b44

Browse files
Merge pull request cool-team-official#2 from GCSLaoLi/master
增加Docker部署配置
2 parents efa7ea7 + 37f8925 commit 6766b44

File tree

3 files changed

+119
-0
lines changed

3 files changed

+119
-0
lines changed

.dockerignore

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
.DS_Store
2+
node_modules
3+
/dist
4+
5+
# local env files
6+
.env.local
7+
.env.*.local
8+
9+
# Log files
10+
npm-debug.log*
11+
yarn-debug.log*
12+
yarn-error.log*
13+
yarn.lock
14+
15+
# Editor directories and files
16+
.idea
17+
*.suo
18+
*.ntvs*
19+
*.njsproj
20+
*.sln
21+
*.sw?

Dockerfile

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
FROM node:lts-alpine
2+
WORKDIR /build
3+
RUN npm config set sass_binary_site=https://npm.taobao.org/mirrors/node-sass
4+
RUN npm set registry https://registry.npm.taobao.org
5+
COPY package.json /build/package.json
6+
RUN npm install
7+
COPY ./ /build
8+
RUN npm run build
9+
10+
FROM nginx
11+
RUN mkdir /app
12+
COPY --from=0 /build/dist /app
13+
COPY --from=0 /build/nginx.conf /etc/nginx/nginx.conf
14+
EXPOSE 80

nginx.conf

+84
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
user nginx;
2+
worker_processes 1;
3+
error_log /var/log/nginx/error.log warn;
4+
pid /var/run/nginx.pid;
5+
events {
6+
worker_connections 1024;
7+
}
8+
http {
9+
include /etc/nginx/mime.types;
10+
default_type application/octet-stream;
11+
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
12+
'$status $body_bytes_sent "$http_referer" '
13+
'"$http_user_agent" "$http_x_forwarded_for"';
14+
access_log /var/log/nginx/access.log main;
15+
sendfile on;
16+
keepalive_timeout 65;
17+
18+
server {
19+
listen 80;
20+
server_name localhost;
21+
location / {
22+
root /app;
23+
index index.html;
24+
try_files $uri $uri/ /index.html;
25+
}
26+
location /api/
27+
{
28+
proxy_pass http://midway:7001/;
29+
proxy_set_header Host $host;
30+
proxy_set_header X-Real-IP $remote_addr;
31+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
32+
proxy_set_header REMOTE-HOST $remote_addr;
33+
34+
#缓存相关配置
35+
#proxy_cache cache_one;
36+
#proxy_cache_key $host$request_uri$is_args$args;
37+
#proxy_cache_valid 200 304 301 302 1h;
38+
39+
#持久化连接相关配置
40+
proxy_connect_timeout 3000s;
41+
proxy_read_timeout 86400s;
42+
proxy_send_timeout 3000s;
43+
#proxy_http_version 1.1;
44+
#proxy_set_header Upgrade $http_upgrade;
45+
#proxy_set_header Connection "upgrade";
46+
47+
add_header X-Cache $upstream_cache_status;
48+
49+
#expires 12h;
50+
}
51+
52+
location /adminer/
53+
{
54+
proxy_pass http://adminer:8080/;
55+
proxy_set_header Host $host;
56+
proxy_set_header X-Real-IP $remote_addr;
57+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
58+
proxy_set_header REMOTE-HOST $remote_addr;
59+
60+
#缓存相关配置
61+
#proxy_cache cache_one;
62+
#proxy_cache_key $host$request_uri$is_args$args;
63+
#proxy_cache_valid 200 304 301 302 1h;
64+
65+
#持久化连接相关配置
66+
proxy_connect_timeout 3000s;
67+
proxy_read_timeout 86400s;
68+
proxy_send_timeout 3000s;
69+
#proxy_http_version 1.1;
70+
#proxy_set_header Upgrade $http_upgrade;
71+
#proxy_set_header Connection "upgrade";
72+
73+
add_header X-Cache $upstream_cache_status;
74+
75+
#expires 12h;
76+
}
77+
78+
error_page 500 502 503 504 /50x.html;
79+
location = /50x.html {
80+
root /usr/share/nginx/html;
81+
}
82+
83+
}
84+
}

0 commit comments

Comments
 (0)