基于nginx docker 构建镜像

This commit is contained in:
周炽键 2021-06-06 10:37:12 +08:00
parent 74afe6fdd9
commit 547d96ea2c
4 changed files with 32 additions and 18 deletions

View File

@ -1,16 +1,21 @@
FROM node:lts FROM node:lts as dist
WORKDIR /src WORKDIR /src
COPY . . COPY . .
RUN yarn global add http-server && \ RUN yarn && \
npm install pm2 -g && \
yarn && \
yarn build:prod yarn build:prod
FROM nginx:1.19.2
WORKDIR /app
COPY --from=dist /src/dist .
COPY nginx.conf /etc/nginx/nginx.conf
EXPOSE 80 EXPOSE 80
# CMD ["http-server","/src/dist","-p","80"] CMD ["nginx","-g","daemon off;"]
CMD ["bash","http.sh"]

15
Node.Dockerfile Normal file
View File

@ -0,0 +1,15 @@
FROM node:lts
WORKDIR /src
COPY . .
RUN yarn && \
yarn build:prod && \
yarn global add pm2 http-server
EXPOSE 80
# CMD ["http-server","/src/dist","-p","80"]
CMD ["bash","http.sh"]

View File

@ -10,8 +10,8 @@ admin_pwd = 39zcj
[http-demo-admin-ci] [http-demo-admin-ci]
type = http type = http
custom_domains = demo-admin.ryio.cn custom_domains = demo.ryio.cn
local_ip = nginx local_ip = web
local_port = 80 local_port = 80
remote_port = 80 remote_port = 80
use_encryption = true use_encryption = true

View File

@ -58,21 +58,15 @@ http {
# Virtual Host Configs # Virtual Host Configs
## ##
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*; include /etc/nginx/sites-enabled/*;
server { server {
listen 80; listen 80;
server_name demo-admin.ryio.cn;
location / { location / {
proxy_set_header X-Real-IP $remote_addr; root /app;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; index index.html;
proxy_set_header Host $http_host; try_files $uri $uri/ /index.html;
proxy_redirect off;
proxy_set_header REMOTE-HOST $remote_addr;
proxy_pass http://wev/;
} }
} }