fixing(gateway)
This commit is contained in:
+1
-1
@@ -20,7 +20,7 @@ class PingService(private val baseUrl: String = "http://localhost:8080") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
suspend fun ping(): Result<PingResponse> = try {
|
suspend fun ping(): Result<PingResponse> = try {
|
||||||
val response = client.get("$baseUrl/ping-service/ping").body<PingResponse>()
|
val response = client.get("$baseUrl/api/ping/ping").body<PingResponse>()
|
||||||
Result.success(response)
|
Result.success(response)
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
Result.failure(e)
|
Result.failure(e)
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ fun App(baseUrl: String = "http://localhost:8080") {
|
|||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun PingScreen(baseUrl: String) {
|
fun PingScreen(baseUrl: String) {
|
||||||
val pingComponent = remember { PingTestComponent() }
|
val pingComponent = remember { PingTestComponent(baseUrl) }
|
||||||
var pingState by remember { mutableStateOf(pingComponent.state) }
|
var pingState by remember { mutableStateOf(pingComponent.state) }
|
||||||
|
|
||||||
LaunchedEffect(pingComponent) {
|
LaunchedEffect(pingComponent) {
|
||||||
|
|||||||
+2
-2
@@ -11,8 +11,8 @@ data class PingTestState(
|
|||||||
val isConnected: Boolean = false
|
val isConnected: Boolean = false
|
||||||
)
|
)
|
||||||
|
|
||||||
class PingTestComponent {
|
class PingTestComponent(baseUrl: String = "http://localhost:8080") {
|
||||||
private val pingService = PingService()
|
private val pingService = PingService(baseUrl)
|
||||||
private val scope = CoroutineScope(Dispatchers.Main + SupervisorJob())
|
private val scope = CoroutineScope(Dispatchers.Main + SupervisorJob())
|
||||||
|
|
||||||
var state: PingTestState = PingTestState()
|
var state: PingTestState = PingTestState()
|
||||||
|
|||||||
@@ -15,7 +15,11 @@ fun main() {
|
|||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun MeldestelleWebApp() {
|
fun MeldestelleWebApp() {
|
||||||
val pingComponent = remember { PingTestComponent() }
|
// Get baseUrl from a window location or use default
|
||||||
|
val baseUrl = remember {
|
||||||
|
js("window.location.origin").toString().ifEmpty { "http://localhost:8080" }
|
||||||
|
}
|
||||||
|
val pingComponent = remember { PingTestComponent(baseUrl) }
|
||||||
var pingState by remember { mutableStateOf(pingComponent.state) }
|
var pingState by remember { mutableStateOf(pingComponent.state) }
|
||||||
|
|
||||||
LaunchedEffect(pingComponent) {
|
LaunchedEffect(pingComponent) {
|
||||||
|
|||||||
+2
-2
@@ -209,7 +209,7 @@ services:
|
|||||||
retries: 3
|
retries: 3
|
||||||
start_period: 15s
|
start_period: 15s
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
# Security: Run as non-root user
|
# Security: Run as a non-root user
|
||||||
user: "65534:65534"
|
user: "65534:65534"
|
||||||
# Resource limits for development
|
# Resource limits for development
|
||||||
deploy:
|
deploy:
|
||||||
@@ -242,7 +242,7 @@ services:
|
|||||||
retries: 3
|
retries: 3
|
||||||
start_period: 20s
|
start_period: 20s
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
# Security: Run as non-root user
|
# Security: Run as a non-root user
|
||||||
user: "472:472"
|
user: "472:472"
|
||||||
# Resource limits for development
|
# Resource limits for development
|
||||||
deploy:
|
deploy:
|
||||||
|
|||||||
+1
-1
@@ -79,7 +79,7 @@ class JwtService(
|
|||||||
permissionStrings?.mapNotNull {
|
permissionStrings?.mapNotNull {
|
||||||
try {
|
try {
|
||||||
BerechtigungE.valueOf(it)
|
BerechtigungE.valueOf(it)
|
||||||
} catch (e: Exception) {
|
} catch (_: Exception) {
|
||||||
null
|
null
|
||||||
}
|
}
|
||||||
} ?: emptyList()
|
} ?: emptyList()
|
||||||
|
|||||||
-1
@@ -8,7 +8,6 @@ import com.fasterxml.jackson.databind.SerializationFeature
|
|||||||
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule
|
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule
|
||||||
import com.fasterxml.jackson.module.kotlin.KotlinModule
|
import com.fasterxml.jackson.module.kotlin.KotlinModule
|
||||||
import org.slf4j.LoggerFactory
|
import org.slf4j.LoggerFactory
|
||||||
import java.util.UUID
|
|
||||||
import java.util.concurrent.ConcurrentHashMap
|
import java.util.concurrent.ConcurrentHashMap
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
+3
-2
@@ -1,10 +1,11 @@
|
|||||||
package at.mocode.infrastructure.eventstore.redis
|
package at.mocode.infrastructure.eventstore.redis
|
||||||
|
|
||||||
import at.mocode.core.domain.event.BaseDomainEvent
|
import at.mocode.core.domain.event.BaseDomainEvent
|
||||||
import at.mocode.core.domain.model.*
|
import at.mocode.core.domain.model.AggregateId
|
||||||
|
import at.mocode.core.domain.model.EventType
|
||||||
|
import at.mocode.core.domain.model.EventVersion
|
||||||
import at.mocode.infrastructure.eventstore.api.ConcurrencyException
|
import at.mocode.infrastructure.eventstore.api.ConcurrencyException
|
||||||
import at.mocode.infrastructure.eventstore.api.EventSerializer
|
import at.mocode.infrastructure.eventstore.api.EventSerializer
|
||||||
import com.benasher44.uuid.Uuid
|
|
||||||
import com.benasher44.uuid.uuid4
|
import com.benasher44.uuid.uuid4
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
import kotlinx.serialization.Transient
|
import kotlinx.serialization.Transient
|
||||||
|
|||||||
+3
-2
@@ -2,10 +2,11 @@ package at.mocode.infrastructure.eventstore.redis
|
|||||||
|
|
||||||
import at.mocode.core.domain.event.BaseDomainEvent
|
import at.mocode.core.domain.event.BaseDomainEvent
|
||||||
import at.mocode.core.domain.event.DomainEvent
|
import at.mocode.core.domain.event.DomainEvent
|
||||||
import at.mocode.core.domain.model.*
|
import at.mocode.core.domain.model.AggregateId
|
||||||
|
import at.mocode.core.domain.model.EventType
|
||||||
|
import at.mocode.core.domain.model.EventVersion
|
||||||
import at.mocode.infrastructure.eventstore.api.EventSerializer
|
import at.mocode.infrastructure.eventstore.api.EventSerializer
|
||||||
import at.mocode.infrastructure.eventstore.api.EventStore
|
import at.mocode.infrastructure.eventstore.api.EventStore
|
||||||
import com.benasher44.uuid.Uuid
|
|
||||||
import com.benasher44.uuid.uuid4
|
import com.benasher44.uuid.uuid4
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
import kotlinx.serialization.Transient
|
import kotlinx.serialization.Transient
|
||||||
|
|||||||
+1
-1
@@ -57,7 +57,7 @@ class GatewaySecurityTests {
|
|||||||
|
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
fun setUpClient() {
|
fun setUpClient() {
|
||||||
// Ensure absolute base URL with scheme to satisfy CORS processor
|
// Ensure absolute base URL with a scheme to satisfy the CORS processor
|
||||||
webTestClient = webTestClient.mutate()
|
webTestClient = webTestClient.mutate()
|
||||||
.baseUrl("http://localhost:$port")
|
.baseUrl("http://localhost:$port")
|
||||||
.build()
|
.build()
|
||||||
|
|||||||
@@ -1,18 +1,29 @@
|
|||||||
# syntax=docker/dockerfile:1
|
# syntax=docker/dockerfile:1
|
||||||
|
|
||||||
# Build stage: compile the ping-service JAR inside Docker
|
# Build stage: compile the ping-service JAR inside Docker
|
||||||
FROM gradle:8.7-jdk17-alpine AS builder
|
FROM gradle:8.14-jdk21-alpine AS builder
|
||||||
WORKDIR /workspace
|
WORKDIR /workspace
|
||||||
|
|
||||||
# Copy the entire repository (simplest and most robust for multi-module setups)
|
# Enable Gradle build cache and daemon for faster builds
|
||||||
# This allows building the ping-service even if it depends on shared build files or platforms.
|
ENV GRADLE_OPTS="-Dorg.gradle.caching=true -Dorg.gradle.daemon=false"
|
||||||
COPY . .
|
|
||||||
|
# Copy gradle files first for better layer caching
|
||||||
|
COPY gradle/ gradle/
|
||||||
|
COPY gradlew gradlew.bat gradle.properties settings.gradle.kts ./
|
||||||
|
COPY build.gradle.kts ./
|
||||||
|
COPY platform/ platform/
|
||||||
|
|
||||||
|
# Copy only necessary source files for the ping-service and its dependencies
|
||||||
|
COPY temp/ping-service/ temp/ping-service/
|
||||||
|
|
||||||
|
# Download dependencies first (better caching)
|
||||||
|
RUN gradle :temp:ping-service:dependencies --no-daemon
|
||||||
|
|
||||||
# Build only the ping-service artifact
|
# Build only the ping-service artifact
|
||||||
RUN gradle :temp:ping-service:bootJar --no-daemon
|
RUN gradle :temp:ping-service:bootJar --no-daemon
|
||||||
|
|
||||||
# Runtime stage: slim JRE image to run the service
|
# Runtime stage: slim JRE image to run the service
|
||||||
FROM eclipse-temurin:17-jre-alpine
|
FROM eclipse-temurin:21-jre-alpine
|
||||||
|
|
||||||
# Set working directory
|
# Set working directory
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
@@ -22,20 +33,28 @@ RUN apk add --no-cache curl
|
|||||||
|
|
||||||
# Create a non-root user for better security
|
# Create a non-root user for better security
|
||||||
RUN addgroup -S app && adduser -S app -G app
|
RUN addgroup -S app && adduser -S app -G app
|
||||||
USER app
|
|
||||||
|
|
||||||
# Copy the built JAR from the builder stage
|
# Copy the built JAR from the builder stage
|
||||||
COPY --from=builder /workspace/temp/ping-service/build/libs/*.jar app.jar
|
COPY --from=builder --chown=app:app /workspace/temp/ping-service/build/libs/*.jar app.jar
|
||||||
|
|
||||||
|
# Switch to non-root user
|
||||||
|
USER app
|
||||||
|
|
||||||
# Expose application port
|
# Expose application port
|
||||||
EXPOSE 8082
|
EXPOSE 8082
|
||||||
|
|
||||||
# Health check against the ping endpoint
|
# Health check against the actuator health endpoint
|
||||||
HEALTHCHECK --interval=30s --timeout=5s --start-period=20s --retries=3 \
|
HEALTHCHECK --interval=30s --timeout=5s --start-period=30s --retries=3 \
|
||||||
CMD curl -fsS http://localhost:8082/ping || exit 1
|
CMD curl -fsS http://localhost:8082/actuator/health || exit 1
|
||||||
|
|
||||||
# JVM options can be overridden at runtime via JAVA_OPTS env
|
# Enhanced JVM options for containerized Spring Boot applications
|
||||||
ENV JAVA_OPTS="-XX:MaxRAMPercentage=75.0 -XX:+UseStringDeduplication"
|
ENV JAVA_OPTS="-XX:MaxRAMPercentage=75.0 \
|
||||||
|
-XX:+UseStringDeduplication \
|
||||||
|
-XX:+UseG1GC \
|
||||||
|
-XX:+UseContainerSupport \
|
||||||
|
-XX:+OptimizeStringConcat \
|
||||||
|
-Djava.security.egd=file:/dev/./urandom \
|
||||||
|
-Dspring.jmx.enabled=false"
|
||||||
|
|
||||||
# Run the application
|
# Run the application
|
||||||
ENTRYPOINT ["sh", "-c", "exec java $JAVA_OPTS -jar app.jar"]
|
ENTRYPOINT ["sh", "-c", "exec java $JAVA_OPTS -jar app.jar"]
|
||||||
|
|||||||
Reference in New Issue
Block a user