Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
FROM eclipse-temurin:21-jre-alpine
WORKDIR /app
# Копируем готовый jar из папки build/libs
COPY build/libs/*.jar app.jar
ENTRYPOINT ["java", "-jar", "app.jar"]
# Этап 1 — сборка jar внутри Docker
FROM gradle:8-jdk21-alpine AS builder
WORKDIR /app
COPY . .
RUN gradle build -x test

# Этап 2 — запуск
FROM eclipse-temurin:21-jre-alpine
WORKDIR /app
COPY --from=builder /app/build/libs/*.jar app.jar
ENTRYPOINT ["java", "-jar", "app.jar"]
10 changes: 10 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ group = 'com.codzilla'
version = '0.0.1'
description = 'Backend'

jar {

enabled = false
}

java {
toolchain {
languageVersion = JavaLanguageVersion.of(21)
Expand All @@ -21,9 +26,14 @@ repositories {
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.kafka:spring-kafka'
implementation 'org.springframework.boot:spring-boot-starter-websocket'

developmentOnly 'org.springframework.boot:spring-boot-devtools'

compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'

runtimeOnly 'org.postgresql:postgresql'

testRuntimeOnly 'com.h2database:h2'
Expand Down
50 changes: 0 additions & 50 deletions src/main/java/com/codzilla/backend/controller/Coffee.java

This file was deleted.

26 changes: 0 additions & 26 deletions src/main/java/com/codzilla/backend/controller/DataLoader.java

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
package com.codzilla.backend.controller.Sandbox.judge0;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestClient;
import org.springframework.http.MediaType;

@Slf4j
@Component
public class Judge0Client {

private final RestClient restClient;
private final ObjectMapper objectMapper = new ObjectMapper();

public Judge0Client(@Value("${judge0.base-url}") String baseUrl) {
this.restClient = RestClient.builder()
.baseUrl(baseUrl)
.build();
}

public String submit(String sourceCode, int languageId, String stdin) {
try {
String body = objectMapper.writeValueAsString(new SubmissionRequest(sourceCode, languageId, stdin));
log.info("Sending to Judge0 body: {}", body);

String raw = restClient.post()
.uri("/submissions?wait=true")
.contentType(MediaType.APPLICATION_JSON)
.body(body)
.retrieve()
.onStatus(status -> true, (req, res) -> {})
.body(String.class);

log.info("Judge0 response: {}", raw);

SubmissionResponse response = objectMapper.readValue(raw, SubmissionResponse.class);
return response.getStatus().getDescription();

} catch (Exception e) {
throw new RuntimeException("Judge0 error: " + e.getMessage(), e);
}
}

public static class SubmissionRequest {
public String source_code;
public Integer language_id;
public String stdin;

public SubmissionRequest(String sourceCode, int languageId, String stdin) {
this.source_code = sourceCode;
this.language_id = languageId;
this.stdin = stdin;
}
}

@Data
@JsonIgnoreProperties(ignoreUnknown = true)
public static class SubmissionResponse {
private String stdout;
private String stderr;
private String compile_output;
private Status status;

@Data
@JsonIgnoreProperties(ignoreUnknown = true)
public static class Status {
private int id;
private String description;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.codzilla.backend.controller.Sandbox.polygon;

import com.codzilla.backend.controller.Sandbox.problem.Problem;
import lombok.Data;
import java.util.List;

@Data
public class CreateProblemRequest {
private String name; // название задачи
private Problem.ProblemType type;
private Problem.ProblemLevel level;
private List<TestCase> tests; // список тестов

@Data
public static class TestCase {
private String input; // "1 2"
private String output; // "3"
}
}
Loading