Multi-stage Dockerfile: build Maven inside Docker
Build and Deploy / build-and-deploy (push) Failing after 10m48s

This commit is contained in:
2026-06-01 18:16:00 +08:00
parent b61b33f2e3
commit 3de5a1c86a
2 changed files with 11 additions and 11 deletions
-6
View File
@@ -15,12 +15,6 @@ jobs:
git clone http://172.17.0.1:3000/kurihada/auth-backend.git . git clone http://172.17.0.1:3000/kurihada/auth-backend.git .
git checkout ${{ github.sha }} git checkout ${{ github.sha }}
- name: Install Maven
run: apt-get update -qq && apt-get install -y -qq maven
- name: Build with Maven
run: mvn clean install -Dmaven.test.skip=true
- name: Build Docker image - name: Build Docker image
run: docker build -t auth-backend:latest . run: docker build -t auth-backend:latest .
+11 -5
View File
@@ -1,12 +1,18 @@
# 多阶段构建 Dockerfile # Stage 1: Build with Maven
# 阶段1: 构建 FROM openjdk:21 AS builder
WORKDIR /app
COPY pom.xml .
COPY src ./src
RUN apt-get update && apt-get install -y maven && mvn clean install -Dmaven.test.skip=true
# Stage 2: Runtime
FROM openjdk:21 FROM openjdk:21
WORKDIR /app WORKDIR /app
COPY --from=builder /app/target/auth-backend-1.0.0.jar /app/
COPY target/auth-backend-1.0.0.jar /app/
EXPOSE 9001 EXPOSE 9001
# 启动应用
CMD ["java", "-jar", "auth-backend-1.0.0.jar"] CMD ["java", "-jar", "auth-backend-1.0.0.jar"]