-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: docker에서 stdout, stderr, time 결과를 내도록 만듦
- Loading branch information
1 parent
f5b5fe1
commit acb5197
Showing
15 changed files
with
73 additions
and
957 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
docker-sh/ | ||
build.sh |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
ARG NODE_VERSION=18.16.0 | ||
ARG NODE_VERSION=20.9.0 | ||
ARG ALPINE_VERSION=3.18 | ||
|
||
FROM node:${NODE_VERSION}-alpine | ||
|
@@ -7,9 +7,8 @@ MAINTAINER Yechan Lee <[email protected]> | |
CMD "mkdir -p /algo-with-me" | ||
|
||
WORKDIR /algo-with-me | ||
COPY . /algo-with-me | ||
RUN npm install | ||
COPY --chmod=555 ./node-sh /algo-with-me/node-sh | ||
|
||
EXPOSE 3000 | ||
# EXPOSE 3000 | ||
|
||
CMD ["node", "./dist/app.js"] | ||
CMD ./node-sh/run.sh $COMPETITION_ID $USER_ID $PROBLEM_ID |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
sudo docker network create --driver bridge isolatedNetwork | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
yechan2468
Author
Collaborator
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
sudo docker container stop algo-with-me-judge | ||
sudo docker container prune --force | ||
sudo docker image prune --force |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
sudo docker run \ | ||
-p 3000:3000 \ | ||
-e COMPETITION_ID=$1 \ | ||
-e USER_ID=$2 \ | ||
-e PROBLEM_ID=$3 \ | ||
-v $HOME/algo-with-me/problems:/algo-with-me/problems:ro \ | ||
-v $HOME/algo-with-me/testcases:/algo-with-me/testcases:ro \ | ||
-v $HOME/algo-with-me/submissions:/algo-with-me/submissions \ | ||
--user $(id -u):$(id -g) \ | ||
--name algo-with-me-judge \ | ||
algo-with-me-judge:latest | ||
|
||
#--network none \ | ||
#--network isolatedNetwork \ |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# PARAM | ||
# $1 COMPETITION_ID | ||
# $2 USER_ID | ||
# $3 PROBLEM_ID | ||
|
||
# DESCRIPTION | ||
# SUBMISSION_JS_FILE에서 파일을 읽어, node로 실행한다. | ||
# DETAIL_FILE에는 사용한 시간(sec)과 최대 memory 메모리 사용량(KB)이 공백(' ')으로 분리되어 기록된다. | ||
|
||
mkdir -p "/algo-with-me/submissions/$1/$2/" | ||
|
||
SUBMISSION_JS_FILE="/algo-with-me/submissions/$1/$2/$3.js" | ||
DETAIL_FILE="/algo-with-me/submissions/$1/$2/$3.detail" | ||
|
||
# 제출된 js 파일이 있으면 node로 js 파일 실행 | ||
# 주의: judge.sh와 run.sh는 execute 권한이 부여되어야 함 | ||
if [ -f "$SUBMISSION_JS_FILE" ]; then | ||
echo "[algo-with-me] run.sh: started running $SUBMISSION_JS_FILE" | ||
# -o FILE Write result to FILE | ||
# -f FMT Custom format | ||
# U Total number of CPU-seconds that the process used directly (in user mode), in seconds. | ||
# e Elapsed real (wall clock) time used by the process, in seconds. | ||
# M Maximum resident set size of the process during its lifetime, in Kilobytes. | ||
/usr/bin/time -o "$DETAIL_FILE" -f "%e %M" /algo-with-me/node-sh/runJs.sh "$1" "$2" "$3" | ||
echo "[algo-with-me] run.sh: successfully ran $SUBMISSION_JS_FILE" | ||
else | ||
echo "[algo-with-me] run.sh: cannot find submitted js file $SUBMISSION_JS_FILE" | ||
fi | ||
|
||
exit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# PARAM | ||
# $1 COMPETITION_ID | ||
# $2 USER_ID | ||
# $3 PROBLEM_ID | ||
|
||
# DESCRIPTION | ||
# node로 제출한 파일을 실행한다. | ||
# stdout, stderr는 각각 STDOUT_FILE, STDERR_FILE에 기록된다. | ||
# RESULT_FILE에는 제출한 파일의 solution() 값이 기록되는데, shell script 상에서는 할 수 없어 템플릿 코드에서 기록해주어야 한다. | ||
# node 실행할 때 첫번째 인자로 RESULT_FILE의 파일 경로를 입력해준다. | ||
|
||
SUBMISSION_JS_FILE="/algo-with-me/submissions/$1/$2/$3.js" | ||
STDOUT_FILE="/algo-with-me/submissions/$1/$2/$3.stdout" | ||
STDERR_FILE="/algo-with-me/submissions/$1/$2/$3.stderr" | ||
RESULT_FILE="/algo-with-me/submissions/$1/$2/$3.result" | ||
|
||
node "$SUBMISSION_JS_FILE" "$RESULT_FILE" 1> "$STDOUT_FILE" 2> "$STDERR_FILE" | ||
|
||
exit |
Binary file not shown.
Oops, something went wrong.
컨테이너간 통신할때 쓰는거라는데 맞나요? 맞다면 왜 통신이 필요한가요?