cicd + tool

This commit is contained in:
2026-01-07 16:51:12 +03:00
parent 3be81fc7a5
commit e7af1ffb0b
6 changed files with 195 additions and 0 deletions

29
aitools/Dockerfile Normal file
View File

@@ -0,0 +1,29 @@
# Stage 1: Build the application
FROM maven:3.9.11-eclipse-temurin-25 AS build
WORKDIR /app
# Copy pom.xml and download dependencies
COPY pom.xml .
RUN mvn dependency:go-offline
# Copy source code
COPY src ./src
# Build the application
RUN mvn package -DskipTests
# Stage 2: Create the runtime image
FROM eclipse-temurin:25-jdk
WORKDIR /app
# Copy the built JAR file
COPY --from=build /app/target/*.jar app.jar
# Set environment variables
ENV JAVA_OPTS=""
# Expose the application port
EXPOSE 8080
# Run the application
ENTRYPOINT ["sh", "-c", "java $JAVA_OPTS -jar app.jar"]

View File

@@ -40,11 +40,18 @@
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webflux-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-starter-webflux-ui</artifactId>
<version>3.0.1</version>
</dependency>
</dependencies>
<build>

View File

@@ -1,4 +1,40 @@
package ru.ldeloff.aitools.datetime.controller;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Mono;
import java.time.ZoneId;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
@Slf4j
@RestController
public class TimeController {
@GetMapping("/time/moscow")
@Operation(summary = "Get current Moscow time", description = "Returns current date and time in Moscow timezone (Europe/Moscow) as ISO 8601 string. Used as a tool for LLMs to get accurate local time.")
@ApiResponses({
@ApiResponse(responseCode = "200", description = "Current time in Moscow in format yyyy-MM-dd HH:mm:ss"),
@ApiResponse(responseCode = "500", description = "Internal server error")
})
public Mono<TimeResponse> getMoscowTime() {
log.info("getMoscowTime");
return Mono.fromSupplier(() -> {
LocalDateTime moscowTime = LocalDateTime.now(ZoneId.of("Europe/Moscow"));
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
return new TimeResponse(moscowTime.format(formatter));
});
}
public static class TimeResponse {
public final String time;
public TimeResponse(String time) {
this.time = time;
}
}
}

View File

@@ -1 +1,3 @@
spring.application.name=aitools
springdoc.api-docs.path=/api-docs