eeg_portal/Dockerfile
Bernhard Müller 975f76dbd3 feat(community): add metering data upload and query with XLSX support
Implement complete metering data management for energy communities:

- MeteringData entity with unique constraint (metering_point_id, interval_start, data_type)
- Bulk upload via JSON or XLSX (multipart) with validation
- XLSX parser using Apache POI with comma-decimal support
- Ownership check on GET endpoints (userId must match metering point owner)
- Deduplication: existing records overwritten on re-upload
- DataSource tracking (EMAIL_XLSX, API, MANUAL)
- Query endpoints: by metering point, by type, by upload batch

Additional fixes:
- MapStruct annotation processor: add to execution-level annotationProcessorPaths
  (Spring Boot parent POM was overriding plugin-level config)
- EnergyCommunityMapper + MeteringDataMapper: componentModel=spring
- UserMapper: ignore passwordResetToken/Expiry (unmapped target policy ERROR)
- TariffService: add TariffInviteRepository dependency + invitation check
- TariffServiceTest: add missing @Mock for TariffInviteRepository
- SecurityConfig: permit /actuator/health and /actuator/info
- pom.xml: add poi-ooxml, postgresql, spring-boot-starter-actuator
- .gitignore: add *.log, survey/, backend.log

Tests: 137/137 passing
2026-07-22 12:42:27 +02:00

69 lines
2.0 KiB
Docker

# ============================================================
# EEG Portal - Multi-stage Docker Build
# Stage 1: Frontend (Node) -> Stage 2: Backend (Maven) -> Stage 3: Runtime (JRE)
# ============================================================
# ---- Stage 1: Build Angular Frontend ----
FROM node:24-slim AS frontend-build
WORKDIR /app/eeg_frontend
COPY eeg_frontend/package.json eeg_frontend/package-lock.json* ./
RUN npm ci --prefer-offline
COPY eeg_frontend/ ./
RUN npm run build -- --configuration production
# ---- Stage 2: Build Spring Boot Backend ----
FROM maven:3.9-eclipse-temurin-21 AS backend-build
WORKDIR /app
# Copy parent POM and module POMs first (dependency caching)
COPY pom.xml ./
COPY eeg_backend/pom.xml eeg_backend/
COPY eeg_frontend/pom.xml eeg_frontend/
# Download dependencies (cached unless POMs change)
RUN mvn dependency:go-offline -pl eeg_backend -am -B
# Copy source code
COPY eeg_backend/src eeg_backend/src
# Copy Angular build output into Spring Boot static resources
COPY --from=frontend-build /app/eeg_frontend/dist/eeg_frontend/browser/ eeg_backend/src/main/resources/static/
# Build the backend JAR (skip tests in Docker)
RUN mvn package -pl eeg_backend -am -DskipTests -B
# ---- Stage 3: Runtime ----
FROM eclipse-temurin:21-jre-jammy
WORKDIR /app
# Install curl for health check
RUN apt-get update && apt-get install -y --no-install-recommends curl && rm -rf /var/lib/apt/lists/*
# Create non-root user
RUN groupadd -r eeg && useradd -r -g eeg -d /app -s /sbin/nologin eeg
# Copy the built JAR
COPY --from=backend-build /app/eeg_backend/target/*.jar app.jar
# Set ownership
RUN chown -R eeg:eeg /app
USER eeg
EXPOSE 8080
HEALTHCHECK --interval=30s --timeout=5s --start-period=60s --retries=3 \
CMD curl -f http://localhost:8080/actuator/health || exit 1
ENTRYPOINT ["java", \
"-XX:+UseContainerSupport", \
"-XX:MaxRAMPercentage=75.0", \
"-Djava.security.egd=file:/dev/./urandom", \
"-jar", "app.jar", \
"--spring.profiles.active=prod"]