mirror of
https://gitee.com/chu1204505056/vue-admin-beautiful.git
synced 2025-05-21 20:10:46 +08:00
add docker
This commit is contained in:
parent
a9d6d1fe11
commit
cbb0cb76b5
1
.dockerignore
Normal file
1
.dockerignore
Normal file
@ -0,0 +1 @@
|
||||
node_modules
|
37
Dockerfile
Normal file
37
Dockerfile
Normal file
@ -0,0 +1,37 @@
|
||||
FROM nginx
|
||||
|
||||
MAINTAINER vue-admin-beautiful
|
||||
LABEL description=本项目基于vue-admin-beautiful开源版构建
|
||||
LABEL qq=783963206
|
||||
|
||||
# 环境变量
|
||||
ENV TZ=Asia/Shanghai \
|
||||
RUN_USER=nginx \
|
||||
RUN_GROUP=nginx \
|
||||
DATA_DIR=/data/web \
|
||||
LOG_DIR=/data/log/nginx
|
||||
|
||||
# 工作目录
|
||||
WORKDIR ${DATA_DIR}
|
||||
|
||||
# 日志输出
|
||||
RUN ["echo","vue-admin-beautiful - UI building..."]
|
||||
|
||||
# 切换为上海时区
|
||||
RUN ln -sf /usr/share/zoneinfo/$TZ /etc/localtime \
|
||||
&& echo $TZ > /etc/timezone
|
||||
|
||||
# 创建日志文件夹
|
||||
RUN mkdir ${LOG_DIR} -p
|
||||
RUN chown nginx.nginx -R ${LOG_DIR}
|
||||
|
||||
# 拷贝dist包文件
|
||||
COPY ./dist ./
|
||||
|
||||
# 拷贝nginx配置文件
|
||||
ADD nginx.conf /etc/nginx/nginx.conf
|
||||
ADD nginx.default.conf /etc/nginx/conf.d/default.conf
|
||||
|
||||
EXPOSE 80
|
||||
|
||||
ENTRYPOINT nginx -g "daemon off;"
|
5
deploy-docker-compose.sh
Normal file
5
deploy-docker-compose.sh
Normal file
@ -0,0 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
npm run build
|
||||
|
||||
docker-compose up -d
|
7
deploy-docker.sh
Normal file
7
deploy-docker.sh
Normal file
@ -0,0 +1,7 @@
|
||||
#!/bin/bash
|
||||
|
||||
npm run build
|
||||
|
||||
docker build -t vue-admin-beautiful .
|
||||
|
||||
docker run --name vue-admin-beautiful --restart=always -p 80:80 -v /var/nginx:/var/data -d vue-admin-beautiful
|
14
docker-compose.yml
Normal file
14
docker-compose.yml
Normal file
@ -0,0 +1,14 @@
|
||||
version: '3.3'
|
||||
services:
|
||||
vue-admin-beautiful:
|
||||
build: ./
|
||||
restart: always
|
||||
container_name: vue-admin-beautiful
|
||||
image: vue-admin-beautiful
|
||||
environment:
|
||||
TZ: Asia/Shanghai
|
||||
LANG: en_US.UTF-8
|
||||
volumes:
|
||||
- /var/nginx:/var/data #挂载 Nginx 文件
|
||||
ports:
|
||||
- "80:80"
|
45
nginx.conf
Normal file
45
nginx.conf
Normal file
@ -0,0 +1,45 @@
|
||||
user nginx;
|
||||
worker_processes auto;
|
||||
pid /var/run/nginx.pid;
|
||||
|
||||
events {
|
||||
use epoll;
|
||||
worker_connections 51200;
|
||||
multi_accept on;
|
||||
}
|
||||
|
||||
http {
|
||||
include /etc/nginx/mime.types;
|
||||
default_type application/octet-stream;
|
||||
|
||||
server_names_hash_bucket_size 512;
|
||||
client_header_buffer_size 32k;
|
||||
large_client_header_buffers 4 32k;
|
||||
client_max_body_size 50m;
|
||||
|
||||
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
|
||||
'$status $body_bytes_sent "$http_referer" '
|
||||
'"$http_user_agent" "$http_x_forwarded_for"';
|
||||
access_log /var/log/nginx/access.log main;
|
||||
sendfile on;
|
||||
tcp_nopush on;
|
||||
tcp_nodelay on;
|
||||
|
||||
keepalive_timeout 65;
|
||||
|
||||
# gzip 压缩
|
||||
gzip on;
|
||||
gzip_min_length 1k;
|
||||
gzip_buffers 4 16k;
|
||||
gzip_http_version 1.1;
|
||||
gzip_comp_level 2;
|
||||
gzip_types text/plain application/javascript application/x-javascript text/javascript text/css application/xml;
|
||||
gzip_vary on;
|
||||
gzip_proxied expired no-cache no-store private auth;
|
||||
gzip_disable "MSIE [1-6]\.";
|
||||
|
||||
limit_conn_zone $binary_remote_addr zone=perip:10m;
|
||||
limit_conn_zone $server_name zone=perserver:10m;
|
||||
|
||||
include /etc/nginx/conf.d/*.conf;
|
||||
}
|
46
nginx.default.conf
Normal file
46
nginx.default.conf
Normal file
@ -0,0 +1,46 @@
|
||||
server {
|
||||
listen 80;
|
||||
server_name localhost;
|
||||
|
||||
access_log /data/log/nginx/access.log main;
|
||||
error_log /data/log/nginx/error.log;
|
||||
|
||||
# 静态资源
|
||||
location / {
|
||||
root /data/web;
|
||||
index index.html index.htm;
|
||||
try_files $uri $uri/ /index.html;
|
||||
}
|
||||
|
||||
# 前端代理
|
||||
location ^~ /后端服务名 {
|
||||
proxy_pass http://后端服务IP地址:8080;
|
||||
add_header Access-Control-Allow-Origin *;
|
||||
add_header Access-Control-Allow-Credentials: true;
|
||||
add_header Access-Control-Allow-Methods GET,POST,OPTIONS,PUT,DELETE;
|
||||
|
||||
proxy_http_version 1.1;
|
||||
# 连接延时
|
||||
proxy_connect_timeout 3600s;
|
||||
proxy_read_timeout 3600s;
|
||||
proxy_send_timeout 3600s;
|
||||
# IP 穿透
|
||||
proxy_set_header Host $proxy_host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
# WebSocket 穿透
|
||||
proxy_set_header Origin "";
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "upgrade";
|
||||
}
|
||||
|
||||
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
|
||||
#location ~ \.php$ {
|
||||
# root html;
|
||||
# fastcgi_pass 127.0.0.1:9000;
|
||||
# fastcgi_index index.php;
|
||||
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
|
||||
# include fastcgi_params;
|
||||
#}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user