Skip to content

Commit

Permalink
feat: 调整example打包脚本 (#163)
Browse files Browse the repository at this point in the history
* fix: optimize the discovery inject logic and fix nacos config not working issue

* feat: 删除无用的导入

* feat: 增加actuator到demo中

* fix: add lossless healthcheck for example

* fix: add configuration comments

* fix: 修复事件日志不输出的问题

* release: release version to 1.7.0-RC1

* feat: new add java agent for hoxton

* feat: support service registry and config

* feat: refrator all inject logics into BeanInjector

* feat: add gray release example & dispatch bean register into plugins

* feat: add environment parameter to obtain the configuration

* feat: 增加元数据传输相关拦截器

* feat: 调整example打包脚本

* fix: 修复脚本没法跳转的问题
  • Loading branch information
andrewshan authored May 9, 2024
1 parent d91b05c commit 52229ed
Show file tree
Hide file tree
Showing 28 changed files with 128 additions and 204 deletions.
71 changes: 39 additions & 32 deletions polaris-agent-build/bin/build_example_docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,38 +46,45 @@ for docker_file in ${docker_files}; do

dir_name=${folder_name##*/}

cp Dockerfile Dockerfile-${dir_name}
docker_tag="${version}-java8"

filename=$(find ./target -maxdepth 1 -name "*.jar" | grep -v "javadoc" | grep -v "sources" | head -n 1)
if [ -z "${filename}" ]; then
echo "jar file not found"
exit 1
fi
echo "jar file path is ${filename}"

filename=${filename##*/}
echo "jar sub file path is ${filename}"
if [ `grep -c "java_version" Dockerfile` -gt 0 ]
then
echo "docker repository java8: ${docker_repository}/${repo_name}, tag : ${docker_tag}"
docker buildx build -f Dockerfile-${dir_name} --no-cache -t ${docker_repository}/${repo_name}:${docker_tag} --build-arg file_name=${filename} --build-arg java_version=8 --platform ${platforms} --push ./

docker_tag="${version}-java11"
echo "docker repository java11: ${docker_repository}/${repo_name}, tag : ${docker_tag}"
docker buildx build -f Dockerfile-${dir_name} --no-cache -t ${docker_repository}/${repo_name}:${docker_tag} --build-arg file_name=${filename} --build-arg java_version=11 --platform ${platforms} --push ./

docker_tag="${version}-java17"
echo "docker repository java17: ${docker_repository}/${repo_name}, tag : ${docker_tag}"
docker buildx build -f Dockerfile-${dir_name} --no-cache -t ${docker_repository}/${repo_name}:${docker_tag} --build-arg file_name=${filename} --build-arg java_version=17 --platform ${platforms} --push ./
else
docker_tag="${version}-java17"
echo "docker repository java17: ${docker_repository}/${repo_name}, tag : ${docker_tag}"
docker buildx build -f Dockerfile-${dir_name} --no-cache -t ${docker_repository}/${repo_name}:${docker_tag} --build-arg file_name=${filename} --platform ${platforms} --push ./
fi

rm -f Dockerfile-${dir_name}
popd
cp Dockerfile Dockerfile-${dir_name}

filename=$(find ./target -maxdepth 1 -name "*.jar" | grep -v "javadoc" | grep -v "sources" | head -n 1)
if [ -z "${filename}" ]; then
echo "jar file not found"
exit 1
fi
echo "jar file path is ${filename}"

version=$(xmllint --xpath "//*[local-name()='project']/*[local-name()='version']/text()" pom.xml)
if [ -z "${version}" ]; then
echo "version not defined, skip"
continue
fi

filename=${filename##*/}
echo "jar sub file path is ${filename}, version is ${version}"

if [ `grep -c "java_version" Dockerfile` -gt 0 ]
then
docker_tag="${version}-java8"
echo "docker repository java8: ${docker_repository}/${repo_name}, tag : ${docker_tag}"
docker buildx build -f Dockerfile-${dir_name} --no-cache -t ${docker_repository}/${repo_name}:${docker_tag} --build-arg file_name=${filename} --build-arg java_version=8 --platform ${platforms} --push ./

docker_tag="${version}-java11"
echo "docker repository java11: ${docker_repository}/${repo_name}, tag : ${docker_tag}"
docker buildx build -f Dockerfile-${dir_name} --no-cache -t ${docker_repository}/${repo_name}:${docker_tag} --build-arg file_name=${filename} --build-arg java_version=11 --platform ${platforms} --push ./

docker_tag="${version}-java17"
echo "docker repository java17: ${docker_repository}/${repo_name}, tag : ${docker_tag}"
docker buildx build -f Dockerfile-${dir_name} --no-cache -t ${docker_repository}/${repo_name}:${docker_tag} --build-arg file_name=${filename} --build-arg java_version=17 --platform ${platforms} --push ./
else
docker_tag="${version}-java17"
echo "docker repository java17: ${docker_repository}/${repo_name}, tag : ${docker_tag}"
docker buildx build -f Dockerfile-${dir_name} --no-cache -t ${docker_repository}/${repo_name}:${docker_tag} --build-arg file_name=${filename} --platform ${platforms} --push ./
fi

rm -f Dockerfile-${dir_name}
popd
fi
done
popd
4 changes: 2 additions & 2 deletions polaris-agent-examples/spring-cloud-plugins-examples/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<module>spring-cloud-2021-examples</module>
<module>spring-cloud-2020-examples</module>
<module>spring-cloud-hoxton-examples</module>
<module>spring-cloud-2023-examples</module>
</modules>
<module>spring-cloud-2023-examples</module>
</modules>

</project>
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
FROM alpine:3.19.1

ARG file_name
ARG java_version

COPY ./target/${file_name} /app/main.jar

Expand All @@ -9,7 +10,7 @@ WORKDIR /app
RUN sed -i 's!http://dl-cdn.alpinelinux.org/!https://mirrors.tencent.com/!g' /etc/apk/repositories

RUN set -eux && \
apk add openjdk17 && \
apk add openjdk${java_version} && \
apk add bind-tools && \
apk add busybox-extras && \
apk add findutils && \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,26 @@ apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: service-a-2023
name: service-a-2023
app: service-a-hoxton
name: service-a-hoxton
namespace: default
spec:
replicas: 1
selector:
matchLabels:
app: service-a-2023
app: service-a-hoxton
template:
metadata:
labels:
app: service-a-2023
app: service-a-hoxton
annotations:
polarismesh.cn/javaagent: "true"
polarismesh.cn/javaagentVersion: "1.7.0-RC.0"
polarismesh.cn/javaagentVersion: "1.7.0-RC2"
polarismesh.cn/javaagentFrameworkName: "spring-cloud"
polarismesh.cn/javaagentFrameworkVersion: "2023"
polarismesh.cn/javaagentConfig: "{\"spring.cloud.polaris.namespace\": \"default\", \"spring.cloud.polaris.router.nearby-router.matchLevel\": \"campus\"}"
polarismesh.cn/javaagentFrameworkVersion: "hoxton"
spec:
containers:
- image: polarismesh/polaris-javaagent-demo-sc-gray-2023-service-a:1.7.0-RC.0-java17
- image: polarismesh/polaris-javaagent-demo-sc-gray-hoxton-service-a:1.7.0-java8
imagePullPolicy: Always
name: consumer
resources:
Expand All @@ -35,7 +34,7 @@ spec:
command:
- /bin/bash
- -c
- cd /app && java -Dspring.cloud.nacos.config.server-addr=127.0.0.1:8848 -Dspring.cloud.nacos.config.password=nacos -jar main.jar
- cd /app && java -Dserver.port=65203 -jar main.jar
lifecycle:
preStop:
exec:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<name>2023-service-a</name>
<description>Demo Service-A Project For Spring Cloud Alibaba</description>
<artifactId>polaris-javaagent-demo-sc-gray-hoxton-service-a</artifactId>
<version>1.7.0</version>
<packaging>jar</packaging>

<dependencyManagement>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
FROM alpine:3.19.1

ARG file_name
ARG java_version

COPY ./target/${file_name} /app/main.jar

Expand All @@ -9,7 +10,7 @@ WORKDIR /app
RUN sed -i 's!http://dl-cdn.alpinelinux.org/!https://mirrors.tencent.com/!g' /etc/apk/repositories

RUN set -eux && \
apk add openjdk17 && \
apk add openjdk${java_version} && \
apk add bind-tools && \
apk add busybox-extras && \
apk add findutils && \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,26 @@ apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: service-b-2023
name: service-b-2023
app: service-b-hoxton
name: service-b-hoxton
namespace: default
spec:
replicas: 1
selector:
matchLabels:
app: service-b-2023
app: service-b-hoxton
template:
metadata:
labels:
app: service-b-2023
app: service-b-hoxton
annotations:
polarismesh.cn/javaagent: "true"
polarismesh.cn/javaagentVersion: "1.7.0-RC.0"
polarismesh.cn/javaagentVersion: "1.7.0-RC2"
polarismesh.cn/javaagentFrameworkName: "spring-cloud"
polarismesh.cn/javaagentFrameworkVersion: "2023"
polarismesh.cn/javaagentConfig: "{\"spring.cloud.polaris.namespace\": \"default\", \"spring.cloud.polaris.router.nearby-router.matchLevel\": \"campus\"}"
polarismesh.cn/javaagentFrameworkVersion: "hoxton"
spec:
containers:
- image: polarismesh/polaris-javaagent-demo-sc-gray-2023-service-b:1.7.0-RC.0-java17
- image: polarismesh/polaris-javaagent-demo-sc-gray-hoxton-service-b:1.7.0-java8
imagePullPolicy: Always
name: consumer
resources:
Expand All @@ -35,7 +34,7 @@ spec:
command:
- /bin/bash
- -c
- cd /app && java -Dspring.cloud.nacos.config.server-addr=127.0.0.1:8848 -Dspring.cloud.nacos.config.password=nacos -jar main.jar
- cd /app && java -Dserver.port=65202 -jar main.jar
lifecycle:
preStop:
exec:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<description>Demo Service-B Project For Spring Cloud Alibaba</description>
<artifactId>polaris-javaagent-demo-sc-gray-hoxton-service-b</artifactId>
<packaging>jar</packaging>
<version>1.7.0</version>

<dependencyManagement>
<dependencies>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
FROM alpine:3.19.1

ARG file_name
ARG java_version

COPY ./target/${file_name} /app/main.jar

Expand All @@ -9,7 +10,7 @@ WORKDIR /app
RUN sed -i 's!http://dl-cdn.alpinelinux.org/!https://mirrors.tencent.com/!g' /etc/apk/repositories

RUN set -eux && \
apk add openjdk17 && \
apk add openjdk${java_version} && \
apk add bind-tools && \
apk add busybox-extras && \
apk add findutils && \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,26 @@ apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: service-c-2023
name: service-c-2023
app: service-c-hoxton
name: service-c-hoxton
namespace: default
spec:
replicas: 1
selector:
matchLabels:
app: service-c-2023
app: service-c-hoxton
template:
metadata:
labels:
app: service-c-2023
app: service-c-hoxton
annotations:
polarismesh.cn/javaagent: "true"
polarismesh.cn/javaagentVersion: "1.7.0-RC.0"
polarismesh.cn/javaagentVersion: "1.7.0-RC2"
polarismesh.cn/javaagentFrameworkName: "spring-cloud"
polarismesh.cn/javaagentFrameworkVersion: "2023"
polarismesh.cn/javaagentConfig: "{\"spring.cloud.polaris.namespace\": \"default\", \"spring.cloud.polaris.router.nearby-router.matchLevel\": \"campus\"}"
polarismesh.cn/javaagentFrameworkVersion: "hoxton"
spec:
containers:
- image: polarismesh/polaris-javaagent-demo-sc-gray-2023-service-c:1.7.0-RC.0-java17
- image: polarismesh/polaris-javaagent-demo-sc-gray-hoxton-service-c:1.7.0-java8
imagePullPolicy: Always
name: consumer
resources:
Expand All @@ -35,7 +34,7 @@ spec:
command:
- /bin/bash
- -c
- cd /app && java -Dspring.cloud.nacos.config.server-addr=127.0.0.1:8848 -Dspring.cloud.nacos.config.password=nacos -jar main.jar
- cd /app && java -Dserver.port=65201 -jar main.jar
lifecycle:
preStop:
exec:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<description>Demo Service-C Project For Spring Cloud Alibaba</description>
<artifactId>polaris-javaagent-demo-sc-gray-hoxton-service-c</artifactId>
<packaging>jar</packaging>
<version>1.7.0</version>

<dependencyManagement>
<dependencies>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
FROM alpine:3.19.1

ARG file_name
ARG java_version

COPY ./target/${file_name} /app/main.jar

Expand All @@ -9,7 +10,7 @@ WORKDIR /app
RUN sed -i 's!http://dl-cdn.alpinelinux.org/!https://mirrors.tencent.com/!g' /etc/apk/repositories

RUN set -eux && \
apk add openjdk17 && \
apk add openjdk${java_version} && \
apk add bind-tools && \
apk add busybox-extras && \
apk add findutils && \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,26 @@ apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: sc-gateway-2023
name: sc-gateway-2023
app: sc-gateway-hoxton
name: sc-gateway-hoxton
namespace: default
spec:
replicas: 1
selector:
matchLabels:
app: sc-gateway-2023
app: sc-gateway-hoxton
template:
metadata:
labels:
app: sc-gateway-2023
app: sc-gateway-hoxton
annotations:
polarismesh.cn/javaagent: "true"
polarismesh.cn/javaagentVersion: "1.7.0-RC.0"
polarismesh.cn/javaagentVersion: "1.7.0-RC2"
polarismesh.cn/javaagentFrameworkName: "spring-cloud"
polarismesh.cn/javaagentFrameworkVersion: "2023"
polarismesh.cn/javaagentConfig: "{\"spring.cloud.polaris.namespace\": \"default\", \"spring.cloud.polaris.router.nearby-router.matchLevel\": \"campus\"}"
polarismesh.cn/javaagentFrameworkVersion: "hoxton"
spec:
containers:
- image: polarismesh/polaris-javaagent-demo-sc-gray-2023-service-gateway:1.7.0-RC.0-java17
- image: polarismesh/polaris-javaagent-demo-sc-gray-hoxton-service-gateway:1.7.0-java8
imagePullPolicy: Always
name: consumer
resources:
Expand All @@ -35,7 +34,7 @@ spec:
command:
- /bin/bash
- -c
- cd /app && java -Dspring.cloud.nacos.config.server-addr=127.0.0.1:8848 -Dspring.cloud.nacos.config.password=nacos -jar main.jar
- cd /app && java -Dserver.port=65200 -jar main.jar
lifecycle:
preStop:
exec:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<name>hoxton-service-gateway</name>
<description>Demo Service-Gateway Project For Spring Cloud Alibaba 2023</description>
<packaging>jar</packaging>
<version>1.7.0</version>

<dependencyManagement>
<dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ server:

spring:
application:
name: service-gateway-hoxton
name: sc-gateway-hoxton
cloud:
gateway:
discovery:
Expand All @@ -22,7 +22,7 @@ spring:
password: 'nacos'
config:
import:
- nacos:sc-gateway-2023.properties?refreshEnabled=true
- nacos:sc-gateway-hoxton.properties?refreshEnabled=true
management:
endpoint:
health:
Expand Down
Loading

0 comments on commit 52229ed

Please sign in to comment.