Skip to content

Commit c30509f

Browse files
committed
Add Coding Playground
1 parent 2002c9b commit c30509f

File tree

17 files changed

+3768
-12
lines changed

17 files changed

+3768
-12
lines changed

build-service.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@ build_push_file_service() {
2727

2828
main() {
2929
login
30-
# for svc in submission-service quiz-service
31-
# do
32-
# build_push_java "$svc"
33-
# done
30+
for svc in submission-service quiz-service coding-service profile-service
31+
do
32+
build_push_java "$svc"
33+
done
3434
# build_push_java "profile-service"
35-
build_push_file_service
35+
# build_push_file_service
3636
}
3737

3838
main "$@"

coding-service/src/main/java/com/codecampus/coding/service/DockerSandboxService.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public CompiledArtifact compile(
5454
}
5555

5656
// 3. Tên nhị phân / jar random để tránh trùng
57-
String binName = STR."bin_\{UUID.randomUUID()}";
57+
String binName = "bin_" + UUID.randomUUID();
5858
String image = "capstoneprojectpythondocker"; // đã có sẵn GCC, JDK
5959

6060
ProcessBuilder processBuilder = switch (language) {
@@ -67,14 +67,13 @@ public CompiledArtifact compile(
6767
"docker", "run", "--rm",
6868
"-v", workDir + ":/code", image,
6969
"bash", "-c",
70-
"javac /code/Main.java -d /code && " +
71-
"jar --create --file=/code/" + binName +
72-
".jar -C /code Main.class");
70+
"javac /code/Main.java -d /code");
7371
default -> throw new IllegalStateException();
7472
};
7573

7674
exec(processBuilder);
77-
return new CompiledArtifact(language, binName, workDir);
75+
return new CompiledArtifact(language,
76+
"java".equals(language) ? "Main" : binName, workDir);
7877
}
7978

8079
/**
@@ -105,8 +104,8 @@ public CodeResult runTest(
105104
List<String> cmd = switch (compiledArtifact.lang()) {
106105
case "python" -> List.of("python3", "/app/Main.py");
107106
case "cpp" -> List.of("/app/" + compiledArtifact.binary());
108-
case "java" -> List.of("java", "-jar",
109-
"/app/" + compiledArtifact.binary() + ".jar");
107+
case "java" -> List.of("java", "-cp", "/app",
108+
compiledArtifact.binary());
110109
default -> throw new IllegalStateException();
111110
};
112111

0 commit comments

Comments
 (0)