fix .
This commit is contained in:
+19
-20
@@ -1,29 +1,28 @@
|
||||
# 1. Этап сборки
|
||||
FROM eclipse-temurin:26-jdk-alpine AS build
|
||||
# --- Этап 1: Сборка Angular ---
|
||||
FROM node:20-alpine AS frontend-builder
|
||||
WORKDIR /app/ui
|
||||
COPY spring-angular-ui/package*.json ./
|
||||
RUN npm ci
|
||||
COPY spring-angular-ui/ ./
|
||||
ENV NODE_OPTIONS="--max-old-space-size=2048"
|
||||
RUN npx ng build --configuration=production
|
||||
|
||||
# --- Этап 2: Сборка Java (Gradle) ---
|
||||
FROM eclipse-temurin:21-jdk-alpine AS backend-builder
|
||||
WORKDIR /app
|
||||
COPY gradlew .
|
||||
COPY gradle gradle
|
||||
COPY build.gradle settings.gradle ./
|
||||
RUN ./gradlew dependencies --no-daemon
|
||||
|
||||
# Устанавливаем Node.js и npm
|
||||
RUN apk add --no-cache nodejs npm curl bash
|
||||
|
||||
# Копируем весь проект (включая папку spring-angular-ui)
|
||||
COPY . .
|
||||
|
||||
# Даем права на выполнение Gradle Wrapper
|
||||
RUN chmod +x gradlew
|
||||
|
||||
# Запускаем сборку Angular и упаковку Spring Boot
|
||||
RUN ./gradlew copyAngularBuild -x test --no-daemon
|
||||
# Копируем уже собранный фронтенд в static
|
||||
COPY --from=frontend-builder /app/ui/dist/spring-angular-ui /app/src/main/resources/static
|
||||
RUN ./gradlew bootJar -x test --no-daemon
|
||||
|
||||
# 2. Финальный образ
|
||||
FROM eclipse-temurin:26-jre-alpine
|
||||
|
||||
# --- Этап 3: Финальный образ ---
|
||||
FROM eclipse-temurin:21-jre-alpine
|
||||
WORKDIR /app
|
||||
|
||||
# Копируем собранный JAR
|
||||
COPY --from=build /app/build/libs/*.jar app.jar
|
||||
|
||||
COPY --from=backend-builder /app/build/libs/*.jar app.jar
|
||||
EXPOSE 8080
|
||||
|
||||
ENTRYPOINT ["java", "-jar", "app.jar"]
|
||||
Reference in New Issue
Block a user