Skip to content

Commit

Permalink
devcontainer 설정
Browse files Browse the repository at this point in the history
  • Loading branch information
cranemont committed Aug 28, 2022
1 parent d02f947 commit 51ba895
Show file tree
Hide file tree
Showing 12 changed files with 48 additions and 11 deletions.
22 changes: 22 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"forwardPorts": [3000],
"name": "judge-manager",
"dockerComposeFile": ["../docker-compose.yml"],
"service": "judge-manager",
"runServices": ["judge-manager", "redis"],
"workspaceFolder": "/go/src/github.com/cranemont/judge-manager",
"customizations": {
// Configure properties specific to VS Code.
"vscode": {
// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"dbaeumer.vscode-eslint",
"golang.go",
"golang.go-nightly",
"albert.TabOut",
"donjayamanne.githistory",
"eamodio.gitlens"
]
}
}
}
3 changes: 2 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
results
results
.devcontainer
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM ubuntu:20.04

COPY sandbox /sandbox
COPY sandbox /tmp
COPY sources.list /etc/apt/

ENV TZ=Asia/Seoul
Expand All @@ -13,7 +13,7 @@ RUN buildDeps='software-properties-common git libtool cmake python-dev python3-p
apt-get update && apt-get install -y openjdk-11-jdk gcc-9 g++-9 && \
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-9 40 && \
update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-9 40 && \
cd /sandbox && cmake CMakeLists.txt && make && make install && \
cd /tmp && cmake CMakeLists.txt && make && make install && \
apt-get purge -y --auto-remove $buildDeps && \
apt-get clean && rm -rf /var/lib/apt/lists/* && \
useradd -u 12001 compiler && useradd -u 12002 code && useradd -u 12003 spj && usermod -a -G code spj
Expand All @@ -29,4 +29,4 @@ ENV PATH $GOPATH/bin:/usr/local/go/bin:$PATH
RUN mkdir -p "$GOPATH/src/github.com/cranemont" "$GOPATH/bin" && chmod -R 777 "$GOPATH"

WORKDIR $GOPATH
RUN git clone https://github.com/cranemont/judge-manager $GOPATH/src/github.com/cranemont
RUN git clone https://github.com/cranemont/judge-manager $GOPATH/src/github.com/cranemont/judge-manager
2 changes: 1 addition & 1 deletion cache/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ type cache struct {

func NewCache(ctx context.Context) *cache {
rdb := redis.NewClient(&redis.Options{
Addr: "localhost:6379", // TODO: export to ENV
Addr: "redis:6379", // TODO: export to ENV
Password: "",
DB: 0,
})
Expand Down
Empty file added compile/error.out
Empty file.
Empty file added compile/out.out
Empty file.
2 changes: 1 addition & 1 deletion constants/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ const TASK_EXITED = "Exited"
const PUBLISH_RESULT = "Publish"

// const BASE_DIR = "./results"
const BASE_DIR = "/home/coc0a25/go/src/github.com/cranemont/judge-manager/results"
const BASE_DIR = "/go/src/github.com/cranemont/judge-manager/results"
const BASE_FILE_MODE = 0755
13 changes: 13 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
version: '3'
services:
judge-manager:
container_name: judge-manager
image: coc0a25/judge-manager:dev
stdin_open: true
tty: true
volumes:
- .:/go/src/github.com/cranemont/judge-manager:cached
redis:
container_name: redis
image: redis:alpine

2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/cranemont/judge-manager

go 1.18
go 1.19

require github.com/go-redis/redis/v9 v9.0.0-beta.2

Expand Down
8 changes: 4 additions & 4 deletions judge/sandbox.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ func (s *sandbox) Execute(args *SandboxArgs) (*Result, error) {
maxCpuTime := "--max_cpu_time=" + fmt.Sprint(args.MaxCpuTime)
maxRealTime := "--max_real_time=" + fmt.Sprint(args.MaxRealTime)
maxMemory := "--max_memory=" + fmt.Sprint(args.MaxMemory)
outputPath := "--output_path=out.out"
errorPath := "--error_path=error.out"
outputPath := "--output_path=./compile/out.out"
errorPath := "--error_path=./compile/error.out"

argsWithFormat := []string{}
for _, arg := range args.Args {
Expand Down Expand Up @@ -102,8 +102,8 @@ func (s *sandbox) Run(args *SandboxArgs) (*Result, error) {
maxCpuTime := "--max_cpu_time=" + fmt.Sprint(args.MaxCpuTime)
maxRealTime := "--max_real_time=" + fmt.Sprint(args.MaxRealTime)
maxMemory := "--max_memory=" + fmt.Sprint(args.MaxMemory)
outputPath := "--output_path=/home/coc0a25/go/src/github.com/cranemont/judge-manager/out.out"
errorPath := "--error_path=/home/coc0a25/go/src/github.com/cranemont/judge-manager/error.out"
outputPath := "--output_path=./run/out.out"
errorPath := "--error_path=./run/error.out"

argSlice := []string{
exePath, maxCpuTime, maxRealTime, maxMemory, outputPath, errorPath,
Expand Down
Empty file added run/error.out
Empty file.
1 change: 1 addition & 0 deletions run/out.out
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Hello world!

0 comments on commit 51ba895

Please sign in to comment.