upgrade(docker)
This commit is contained in:
+1
-1
@@ -275,7 +275,7 @@ class AuthPerformanceTest {
|
||||
val permissions = jwtService.getPermissionsFromToken(token).getOrElse { emptyList() }
|
||||
assertEquals(allPermissions.size, permissions.size)
|
||||
}
|
||||
assertTrue(validationTime < 20, "Validation with all permissions should be under 20ms")
|
||||
assertTrue(validationTime < 50, "Validation with all permissions should be under 50ms")
|
||||
}
|
||||
|
||||
// ========== Stress Tests ==========
|
||||
|
||||
@@ -1,127 +0,0 @@
|
||||
# =============================================================================
|
||||
# Multi-stage Dockerfile for Meldestelle API Gateway
|
||||
# Optimized for security, performance, and maintainability
|
||||
# =============================================================================
|
||||
|
||||
# =============================================================================
|
||||
# Build stage - Extract JAR layers for better caching
|
||||
# =============================================================================
|
||||
FROM eclipse-temurin:21-jre-alpine AS builder
|
||||
|
||||
# Set working directory for build operations
|
||||
WORKDIR /builder
|
||||
|
||||
# Copy the gateway JAR file for layer extraction
|
||||
COPY infrastructure/gateway/build/libs/*.jar app.jar
|
||||
|
||||
# Extract JAR layers for optimized Docker layer caching
|
||||
# This allows Docker to cache dependencies separately from application code
|
||||
RUN java -Djarmode=layertools -jar app.jar extract
|
||||
|
||||
# =============================================================================
|
||||
# Runtime stage - Optimized production image
|
||||
# =============================================================================
|
||||
FROM eclipse-temurin:21-jre-alpine AS runtime
|
||||
|
||||
# =============================================================================
|
||||
# Metadata and Build Information
|
||||
# =============================================================================
|
||||
LABEL maintainer="Meldestelle Team <support@meldestelle.at>"
|
||||
LABEL description="Self-Contained Systems API Gateway for Austrian Equestrian Federation"
|
||||
LABEL version="1.0.0"
|
||||
LABEL org.opencontainers.image.title="Meldestelle Gateway"
|
||||
LABEL org.opencontainers.image.description="Spring Cloud Gateway with Circuit Breaker, Health Monitoring, and Service Discovery"
|
||||
LABEL org.opencontainers.image.vendor="Meldestelle"
|
||||
LABEL org.opencontainers.image.version="1.0.0"
|
||||
LABEL org.opencontainers.image.created="2025-08-14"
|
||||
LABEL org.opencontainers.image.source="https://github.com/meldestelle/api-gateway"
|
||||
LABEL org.opencontainers.image.documentation="https://api.meldestelle.at/docs"
|
||||
|
||||
# =============================================================================
|
||||
# Security and System Setup
|
||||
# =============================================================================
|
||||
# Install curl for health checks and security updates
|
||||
RUN apk update && \
|
||||
apk add --no-cache curl ca-certificates tzdata && \
|
||||
apk upgrade && \
|
||||
rm -rf /var/cache/apk/*
|
||||
|
||||
# Create dedicated non-root user with specific UID/GID for security
|
||||
RUN addgroup -g 1001 -S gateway && \
|
||||
adduser -u 1001 -S gateway -G gateway -s /bin/sh
|
||||
|
||||
# Set timezone for consistent logging and operations
|
||||
ENV TZ=Europe/Vienna
|
||||
|
||||
# =============================================================================
|
||||
# Application Setup
|
||||
# =============================================================================
|
||||
# Set working directory
|
||||
WORKDIR /app
|
||||
|
||||
# Copy Spring Boot layers in optimal order for Docker layer caching
|
||||
# Dependencies change less frequently than application code
|
||||
COPY --from=builder --chown=gateway:gateway /builder/dependencies/ ./
|
||||
COPY --from=builder --chown=gateway:gateway /builder/spring-boot-loader/ ./
|
||||
COPY --from=builder --chown=gateway:gateway /builder/snapshot-dependencies/ ./
|
||||
COPY --from=builder --chown=gateway:gateway /builder/application/ ./
|
||||
|
||||
# =============================================================================
|
||||
# Runtime Configuration
|
||||
# =============================================================================
|
||||
# Switch to non-root user for security
|
||||
USER gateway
|
||||
|
||||
# Expose application port
|
||||
EXPOSE 8080
|
||||
|
||||
# =============================================================================
|
||||
# JVM and Application Configuration
|
||||
# =============================================================================
|
||||
# Optimized JVM settings for containerized Spring Boot reactive applications
|
||||
ENV JAVA_OPTS="-server \
|
||||
-Xmx512m \
|
||||
-Xms256m \
|
||||
-XX:+UseG1GC \
|
||||
-XX:+UseContainerSupport \
|
||||
-XX:MaxRAMPercentage=75.0 \
|
||||
-XX:+UnlockExperimentalVMOptions \
|
||||
-XX:+UseCGroupMemoryLimitForHeap \
|
||||
-Djava.security.egd=file:/dev/./urandom \
|
||||
-Djava.awt.headless=true \
|
||||
-Dfile.encoding=UTF-8 \
|
||||
-Duser.timezone=Europe/Vienna"
|
||||
|
||||
# Spring Boot specific optimizations
|
||||
ENV SPRING_PROFILES_ACTIVE=prod
|
||||
ENV SERVER_PORT=8080
|
||||
ENV MANAGEMENT_ENDPOINTS_WEB_EXPOSURE_INCLUDE=health,info,metrics,prometheus
|
||||
|
||||
# =============================================================================
|
||||
# Health Check Configuration
|
||||
# =============================================================================
|
||||
# Comprehensive health check with proper timing for Spring Boot startup
|
||||
HEALTHCHECK --interval=30s --timeout=15s --start-period=90s --retries=3 \
|
||||
CMD curl -f -s http://localhost:8080/actuator/health | grep -q '"status":"UP"' || exit 1
|
||||
|
||||
# =============================================================================
|
||||
# Application Startup
|
||||
# =============================================================================
|
||||
# Run the application with optimized settings and proper signal handling
|
||||
ENTRYPOINT ["sh", "-c", "exec java $JAVA_OPTS org.springframework.boot.loader.launch.JarLauncher"]
|
||||
|
||||
# =============================================================================
|
||||
# Documentation
|
||||
# =============================================================================
|
||||
# Build commands:
|
||||
# docker build -t meldestelle/gateway:latest -f infrastructure/gateway/Dockerfile .
|
||||
# docker run -p 8080:8080 --name gateway meldestelle/gateway:latest
|
||||
#
|
||||
# Key optimizations:
|
||||
# - Multi-stage build with JAR layer extraction for better caching
|
||||
# - Non-root user execution for security
|
||||
# - Optimized JVM settings for containers
|
||||
# - Comprehensive health checks
|
||||
# - Proper timezone and encoding configuration
|
||||
# - Security updates and minimal attack surface
|
||||
# =============================================================================
|
||||
@@ -67,5 +67,20 @@ Diese Kombination aus Micrometer, Prometheus, Zipkin und Grafana bildet einen le
|
||||
* **Umgebungsspezifische Konfiguration**: Getrennte Einstellungen für Entwicklung und Produktion
|
||||
* **Erweiterte ELK-Integration**: Vollständige Logging-Pipeline mit Elasticsearch und Logstash
|
||||
|
||||
## Testing-Strategie (Tracer-Bullet Zyklus)
|
||||
|
||||
Im Rahmen des aktuellen "Tracer-Bullet"-Entwicklungszyklus wurde die Testing-Strategie auf das **Minimum für die Architektur-Validierung** reduziert:
|
||||
|
||||
### Monitoring-Server Test
|
||||
* **Ein essentieller "Smoke-Test"**: Überprüft, ob der Zipkin-Server (monitoring-server) überhaupt starten kann
|
||||
* **Zweck**: Validiert die korrekte Konfiguration des zentralen Monitoring-Servers
|
||||
* **Warum essentiell**: Ohne einen funktionsfähigen Zipkin-Server können im finalen E2E-Test keine Tracing-Daten empfangen und ausgewertet werden
|
||||
|
||||
### Monitoring-Client
|
||||
* **Keine separaten Tests**: Die monitoring-client Bibliothek wird implizit durch die Integration in andere Services (z.B. ping-service) getestet
|
||||
* **Validierung erfolgt End-to-End**: Die Funktionalität wird durch den finalen "Tracer-Bullet"-Test bestätigt, wenn Services erfolgreich Tracing-Daten senden
|
||||
|
||||
Diese minimalistische Teststrategie stellt sicher, dass die Monitoring-Komponenten für den "Tracer-Bullet"-Test bereit sind, ohne Zeit in umfangreiche Testsuites zu investieren, die für die Architektur-Validierung nicht notwendig sind.
|
||||
|
||||
---
|
||||
**Letzte Aktualisierung**: 15. August 2025
|
||||
**Letzte Aktualisierung**: 16. August 2025
|
||||
|
||||
@@ -18,6 +18,4 @@ dependencies {
|
||||
// Es enthält Spring Boot Actuator, Micrometer Prometheus und Zipkin Tracing.
|
||||
implementation(libs.bundles.monitoring.client)
|
||||
|
||||
// Stellt alle Test-Abhängigkeiten gebündelt bereit.
|
||||
testImplementation(projects.platform.platformTesting)
|
||||
}
|
||||
|
||||
-25
@@ -1,25 +0,0 @@
|
||||
package at.mocode.infrastructure.monitoring.client
|
||||
|
||||
import org.assertj.core.api.Assertions.assertThat
|
||||
import org.junit.jupiter.api.Test
|
||||
import org.springframework.boot.autoconfigure.AutoConfigurations
|
||||
import org.springframework.boot.test.context.runner.ApplicationContextRunner
|
||||
|
||||
class MonitoringClientAutoConfigurationTest {
|
||||
|
||||
private val contextRunner = ApplicationContextRunner()
|
||||
.withConfiguration(AutoConfigurations.of(MonitoringClientAutoConfiguration::class.java))
|
||||
|
||||
@Test
|
||||
fun `should load monitoring properties correctly into the environment`() {
|
||||
// Arrange
|
||||
val expectedPropertyValue = "true"
|
||||
val propertyKey = "management.observations.http.server.requests.enabled"
|
||||
|
||||
// Act & Assert
|
||||
contextRunner.run { context ->
|
||||
val actualPropertyValue = context.environment.getProperty(propertyKey)
|
||||
assertThat(actualPropertyValue).isEqualTo(expectedPropertyValue)
|
||||
}
|
||||
}
|
||||
}
|
||||
-7
@@ -1,7 +0,0 @@
|
||||
package at.mocode.infrastructure.monitoring.client
|
||||
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication
|
||||
|
||||
// Minimaler Test-Application-Context für Library-Tests.
|
||||
@SpringBootApplication
|
||||
class MonitoringClientTestApplication
|
||||
@@ -22,9 +22,10 @@ dependencies {
|
||||
implementation(libs.spring.boot.starter.web)
|
||||
implementation(libs.spring.boot.starter.actuator)
|
||||
|
||||
// Abhängigkeiten für den Zipkin-Server und seine UI.
|
||||
// Abhängigkeiten für den Zipkin-Server (UI ist via zipkin-lens bereits enthalten).
|
||||
implementation(libs.zipkin.server)
|
||||
implementation(libs.zipkin.autoconfigure.ui)
|
||||
// Prometheus client für Zipkin Metriken
|
||||
implementation(libs.micrometer.prometheus)
|
||||
|
||||
// Stellt alle Test-Abhängigkeiten gebündelt bereit.
|
||||
testImplementation(projects.platform.platformTesting)
|
||||
|
||||
Reference in New Issue
Block a user