Commit ccff10e2 authored by Kunkka王辉's avatar Kunkka王辉 😲

feat: 新增java容器

parent 6806f359
# 环境变量env dev,test,test1,test2等区分
ENV=dev
# 服务宿主机的端口
PORT=80
PORT=8118
PORT_CRM=8181
# 代码目录,含前后端
CODE_DIR=/home/wh/workplace/code_test
\ No newline at end of file
## galaxy-开发/测试环境 docker-compose
## services
1. php
2. nginx
3. supervisor
### 文件目录
| 目录 | 占用内网端口 | 类型 |
|:------------------------|:-------------------------------------|:----|
| common-server | $GALAXY_COMMON_SERVER_API_HTTP_PORT | php |
| crm-admin | $OLD_CRM_ADMIN_HTTP_PORT | php |
| entry | $GALAXY_ENTRY_API_HTTP_PORT | php |
| flow-micros | $GALAXY_FLOW_MICROS_API_HTTP_PORT | php |
| galaxy-crm | $GALAXY_CRM_API_HTTP_PORT | php |
| galaxy-workflow | $GALAXY_WORKFLOW_API_HTTP_PORT | php |
| micros-gateway | $GALAXY_MICROS_GATEWAY_API_HTTP_PORT | php |
| CRM | $OLD_CRM_HTTP_PORT | vue |
| presale-micros | $GALAXY_PRESALE_MICROS_API_HTTP_PORT | php |
| server-site | $GALAXY_SERVER_SITE_API_HTTP_PORT | php |
| user-micros | $GALAXY_USER_MICROS_API_HTTP_PORT | php |
| dwp/subapp/userInfo | $VUE_USERINFO_PORT | vue |
| crm-client | $OLD_CRM_CLIENT_HTTP_PORT | vue |
| user-information-system | $OLD_CRM_USER_HTTP_PORT | vue |
| dwp/main | $DWP_HTTP_PORT | vue |
| dwp/subapp | $DWP_HTTP_PORT | vue |
### php扩展
| 名称 |
|:----------------|
......@@ -59,15 +83,37 @@
| zip |
| zlib |
## 命令执行,常驻supervisor,计划任务等处理
## 配置文件处理
如何让服务内部调度
## 安装与部署
- 新增一套测试环境
- 销毁一套测试环境
- 配置多个项目
- 执行php artisan
1. 本地或远程机器 git clone 仓库代码
```shell script
git clone git@gitlab.galaxy-immi.com:kunkka.wh/docker-test.git
cd galaxy
cp .env.example .env
# 修改.env
# ENV = 环境
# PORT = 服务端口
# CODE_DIR = 挂载目录
# 启动容器环境
docker compose up -d # 或 docker-compose up -d
# 销毁环境环境
docker compose down --rmi all # 销毁并删除镜像
```
2. portainer使用(推荐)
- compose-yaml文件变更时,自动更新容器环境
- webhook
- 定时任务
## 代码更新
1. 更新后端代码
2. 更新前端代码
## 执行脚本
## 执行计划任务
## 常驻进程管理
......@@ -6,12 +6,13 @@ services:
dockerfile: Dockerfile-php
image: galaxy-php:7.4
container_name: galaxy-php7.4-${ENV:-dev}
volumes:
- ${CODE_DIR}:/var/www
volumes: # 前后端代码统一放一个目录管理
- ${CODE_DIR}:/app/www
expose:
- 9000
networks:
- galaxy-net
restart: on-failure
nginx:
build:
context: src
......@@ -34,16 +35,104 @@ services:
- GALAXY_WORKFLOW_API_HTTP_PORT=9108
- GALAXY_COMMON_SERVER_API_HTTP_PORT=9109
- VUE_USERINFO_PORT=9169
- JAVA_CLIENT_URI=galaxy-client-${ENV:-dev}:9308
- JAVA_NOTICE_URI=galaxy-notice-${ENV:-dev}:9307
- JAVA_FLOWENGINE_URI=galaxy-flowengine-${ENV:-dev}:9305
- JAVE_INTELLIGENTWRITING_URI=galaxy-intelligentwriting-${ENV:-dev}:9319
- JAVA_BIZ_PLATFORM_URI=galaxy-biz-platform-${ENV:-dev}:9315
image: galaxy-nginx
container_name: nginx-${ENV:-dev}
volumes: # 前后端代码统一放一个目录管理
- ${CODE_DIR}:/app/www
networks:
- galaxy-net
expose:
- 80
ports:
- "${PORT:-8118}:80"
- "${PORT:-8118}:8081"
- "${PORT_CRM:-8181}:8181"
command: [ "nginx", "-g","daemon off;" ]
restart: on-failure
java-notice:
build:
context: src
dockerfile: Dockerfile-java
args:
- PROJECT_NAME=notice
image: galaxy-java:11
container_name: galaxy-notice-${ENV:-dev}
volumes:
- ${CODE_DIR}:/app/code
- maven-repo:/usr/share/maven/repo # maven共享repo目录
expose:
- 9307
networks:
- galaxy-net
java-biz-platform:
build:
context: src
dockerfile: Dockerfile-java
args:
- PROJECT_NAME=biz-platform
image: galaxy-java:11
container_name: galaxy-biz-platform-${ENV:-dev}
volumes:
- ${CODE_DIR}:/app/code
- maven-repo:/usr/share/maven/repo # maven共享repo目录
command: ['/app/java-start.sh','--spring.profiles.active=dev']
expose:
- 9315
networks:
- galaxy-net
java-flowengine:
build:
context: src
dockerfile: Dockerfile-java
args:
- PROJECT_NAME=flowengine
image: galaxy-java:11
container_name: galaxy-flowengine-${ENV:-dev}
volumes:
- ${CODE_DIR}:/app/code
- maven-repo:/usr/share/maven/repo # maven共享repo目录
command: [ '/app/java-start.sh','--spring.profiles.active=dev' ]
expose:
- 9305
networks:
- galaxy-net
java-intelligentwriting:
build:
context: src
dockerfile: Dockerfile-java
args:
- PROJECT_NAME=intelligentwriting
image: galaxy-java:11
container_name: galaxy-intelligentwriting-${ENV:-dev}
volumes:
- ${CODE_DIR}:/app/code
- maven-repo:/usr/share/maven/repo # maven共享repo目录
command: [ '/app/java-start.sh','--spring.profiles.active=dev' ]
expose:
- 9319
networks:
- galaxy-net
java-client:
build:
context: src
dockerfile: Dockerfile-java
args:
- PROJECT_NAME=client
image: galaxy-java:11
container_name: galaxy-client-${ENV:-dev}
volumes:
- ${CODE_DIR}:/app/code
- maven-repo:/usr/share/maven/repo # maven共享repo目录
command: [ '/app/java-start.sh','--spring.profiles.active=dev' ]
expose:
- 9308
networks:
- galaxy-net
networks:
galaxy-net:
name: galaxy-net
driver: bridge
\ No newline at end of file
driver: bridge
volumes:
maven-repo:
\ No newline at end of file
FROM maven:3.8.4-openjdk-11
WORKDIR /app
ARG PROJECT_NAME
COPY settings.xml /usr/share/maven/conf/settings.xml
COPY <<EOF /app/java-start.sh
#/bin/bash
#进入项目
# 接收参数
cd /app/code/${PROJECT_NAME} && \
mvn clean package -B -DskipTests && \
mv /app/code/${PROJECT_NAME}/target/*.jar /app/app.jar &&\
mvn clean && \
java -jar /app/app.jar "\$@"
EOF
RUN chmod +x /app/java-start.sh
CMD ["/app/java-start.sh"]
......@@ -17,6 +17,11 @@ ARG GALAXY_ENTRY_API_HTTP_PORT
ARG GALAXY_WORKFLOW_API_HTTP_PORT
ARG GALAXY_COMMON_SERVER_API_HTTP_PORT
ARG VUE_USERINFO_PORT
ARG JAVA_CLIENT_URI
ARG JAVA_NOTICE_URI
ARG JAVA_FLOWENGINE_URI
ARG JAVE_INTELLIGENTWRITING_URI
ARG JAVA_BIZ_PLATFORM_URI
ENTRYPOINT ["/docker-entrypoint.sh"]
COPY deploy-hosts.sh /app/deploy-hosts.sh
RUN chmod +x /app/deploy-hosts.sh && /app/deploy-hosts.sh
......
#部署的env全部,用来追加到 项目的.env 文件用来支持每个服务之间的调用
SERVICE_BaseMicros=$HOST:1234 #缺省
SERVICE_MarketMicros=$HOST:1234 #缺省
SERVICE_FlowMicros=$HOST:$GALAXY_FLOW_MICROS_API_HTTP_PORT
SERVICE_UserMicros=$HOST:$GALAXY_USER_MICROS_API_HTTP_PORT
SERVICE_FlowEngineMicros= #java
SERVICE_ServerSiteMicros=$HOST:$GALAXY_SERVER_SITE_API_HTTP_PORT
SERVICE_NoticeMicros= #java
SERVICE_PromotionMicros=#缺省
SERVICE_MemberMicros=#缺省
SERVICE_PresaleMicros=$HOST:$GALAXY_PRESALE_MICROS_API_HTTP_PORT
SERVICE_BizPlatform= #java
SERVICE_CrmClient= #java
SERVICE_common-server=$HOST:$GALAXY_COMMON_SERVER_API_HTTP_PORT
SERVICE_workflow-server=$HOST:$GALAXY_WORKFLOW_API_HTTP_PORT
SERVICE_data-center=$HOST:1234 #缺省
\ No newline at end of file
......@@ -51,15 +51,14 @@ server {
proxy_pass http://$HOST:$GALAXY_PRESALE_MICROS_API_HTTP_PORT;
}
location ^~ /intelligentWriting/ {
#待部署
proxy_pass http://middle-platform.galaxy-immi.com:8319/intelligentWriting/;
proxy_pass http://$JAVE_INTELLIGENTWRITING_URI/intelligentWriting/;
}
location ^~ /business/ {
proxy_pass http://$HOST:$GALAXY_SERVER_SITE_API_HTTP_PORT;
}
location ^~ /biz-platform/ {
# 待部署
proxy_pass http://middle-platform.galaxy-immi.com:8315/biz-platform/;
proxy_pass http://$JAVA_BIZ_PLATFORM_URI/biz-platform/;
}
location ~ ^/(\.user.ini|\.htaccess|\.git|\.svn|\.project|LICENSE|README.md)
{
......@@ -79,7 +78,7 @@ cat <<EOF >/etc/nginx/conf.d/crm-client.conf
server {
listen $OLD_CRM_CLIENT_HTTP_PORT;
server_name localhost;
root /app/www/crm-client;
root /app/www/CRM-Client;
index index.php index.html;
location ^~ /backend/ {
......@@ -93,8 +92,7 @@ server {
}
location ^~ /client-web/ {
#待部署
proxy_pass http://middle-platform.galaxy-immi.com:8308;
proxy_pass http:$JAVA_CLIENT_URI;
#获取客户端真实IP
proxy_set_header X-Real-PORT \$remote_port;
proxy_set_header X-Real-IP \$remote_addr;
......@@ -127,7 +125,7 @@ cat <<EOF >/etc/nginx/conf.d/crm-userinfo.conf
server {
listen $OLD_CRM_USER_HTTP_PORT;
server_name localhost;
root /app/www/user-information-system;
root /app/www/User-Information-System;
index index.php index.html;
location ^~ /backend/ {
proxy_pass http://$HOST:$GALAXY_FLOW_MICROS_API_HTTP_PORT;
......@@ -140,8 +138,7 @@ server {
}
location ^~ /client-web/ {
#待部署
proxy_pass http://middle-platform.galaxy-immi.com:8308;
proxy_pass http://$JAVA_CLIENT_URI;
#获取客户端真实IP
proxy_set_header X-Real-PORT \$remote_port;
proxy_set_header X-Real-IP \$remote_addr;
......@@ -319,8 +316,8 @@ server {
}
location ^~ /client-web/ {
#待部署
proxy_pass http://middle-platform.galaxy-immi.com:8308;
proxy_pass http://$JAVA_CLIENT_URI;
#获取客户端真实IP
proxy_set_header X-Real-PORT \$remote_port;
proxy_set_header X-Real-IP \$remote_addr;
......
<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.2.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.2.0 http://maven.apache.org/xsd/settings-1.2.0.xsd">
<localRepository>/usr/share/maven/repo</localRepository>
<pluginGroups>
</pluginGroups>
<proxies>
</proxies>
<servers>
</servers>
<mirrors>
<!-- 阿里云仓库 -->
<mirror>
<id>alimaven</id>
<mirrorOf>central</mirrorOf>
<name>aliyun maven</name>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
</mirror>
</mirrors>
</settings>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment