commit b41f0c3b0593ccb7f3c66912af9d9ec060375d1e Author: yanghanbin Date: Thu Feb 22 17:02:36 2024 +0800 * #01 init code diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..feab0cd --- /dev/null +++ b/Dockerfile @@ -0,0 +1,27 @@ +# 基础镜像 +FROM openjdk:8-jre +# author +MAINTAINER afe + +# 挂载目录 +VOLUME /home/ai +# 创建目录 +RUN mkdir -p /home/ai + +ENV HOSTNAME="ai-data" + +# +ARG PROFILE_ACTIVE + +# 指定路径 +WORKDIR /home/ai +# 复制jar文件到路径 +COPY /target/ai-data.jar /home/ai/ai-data.jar + +#COPY /ai-auth/jar_lib/skywalking /home/ai/skywalking + +ENV TIME_ZONE=Asia/Shanghai +RUN ln -snf /usr/share/zoneinfo/$TIME_ZONE /etc/localtime && echo $TIME_ZONE > /etc/timezone + +# 启动认证服务 +ENTRYPOINT ["java", "-Xms512m", "-Xmx512m", "-jar", "ai-data.jar", "--spring.cloud.nacos.discovery.ip=${HOSTNAME}", "--spring.profiles.active=${PROFILE_ACTIVE}"] \ No newline at end of file diff --git a/bin/depoly.sh b/bin/depoly.sh new file mode 100644 index 0000000..e4b9987 --- /dev/null +++ b/bin/depoly.sh @@ -0,0 +1,49 @@ +#接收外部参数,由jenkinsfile执行部署脚本时传递 +projectName=$1 +imageName=$2 +version=$3 +profileActive=$4 + +echo "镜像名: $imageName" +echo "项目名: $projectName" +echo "版本号: $version" +echo "多环境: $profileActive" +# 容器id +containerId=$(docker ps -a | grep -w "${projectName}" | awk '{print $1}') +if [ "$containerId" != "" ] ; +then + #停掉容器 + docker stop "$containerId" + #删除容器 + docker rm "$containerId" + echo "成功删除容器" +fi + +# 镜像id +imageId=$(docker images | grep -w "${projectName}" | awk '{print $3}') +#if [ "$imageId" != "" ] ; +#then + #删除镜像 + #docker rmi --force $(docker images | grep -w "${projectName}" | awk '{print $3}') + #echo "成功删除镜像" +#fi + +docker login 192.168.3.210:9999 + +# 镜像下载 +docker pull "$imageName" +# cd /data/dev/app +# 启动容器 +VERSION="${version}" PROFILE_ACTIVE=${profileActive} docker-compose up -d "${projectName}" +echo "容器启动成功" + + +# 镜像id +imageId=$(docker images | grep -w "${projectName}" | awk '{print $3}') +#if [ "$imageId" != "" ] ; +#then + #删除镜像 + #docker rmi --force $(docker images | grep -w "${projectName}" | awk '{print $3}') + #echo "成功删除镜像" +#fi + diff --git a/bin/docker-compose.yml b/bin/docker-compose.yml new file mode 100644 index 0000000..40df1a8 --- /dev/null +++ b/bin/docker-compose.yml @@ -0,0 +1,98 @@ +version: "3.8" +services: + ai-auth: + image: 192.168.3.210:9999/ai/ai-auth:${VERSION} + container_name: ai-auth + ports: + - "9206:9206" + mem_limit: 512m + environment: + PROFILE_ACTIVE: ${PROFILE_ACTIVE} + volumes: + - /data/logs/ai-auth/:/data/logs/ai-auth + restart: + always + ai-customer: + image: 192.168.2.210:9999/ai/ai-customer:${VERSION} + container_name: ai-customer + ports: + - "9204:9204" + environment: + PROFILE_ACTIVE: ${PROFILE_ACTIVE} + volumes: + - /data/logs/ai-customer/:/data/logs/ai-customer + restart: + always + ai-file: + image: 192.168.2.210:9999/ai/ai-file:${VERSION} + container_name: ai-file + ports: + - "9208:9208" + environment: + PROFILE_ACTIVE: ${PROFILE_ACTIVE} + volumes: + - /data/logs/ai-file/:/data/logs/ai-file + restart: + always + ai-gateway: + image: 192.168.2.210:9999/ai/ai-gateway:${VERSION} + container_name: ai-gateway + ports: + - "8088:8088" + environment: + PROFILE_ACTIVE: ${PROFILE_ACTIVE} + volumes: + - /data/logs/ai-gateway/:/data/logs/ai-gateway + restart: + always + ai-job: + image: 192.168.2.210:9999/ai/ai-job:${VERSION} + container_name: ai-job + ports: + - "9203:9203" + environment: + PROFILE_ACTIVE: ${PROFILE_ACTIVE} + volumes: + - /data/logs/ai-job/:/data/logs/ai-job + restart: + always + ai-news: + image: 192.168.2.210:9999/ai/ai-news:${VERSION} + container_name: ai-news + ports: + - "9205:9205" + environment: + PROFILE_ACTIVE: ${PROFILE_ACTIVE} + volumes: + - /data/logs/ai-news/:/data/logs/ai-news + restart: + always + ai-route: + image: 192.168.2.210:9999/ai/ai-route:${VERSION} + container_name: ai-route + ports: + - "9207:9207" + environment: + PROFILE_ACTIVE: ${PROFILE_ACTIVE} + volumes: + - /data/logs/ai-route/:/data/logs/ai-route + restart: + always + ai-system: + image: 192.168.2.210:9999/ai/ai-system:${VERSION} + container_name: ai-system + ports: + - "9201:9201" + environment: + PROFILE_ACTIVE: ${PROFILE_ACTIVE} + volumes: + - /data/logs/ai-system/:/data/logs/ai-system + restart: + always + +networks: + default: + external: + name: docker_default + + diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..83791d0 --- /dev/null +++ b/pom.xml @@ -0,0 +1,106 @@ + + + com.afe + ai-common + 1.0.0 + + 4.0.0 + + ai-data + + + ai-data数据中心 + + + + + + + com.alibaba.cloud + spring-cloud-starter-alibaba-nacos-discovery + + + + + com.alibaba.cloud + spring-cloud-starter-alibaba-nacos-config + + + + + com.alibaba.cloud + spring-cloud-starter-alibaba-sentinel + + + + + org.springframework.boot + spring-boot-starter-web + + + + + org.springframework.boot + spring-boot-starter-actuator + + + + + com.afe + ai-common-security + + + + + com.afe + ai-api-customer + + + + + org.springframework.boot + spring-boot-starter-websocket + + + + + com.afe + ai-common-baffle + + + + + org.springframework.boot + spring-boot-starter-test + test + + + + + junit + junit + test + + + + + + ${project.artifactId} + + + org.springframework.boot + spring-boot-maven-plugin + + + + repackage + + + + + + + +