惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

V
Vulnerabilities – Threatpost
U
Unit 42
F
Fortinet All Blogs
aimingoo的专栏
aimingoo的专栏
P
Proofpoint News Feed
F
Full Disclosure
月光博客
月光博客
Engineering at Meta
Engineering at Meta
博客园_首页
The Register - Security
The Register - Security
G
Google Developers Blog
The Cloudflare Blog
博客园 - Franky
K
Kaspersky official blog
A
Arctic Wolf
Scott Helme
Scott Helme
C
Cisco Blogs
Hugging Face - Blog
Hugging Face - Blog
C
Check Point Blog
NISL@THU
NISL@THU
AI
AI
D
DataBreaches.Net
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Stack Overflow Blog
Stack Overflow Blog
Project Zero
Project Zero
The GitHub Blog
The GitHub Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
量子位
Vercel News
Vercel News
T
Tor Project blog
P
Privacy International News Feed
D
Docker
I
Intezer
L
LangChain Blog
P
Proofpoint News Feed
Security Latest
Security Latest
C
CXSECURITY Database RSS Feed - CXSecurity.com
T
Threatpost
博客园 - 聂微东
AWS News Blog
AWS News Blog
Martin Fowler
Martin Fowler
P
Privacy & Cybersecurity Law Blog
V
V2EX
Last Week in AI
Last Week in AI
C
Cybersecurity and Infrastructure Security Agency CISA
The Hacker News
The Hacker News
T
Tenable Blog
Blog — PlanetScale
Blog — PlanetScale
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
T
Tailwind CSS Blog

博客园 - NewSea

Linux 安装IntelAx211无线网卡 解决 K8sApi 部署后报 Unknown apiVersionKind apps/v1/Deployment is it registered? docker 一键启动 mariadb 分区脚本 Spring笔记--@ConditionalOnBean坑 K8s笔记 ubuntu18+k8s单机版+kuboard+harbor安装笔记 yapi 自定义Json的数据类型 Nginx笔记 k3s+rancher+harbor 笔记 postgresql 笔记 vscode 笔记 发布Jar包到中央仓库 Java开发笔记汇总 - NewSea - 博客园 css 适配 nui-app 笔记 Java里的不能与无用. SSH 配置 Swagger 配置
Docker 启动前后端脚本
NewSea · 2022-12-06 · via 博客园 - NewSea

后端

docker 提前运行 consul,mongo,redis

进入到 Jar所在的文件夹(文件夹下只有一个Jar!)

新建 start.sh

CMD jar_name=$(ls -1 -F *.jar) && \
 java  -Xms450m -Xmx450m \
  -XX:+UseContainerSupport -XX:MaxRAMPercentage=80  -XX:MaxMetaspaceSize=178m -XX:MetaspaceSize=178m -Xss512k ${JAVA_OPTS} \
 -Dlog4j2.formatMsgNoLookups=true \
 -Dspring.cloud.bootstrap.enabled=true \
 -Dreactor.netty.pool.leasingStrategy=lifo \
 -Dloader.path=lib \
 -jar $jar_name \
 --spring.main.allow-bean-definition-overriding=true \
 --spring.main.allow-circular-references=true \
 --spring.profiles.active=consul,yuxh,amy $*

执行Docker (暴露端口,是给前端调用联调用!)

docker run -d  --name gateway -v "$PWD":/app -w /app -p 8083:8083 --link consul:consul --link mongo:mongo --link redis:redis  openjdk:17  /bin/bash  /app/start.sh

前端

/vue/nginx.cnf

server {
    listen       80;
    listen  [::]:80;
    server_name _; 

    #access_log  /var/log/nginx/host.access.log  main;
    absolute_redirect off;
    index index.html;
    
    location /api/ {
        if ($request_method = 'OPTIONS') {
            add_header 'Access-Control-Allow-Credentials' 'true';
            add_header 'Access-Control-Allow-Origin' "$http_origin";
            add_header 'Access-Control-Allow-Methods' '$http_access_control_request_method';
            add_header 'Access-Control-Allow-Headers' '$http_access_control_request_headers';
            add_header 'Access-Control-Expose-Headers' '$http_access_control_request_headers';
            add_header 'Access-Control-Max-Age' '2592000';
            add_header 'Content-Length' 0;
            add_header 'Content-Type' 'text/plain charset=UTF-8';
            add_header 'Access-Control-Allow-Headers' 'Authorization';
            return 204;
        } 
        
        proxy_pass http://mp-gateway-api:8083/;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_redirect off;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
    
    location /{虚拟目录} {
        alias   /vue/;
        try_files $uri $uri/ /index.html =404;
    } 
}

cp /vue/nginx.cnf /vue/{应用名}/nginx.cnf
cd /vue/{应用名}
修改 nginx.cnf 中的 虚拟目录

docker run -d  -p 8010:80 --name {应用名} --link mp-gateway-api:mp-gateway-api -v "$PWD"/nginx.conf:/etc/nginx/conf.d/default.conf  -v "$PWD"/dist:/vue/   nginx