This commit is contained in:
史悦
2025-09-12 14:03:25 +08:00
parent 8708378117
commit 3e06ed643e

View File

@@ -1,27 +1,20 @@
# Stage 1: Build the Flutter web client
FROM cirrusci/flutter:3.3.0 as flutter_builder
WORKDIR /app
FROM ghcr.io/cirruslabs/flutter:3.22.2 as flutter_builder
# Copy Flutter project files
COPY AINoval/pubspec.yaml AINoval/pubspec.lock ./
# Copy Flutter project
COPY AINoval/ /flutter_app/
WORKDIR /flutter_app
# Get dependencies and build
RUN flutter pub get
# Copy the rest of the Flutter project source code
COPY AINoval/ ./
# Build the Flutter web application
RUN flutter build web --release --web-renderer canvaskit
# Stage 2: Build the Java Spring Boot server
FROM maven:3.9-eclipse-temurin-21 as java_builder
WORKDIR /app
# Copy only the pom.xml to leverage Docker cache for dependencies
COPY AINovalServer/pom.xml ./
RUN mvn dependency:go-offline
# Copy the rest of the server source code
COPY AINovalServer/ ./
# Copy Java project
COPY AINovalServer/ /java_app/
WORKDIR /java_app
# Build the application, skipping tests to speed up the process
RUN mvn clean package -DskipTests
@@ -42,10 +35,10 @@ ENV JAVA_TOOL_OPTIONS="--add-opens=java.base/java.math=ALL-UNNAMED --add-opens=j
WORKDIR /app
# Copy the server jar from the java_builder stage and rename it
COPY --from=java_builder /app/target/ai-novel-server-0.0.1-SNAPSHOT.jar /app/ainoval-server.jar
COPY --from=java_builder /java_app/target/ai-novel-server-0.0.1-SNAPSHOT.jar /app/ainoval-server.jar
# Copy the built web assets from the flutter_builder stage
COPY --from=flutter_builder /app/build/web/ /app/web/
COPY --from=flutter_builder /flutter_app/build/web/ /app/web/
EXPOSE 18080