Docker Fixes
This commit is contained in:
parent
ac53f04e0a
commit
8f797a51f1
5 changed files with 69 additions and 6 deletions
|
|
@ -44,7 +44,7 @@ services:
|
||||||
SPRING_JPA_HIBERNATE_DDL_AUTO: validate
|
SPRING_JPA_HIBERNATE_DDL_AUTO: validate
|
||||||
SPRING_JPA_SHOW_SQL: ${JPA_SHOW_SQL:-false}
|
SPRING_JPA_SHOW_SQL: ${JPA_SHOW_SQL:-false}
|
||||||
SPRING_JPA_PROPERTIES_HIBERNATE_FORMAT_SQL: ${JPA_FORMAT_SQL:-false}
|
SPRING_JPA_PROPERTIES_HIBERNATE_FORMAT_SQL: ${JPA_FORMAT_SQL:-false}
|
||||||
SPRING_JPA_PROPERTIES_HIBERNATE_DIALECT: org.hibernate.spatial.dialect.postgis.PostgisDialect
|
SPRING_JPA_PROPERTIES_HIBERNATE_DIALECT: org.hibernate.dialect.PostgreSQLDialect
|
||||||
|
|
||||||
# Flyway Configuration
|
# Flyway Configuration
|
||||||
SPRING_FLYWAY_ENABLED: true
|
SPRING_FLYWAY_ENABLED: true
|
||||||
|
|
@ -55,8 +55,8 @@ services:
|
||||||
SERVER_PORT: ${APP_PORT:-8080}
|
SERVER_PORT: ${APP_PORT:-8080}
|
||||||
|
|
||||||
# Application Configuration
|
# Application Configuration
|
||||||
APP_DOMAIN: ${APP_DOMAIN}
|
FITPUB_DOMAIN: ${APP_DOMAIN}
|
||||||
APP_BASE_URL: ${APP_BASE_URL}
|
FITPUB_BASE_URL: ${APP_BASE_URL}
|
||||||
|
|
||||||
# Security Configuration
|
# Security Configuration
|
||||||
JWT_SECRET: ${JWT_SECRET}
|
JWT_SECRET: ${JWT_SECRET}
|
||||||
|
|
|
||||||
22
pom.xml
22
pom.xml
|
|
@ -78,6 +78,7 @@
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- Testcontainers for Dev Services -->
|
<!-- Testcontainers for Dev Services -->
|
||||||
|
<!-- These are excluded from production builds via Maven profile -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-testcontainers</artifactId>
|
<artifactId>spring-boot-testcontainers</artifactId>
|
||||||
|
|
@ -173,6 +174,27 @@
|
||||||
<groupId>org.projectlombok</groupId>
|
<groupId>org.projectlombok</groupId>
|
||||||
<artifactId>lombok</artifactId>
|
<artifactId>lombok</artifactId>
|
||||||
</exclude>
|
</exclude>
|
||||||
|
<!-- Exclude Testcontainers from production JAR -->
|
||||||
|
<exclude>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-testcontainers</artifactId>
|
||||||
|
</exclude>
|
||||||
|
<exclude>
|
||||||
|
<groupId>org.testcontainers</groupId>
|
||||||
|
<artifactId>testcontainers</artifactId>
|
||||||
|
</exclude>
|
||||||
|
<exclude>
|
||||||
|
<groupId>org.testcontainers</groupId>
|
||||||
|
<artifactId>postgresql</artifactId>
|
||||||
|
</exclude>
|
||||||
|
<exclude>
|
||||||
|
<groupId>org.testcontainers</groupId>
|
||||||
|
<artifactId>jdbc</artifactId>
|
||||||
|
</exclude>
|
||||||
|
<exclude>
|
||||||
|
<groupId>org.testcontainers</groupId>
|
||||||
|
<artifactId>database-commons</artifactId>
|
||||||
|
</exclude>
|
||||||
</excludes>
|
</excludes>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
package org.operaton.fitpub.config;
|
package org.operaton.fitpub.config;
|
||||||
|
|
||||||
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||||
import org.springframework.boot.testcontainers.service.connection.ServiceConnection;
|
import org.springframework.boot.testcontainers.service.connection.ServiceConnection;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
@ -13,10 +14,11 @@ import org.testcontainers.utility.DockerImageName;
|
||||||
*
|
*
|
||||||
* This ensures development environment matches production (PostgreSQL + PostGIS).
|
* This ensures development environment matches production (PostgreSQL + PostGIS).
|
||||||
*
|
*
|
||||||
* Only active when NOT running in production profile.
|
* Only active when NOT running in production profile AND Testcontainers is on the classpath.
|
||||||
*/
|
*/
|
||||||
@Configuration(proxyBeanMethods = false)
|
@Configuration(proxyBeanMethods = false)
|
||||||
@Profile("!prod")
|
@Profile("!prod")
|
||||||
|
@ConditionalOnClass(PostgreSQLContainer.class)
|
||||||
public class TestcontainersConfiguration {
|
public class TestcontainersConfiguration {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -262,7 +262,35 @@ public class ActivityController {
|
||||||
// Build GeoJSON FeatureCollection
|
// Build GeoJSON FeatureCollection
|
||||||
ActivityDTO dto = ActivityDTO.fromEntity(activity);
|
ActivityDTO dto = ActivityDTO.fromEntity(activity);
|
||||||
|
|
||||||
if (dto.getSimplifiedTrack() == null) {
|
// Use high-resolution track points if available, otherwise fall back to simplified track
|
||||||
|
java.util.List<java.util.List<Double>> coordinates = new java.util.ArrayList<>();
|
||||||
|
|
||||||
|
if (dto.getTrackPoints() != null && !dto.getTrackPoints().isEmpty()) {
|
||||||
|
// Use high-resolution track points
|
||||||
|
for (java.util.Map<String, Object> point : dto.getTrackPoints()) {
|
||||||
|
Double longitude = (Double) point.get("longitude");
|
||||||
|
Double latitude = (Double) point.get("latitude");
|
||||||
|
Double elevation = (Double) point.get("elevation");
|
||||||
|
|
||||||
|
if (longitude != null && latitude != null) {
|
||||||
|
if (elevation != null) {
|
||||||
|
coordinates.add(java.util.List.of(longitude, latitude, elevation));
|
||||||
|
} else {
|
||||||
|
coordinates.add(java.util.List.of(longitude, latitude));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (dto.getSimplifiedTrack() != null) {
|
||||||
|
// Fall back to simplified track if high-res not available
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
java.util.List<java.util.List<Double>> simplifiedCoords =
|
||||||
|
(java.util.List<java.util.List<Double>>) dto.getSimplifiedTrack().get("coordinates");
|
||||||
|
if (simplifiedCoords != null) {
|
||||||
|
coordinates = simplifiedCoords;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (coordinates.isEmpty()) {
|
||||||
// Return empty FeatureCollection if no track data
|
// Return empty FeatureCollection if no track data
|
||||||
return ResponseEntity.ok(java.util.Map.of(
|
return ResponseEntity.ok(java.util.Map.of(
|
||||||
"type", "FeatureCollection",
|
"type", "FeatureCollection",
|
||||||
|
|
@ -270,10 +298,15 @@ public class ActivityController {
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Create GeoJSON geometry
|
||||||
|
java.util.Map<String, Object> geometry = new java.util.LinkedHashMap<>();
|
||||||
|
geometry.put("type", "LineString");
|
||||||
|
geometry.put("coordinates", coordinates);
|
||||||
|
|
||||||
// Create GeoJSON Feature with the track
|
// Create GeoJSON Feature with the track
|
||||||
java.util.Map<String, Object> feature = new java.util.LinkedHashMap<>();
|
java.util.Map<String, Object> feature = new java.util.LinkedHashMap<>();
|
||||||
feature.put("type", "Feature");
|
feature.put("type", "Feature");
|
||||||
feature.put("geometry", dto.getSimplifiedTrack());
|
feature.put("geometry", geometry);
|
||||||
|
|
||||||
// Add properties
|
// Add properties
|
||||||
java.util.Map<String, Object> properties = new java.util.LinkedHashMap<>();
|
java.util.Map<String, Object> properties = new java.util.LinkedHashMap<>();
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,12 @@
|
||||||
# Activated with: java -jar fitpub.jar --spring.profiles.active=prod
|
# Activated with: java -jar fitpub.jar --spring.profiles.active=prod
|
||||||
|
|
||||||
spring:
|
spring:
|
||||||
|
# Disable Testcontainers auto-configuration in production
|
||||||
|
autoconfigure:
|
||||||
|
exclude:
|
||||||
|
- org.springframework.boot.testcontainers.service.connection.ContainerConnectionDetailsAutoConfiguration
|
||||||
|
- org.springframework.boot.testcontainers.lifecycle.TestcontainersLifecycleBeanPostProcessor
|
||||||
|
|
||||||
# Production datasource - must be configured via environment variables
|
# Production datasource - must be configured via environment variables
|
||||||
datasource:
|
datasource:
|
||||||
url: ${SPRING_DATASOURCE_URL}
|
url: ${SPRING_DATASOURCE_URL}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue