trivial implementation to test cloud run
Signed-off-by: Peter Siegmund <developer@mars3142.org>
This commit is contained in:
9
.run/Application.run.xml
Normal file
9
.run/Application.run.xml
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
<component name="ProjectRunConfigurationManager">
|
||||||
|
<configuration default="false" name="Application" type="SpringBootApplicationConfigurationType" factoryName="Spring Boot">
|
||||||
|
<module name="timezone-service" />
|
||||||
|
<option name="SPRING_BOOT_MAIN_CLASS" value="dev.mars3142.fhq.timezone_service.Application" />
|
||||||
|
<method v="2">
|
||||||
|
<option name="Make" enabled="true" />
|
||||||
|
</method>
|
||||||
|
</configuration>
|
||||||
|
</component>
|
33
Dockerfile
Normal file
33
Dockerfile
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
# Stage that builds the application, a prerequisite for the running stage
|
||||||
|
FROM eclipse-temurin:21-jdk-jammy as build
|
||||||
|
|
||||||
|
ARG SERVICE_ROOT
|
||||||
|
|
||||||
|
RUN apt-get update -qq
|
||||||
|
|
||||||
|
# Stop running as root at this point
|
||||||
|
RUN useradd -m app
|
||||||
|
WORKDIR /usr/src/app/
|
||||||
|
RUN chown app:app /usr/src/app/
|
||||||
|
USER app
|
||||||
|
|
||||||
|
# Copy pom.xml and prefetch dependencies so a repeated build can continue from the next step with existing dependencies
|
||||||
|
COPY --chown=app ${SERVICE_ROOT}/.mvn/ .mvn
|
||||||
|
COPY --chown=app ${SERVICE_ROOT}/mvnw ${SERVICE_ROOT}/pom.xml ./
|
||||||
|
|
||||||
|
# Copy all needed project files to a folder
|
||||||
|
COPY --chown=app:app ${SERVICE_ROOT}/src ./src
|
||||||
|
|
||||||
|
# Build the production package
|
||||||
|
RUN ./mvnw --batch-mode clean verify -DskipTests
|
||||||
|
|
||||||
|
# Running stage: the part that is used for running the application
|
||||||
|
FROM eclipse-temurin:21-jre-jammy
|
||||||
|
|
||||||
|
RUN useradd -m app
|
||||||
|
USER app
|
||||||
|
|
||||||
|
COPY --chown=app --from=build /usr/src/app/target/*.jar /usr/app/app.jar
|
||||||
|
|
||||||
|
EXPOSE 8080
|
||||||
|
CMD java -jar /usr/app/app.jar
|
9
pom.xml
9
pom.xml
@@ -55,6 +55,15 @@
|
|||||||
<artifactId>spring-modulith-starter-test</artifactId>
|
<artifactId>spring-modulith-starter-test</artifactId>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-devtools</artifactId>
|
||||||
|
<scope>runtime</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
<dependencyManagement>
|
<dependencyManagement>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
@@ -4,10 +4,10 @@ import org.springframework.boot.SpringApplication;
|
|||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
|
||||||
@SpringBootApplication
|
@SpringBootApplication
|
||||||
public class TimezoneServiceApplication {
|
public class Application {
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
SpringApplication.run(TimezoneServiceApplication.class, args);
|
SpringApplication.run(Application.class, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@@ -0,0 +1,5 @@
|
|||||||
|
package dev.mars3142.fhq.timezone_service.timezone.domain.model.request;
|
||||||
|
|
||||||
|
public record TimeZoneRequest(String timezone) {
|
||||||
|
|
||||||
|
}
|
@@ -0,0 +1,5 @@
|
|||||||
|
package dev.mars3142.fhq.timezone_service.timezone.domain.model.response;
|
||||||
|
|
||||||
|
public record TimeZoneResponse(String timezone) {
|
||||||
|
|
||||||
|
}
|
@@ -0,0 +1,18 @@
|
|||||||
|
package dev.mars3142.fhq.timezone_service.timezone.web.controllers;
|
||||||
|
|
||||||
|
import dev.mars3142.fhq.timezone_service.timezone.domain.model.request.TimeZoneRequest;
|
||||||
|
import dev.mars3142.fhq.timezone_service.timezone.domain.model.response.TimeZoneResponse;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("v1/timezone")
|
||||||
|
public class TimeZoneController {
|
||||||
|
|
||||||
|
@PostMapping()
|
||||||
|
public TimeZoneResponse getTimeZone(@RequestBody TimeZoneRequest request) {
|
||||||
|
return new TimeZoneResponse(request.timezone());
|
||||||
|
}
|
||||||
|
}
|
@@ -4,7 +4,7 @@ import org.junit.jupiter.api.Test;
|
|||||||
import org.springframework.boot.test.context.SpringBootTest;
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
|
|
||||||
@SpringBootTest
|
@SpringBootTest
|
||||||
class TimezoneServiceApplicationTests {
|
class ApplicationTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void contextLoads() {
|
void contextLoads() {
|
Reference in New Issue
Block a user