build: 配置生产环境构建与Docker部署- 添加Gitea自动构建工作流配置
Some checks failed
Auto-build / Automatic-Packaging (push) Failing after 4m57s
Some checks failed
Auto-build / Automatic-Packaging (push) Failing after 4m57s
- 配置Maven多环境Profile支持(dev/prod) - 移除spring-boot-docker-compose依赖 - 配置Docker镜像构建与运行环境 - 设置JDK17运行环境与CDS优化 - 配置资源文件过滤规则 - 指定构建输出目录与源码路径 - 启用Spring Profile动态配置替换
This commit is contained in:
parent
3ecff3cec3
commit
38cbff11b3
23
.gitea/workflows/auto-build.yaml
Normal file
23
.gitea/workflows/auto-build.yaml
Normal file
@ -0,0 +1,23 @@
|
||||
name: Auto-build
|
||||
run-name: Automatic-Packaging 📦
|
||||
on: [ push ]
|
||||
env:
|
||||
BARE_REPO_DIR: https://git.alina-dace.info/Dace/Animo-Server.git
|
||||
CLONED_REPO_DIR: ./
|
||||
jobs:
|
||||
Automatic-Packaging:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout Git Repo
|
||||
uses: https://git.alina-dace.info/actions/checkout@v4
|
||||
- run: pwd
|
||||
- name: Set up JDK 17
|
||||
uses: https://git.alina-dace.info/actions/setup-java@v4
|
||||
with:
|
||||
java-version: '17'
|
||||
distribution: 'temurin'
|
||||
cache: maven
|
||||
- run: chmod +x ./mvnw
|
||||
- name: build
|
||||
run: ./mvnw clean package -DskipTests=true -P prod
|
||||
- run: docker build -t animo-server:latest ./
|
||||
10
Dockerfile
Normal file
10
Dockerfile
Normal file
@ -0,0 +1,10 @@
|
||||
FROM bellsoft/liberica-openjdk-debian:17.0.11-cds
|
||||
|
||||
LABEL maintainer="Kane / Arina Dace / Sakura Reimi"
|
||||
|
||||
ENV LANG C.UTF-8
|
||||
ENV LC_ALL C.UTF-8
|
||||
|
||||
ADD ./target/animo.jar /app.jar
|
||||
|
||||
ENTRYPOINT exec java -jar /app.jar
|
||||
44
pom.xml
44
pom.xml
@ -26,6 +26,23 @@
|
||||
<tag/>
|
||||
<url/>
|
||||
</scm>
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>dev</id>
|
||||
<properties>
|
||||
<spring.profiles.active>dev</spring.profiles.active>
|
||||
</properties>
|
||||
<activation>
|
||||
<activeByDefault>true</activeByDefault>
|
||||
</activation>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>prod</id>
|
||||
<properties>
|
||||
<spring.profiles.active>prod</spring.profiles.active>
|
||||
</properties>
|
||||
</profile>
|
||||
</profiles>
|
||||
<properties>
|
||||
<java.version>17</java.version>
|
||||
</properties>
|
||||
@ -41,12 +58,6 @@
|
||||
<scope>runtime</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>org.springframework.boot</groupId>-->
|
||||
<!-- <artifactId>spring-boot-docker-compose</artifactId>-->
|
||||
<!-- <scope>runtime</scope>-->
|
||||
<!-- <optional>true</optional>-->
|
||||
<!-- </dependency>-->
|
||||
<dependency>
|
||||
<groupId>com.mysql</groupId>
|
||||
<artifactId>mysql-connector-j</artifactId>
|
||||
@ -91,6 +102,9 @@
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<finalName>${project.artifactId}</finalName>
|
||||
<sourceDirectory>${project.basedir}/src/main/java</sourceDirectory>
|
||||
<testSourceDirectory>${project.basedir}/src/test/java</testSourceDirectory>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
@ -117,6 +131,24 @@
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
<!-- 关闭过滤 -->
|
||||
<filtering>false</filtering>
|
||||
</resource>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
<!-- 引入所有 匹配文件进行过滤 -->
|
||||
<includes>
|
||||
<include>application*</include>
|
||||
<include>bootstrap*</include>
|
||||
<include>banner*</include>
|
||||
</includes>
|
||||
<!-- 启用过滤 即该资源中的变量将会被过滤器中的值替换 -->
|
||||
<filtering>true</filtering>
|
||||
</resource>
|
||||
</resources>
|
||||
</build>
|
||||
|
||||
</project>
|
||||
|
||||
@ -3,7 +3,7 @@ server:
|
||||
|
||||
spring:
|
||||
profiles:
|
||||
active: dev
|
||||
active: @spring.profiles.active@
|
||||
application:
|
||||
name: Animo
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user