diff --git a/Dockerfile b/Dockerfile index 3f863e3..58c1781 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ # Stage that builds the application, a prerequisite for the running stage -FROM eclipse-temurin:21-jdk-jammy AS build +FROM eclipse-temurin:21-jdk-noble AS build ARG SERVICE_ROOT @@ -22,7 +22,7 @@ COPY --chown=app:app ${SERVICE_ROOT}/src ./src RUN ./mvnw --batch-mode clean verify -DskipTests # Running stage: the part that is used for running the application -FROM eclipse-temurin:21-jre-jammy +FROM eclipse-temurin:21-jre-noble RUN useradd -m app USER app diff --git a/pom.xml b/pom.xml index b5012b7..64d5cc2 100644 --- a/pom.xml +++ b/pom.xml @@ -83,6 +83,11 @@ caffeine 3.1.2 + + org.springdoc + springdoc-openapi-starter-webmvc-ui + 2.6.0 + diff --git a/src/main/java/dev/mars3142/fhq/timezone_service/config/OpenAPIConfig.java b/src/main/java/dev/mars3142/fhq/timezone_service/config/OpenAPIConfig.java new file mode 100644 index 0000000..a098464 --- /dev/null +++ b/src/main/java/dev/mars3142/fhq/timezone_service/config/OpenAPIConfig.java @@ -0,0 +1,24 @@ +package dev.mars3142.fhq.timezone_service.config; + +import io.swagger.v3.oas.models.OpenAPI; +import io.swagger.v3.oas.models.info.Info; +import io.swagger.v3.oas.models.servers.Server; +import java.util.List; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +@Configuration +public class OpenAPIConfig { + + @Bean + public OpenAPI timeZoneOpenAPI() { + return new OpenAPI() + .info(new Info().title("TimeZone API").version("1.0")) + .servers( + List.of( + new Server().url("https://api.firmware-hq.dev/v1/timezone"), + new Server().url("http://localhost:8090") + ) + ); + } +} diff --git a/src/main/java/dev/mars3142/fhq/timezone_service/config/WebConfig.java b/src/main/java/dev/mars3142/fhq/timezone_service/config/WebConfig.java new file mode 100644 index 0000000..ae79289 --- /dev/null +++ b/src/main/java/dev/mars3142/fhq/timezone_service/config/WebConfig.java @@ -0,0 +1,16 @@ +package dev.mars3142.fhq.timezone_service.config; + +import org.springframework.context.annotation.Configuration; +import org.springframework.web.servlet.config.annotation.CorsRegistry; +import org.springframework.web.servlet.config.annotation.EnableWebMvc; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; + +@Configuration +@EnableWebMvc +public class WebConfig implements WebMvcConfigurer { + + @Override + public void addCorsMappings(CorsRegistry registry) { + registry.addMapping("/**"); + } +} diff --git a/src/main/java/dev/mars3142/fhq/timezone_service/root/web/controller/RootController.java b/src/main/java/dev/mars3142/fhq/timezone_service/root/web/controller/RootController.java deleted file mode 100644 index 48f3c1f..0000000 --- a/src/main/java/dev/mars3142/fhq/timezone_service/root/web/controller/RootController.java +++ /dev/null @@ -1,21 +0,0 @@ -package dev.mars3142.fhq.timezone_service.root.web.controller; - -import java.net.URI; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -@RestController -@RequestMapping("/") -public class RootController { - - @GetMapping - public ResponseEntity getRoot() { - return ResponseEntity.status(HttpStatus.SEE_OTHER) - .location(URI.create("https://firmware-hq.dev")) - .build(); - } - -} diff --git a/src/main/resources/application-dev.yaml b/src/main/resources/application-dev.yaml index 3e8faa9..b882783 100644 --- a/src/main/resources/application-dev.yaml +++ b/src/main/resources/application-dev.yaml @@ -1,5 +1,5 @@ server: - port: 8085 + port: 0 eureka: client: diff --git a/src/main/resources/application.yaml b/src/main/resources/application.yaml index 58f84e8..931b367 100644 --- a/src/main/resources/application.yaml +++ b/src/main/resources/application.yaml @@ -24,3 +24,6 @@ eureka: defaultZone: http://eureka-service.web:8761/eureka instance: instanceId: ${spring.application.name}:${spring.application.instance_id:${random.value}} +springdoc: + swagger-ui: + path: /swagger-ui.html