Compare commits

...

12 Commits

Author SHA1 Message Date
bamanker
1696261450 本地build fix1
Some checks failed
Build Push and Deploy Image / build (push) Failing after 19s
2025-12-30 10:28:31 +08:00
bamanker
5ca35df955 本地build
Some checks failed
Build Push and Deploy Image / build (push) Failing after 21s
2025-12-30 10:06:49 +08:00
bamanker
21bc585376 修改了deploy参数 2025-12-29 22:58:14 +08:00
bamanker
00684cebf2 修改了runs-on镜像
Some checks failed
Build Push and Deploy Image / build (push) Has been cancelled
2025-12-29 21:45:52 +08:00
bamanker
a29c9c1085 修改了一些问题
Some checks failed
Build Push and Deploy Image / build (push) Failing after 24m59s
2025-12-29 17:43:49 +08:00
bamanker
838e811619 修改了无法找到node的问题
Some checks failed
Build Push and Deploy Image / build (push) Failing after 4m48s
2025-12-29 17:23:04 +08:00
bamanker
e02119c1f3 action环境切换到ubuntu镜像
Some checks failed
Build Push and Deploy Image / build (push) Failing after 7m56s
2025-12-29 16:34:10 +08:00
bamanker
dfe90c96b2 fix build文件
Some checks failed
Build Push and Deploy Image / build (push) Failing after 14s
2025-12-28 22:47:18 +08:00
bamanker
785488505a graalvm native 原生镜像版本
Some checks failed
Build Push and Deploy Image / build (push) Has been cancelled
2025-12-28 22:43:17 +08:00
bamanker
078fdf969e fix readinessProbe http path
All checks were successful
Build Push and Deploy Image / build (push) Successful in 4m35s
2025-12-28 17:08:44 +08:00
bamanker
e428f7a05c fix 2025-12-26 17:49:55 +08:00
bamanker
d694d0f7ab 修复端口号错误
Some checks failed
Build Push and Deploy Image / build (push) Failing after 36s
2025-12-26 17:07:01 +08:00
4 changed files with 60 additions and 19 deletions

View File

@@ -21,12 +21,16 @@ env:
# 构建 Job
jobs:
build:
runs-on: host
runs-on: linux_amd64 # 如果host构建 linux_amd64
steps:
- run: echo " The job was automatically triggered by a ${{ gitea.event_name }} event."
- run: echo " This job is now running on a ${{ runner.os }} server hosted by Gitea!"
- run: echo " The name of your branch is ${{ gitea.ref }} and your repository is ${{ gitea.repository }}."
- run: env
# 下载仓库源码依赖node环境因此构建服务器本地需要下载安装node并设置环境变量
- name: Checkout repository code
#使用自定义仓库action
uses: http://139.9.216.111:3000/bamanker/checkout@v6
uses: http://localhost:3000/bamanker/checkout@v6
# 获取 TAG 并设置为环境变量
- name: Get version
@@ -50,13 +54,20 @@ jobs:
cat ./deployment.yml
# 构建java项目
# - name: Set up Java
# uses: http://localhost:3000/bamanker/setup-java@v5
# with:
# distribution: 'graalvm'
# java-version: '25.0.1'
# cache: 'maven'
- name: Build with Maven
#使用maven绝对路径执行打包命令
run: /usr/local/maven/bin/mvn clean package -DskipTests -Pprod
run: /usr/local/maven/bin/mvn clean native:compile -DskipTests -Pnative
# 登录镜像仓库,方便后续上传镜像
- name: Login to Docker Registry
uses: http://139.9.216.111:3000/bamanker/login-action@v3
uses: http://localhost:3000/bamanker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ secrets.DOCKERHUB_USERNAME }}
@@ -71,7 +82,7 @@ jobs:
# 构建并上传镜像
- name: Build and push Docker image
uses: http://139.9.216.111:3000/bamanker/build-push-action@v6 # 获取上一步截取到的版本号,既 1.0.0
uses: http://localhost:3000/bamanker/build-push-action@v6 # 获取上一步截取到的版本号,既 1.0.0
#只能这样接收
env:
TAG: ${{ steps.set_envar.outputs.tag }}
@@ -82,6 +93,7 @@ jobs:
push: true
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAMESPACE }}/${{ env.IMAGE_NAME }}:${{ env.TAG }}
#发布到 k8s
#发布到 k8s
- name: Generate kubeconfig and deploy
run: kubectl apply -f ./deployment.yml
@@ -90,6 +102,5 @@ jobs:
run: kubectl get pod -n default -l app=${{ env.APP_NAME }}
- name: k8s Update Deployment
run: kubectl rollout restart deployment ${{ env.APP_NAME }}-${{ gitea.ref_name }}
run: kubectl rollout restart deployment ${{ env.APP_NAME }}

View File

@@ -1,7 +1,7 @@
# 基于 java25 构建
FROM swr.cn-north-4.myhuaweicloud.com/ddn-k8s/docker.io/openjdk:25-jdk-slim
FROM ubuntu:jammy
# 基于构建上下文 . 进行COPY 文件到 /root目录下
COPY target/myk3sTest.jar /root/myk3sTest/
COPY target/myk3sTest /root/myk3sTest/
EXPOSE 9090
# 容器启动执行的命令
CMD java -jar -Xms20m -Xmx20m -Dspring.profiles.active=test /root/myk3sTest/myk3sTest.jar
CMD /root/myk3sTest/myk3sTest -XX:StartFlightRecording='filename=recording.jfr,dumponexit=true,duration=10s'

View File

@@ -29,14 +29,15 @@ spec:
- image: $REGISTRY/$IMAGE_NAMESPACE/$IMAGE_NAME:$APP_TAG
name: $APP_NAME
imagePullPolicy: Always
readinessProbe:
livenessProbe: # 存活探针:失败意味着应用彻底挂了,需要重启来恢复
httpGet:
path: /actuator/health
path: /test
port: 9090
initialDelaySeconds: 1
timeoutSeconds: 10
failureThreshold: 30
successThreshold: 5
initialDelaySeconds: 10 # 延迟xx秒开始执行
periodSeconds: 15 # 每隔15秒执行一次
timeoutSeconds: 10 # 10秒未返回结果则超时
failureThreshold: 10 # 探测失败后的重试次数,当达到这个次数后就判定结果为失败
# successThreshold: 5
ports:
- containerPort: 9090
imagePullSecrets:
@@ -56,6 +57,6 @@ spec:
- name: http
protocol: TCP
port: 9090
nodePort: 9090
nodePort: 30909
selector:
app: $APP_NAME

33
pom.xml
View File

@@ -11,7 +11,7 @@
<groupId>com.bamanker</groupId>
<artifactId>myk3sTest</artifactId>
<version>v1.1.9</version>
<version>v3.1-native</version>
<name>myk3sTest</name>
<description>myk3sTest</description>
<url/>
@@ -70,11 +70,40 @@
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.graalvm.buildtools</groupId>
<artifactId>native-maven-plugin</artifactId>
<configuration>
<mainClass>com.bamanker.myk3stest.Myk3sTestApplication</mainClass>
<buildArgs>
<!--开启dashboard-->
<!-- <arg>-H:DashboardDump=dailylove -H:+DashboardAll</arg>-->
<arg->-H:+ReportExceptionStackTraces</arg->
<!--开启JFR-->
<arg>--enable-monitoring=jfr</arg>
<!-- <arg>&#45;&#45;gc=G1</arg>-->
<!-- <arg>&#45;&#45;pgo</arg>-->
<arg>-Ob</arg>
<!-- <arg>-march=native</arg>-->
<!-- <arg>-H:+BuildReport</arg>-->
</buildArgs>
<!--启动详细输出-->
<verbose>true</verbose>
<!--配置jvm参数-->
<!-- <jvmArgs>
</jvmArgs>-->
<!--<agent>
<enabled>true</enabled>
<options>
<option>experimental-class-loader-support</option>
</options>
</agent>-->
</configuration>
</plugin>
<plugin>
<!--支持yaml读取pom的参数-->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>3.2.0</version>
<configuration>
<encoding>UTF-8</encoding>
<delimiters>