Add demo Dockerfile

This commit is contained in:
criyle 2020-03-04 17:45:48 -05:00
parent 8e8cc17123
commit 0234395b50
3 changed files with 45 additions and 0 deletions

24
.dockerignore Normal file
View File

@ -0,0 +1,24 @@
# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib
/judge
# Test binary, build with `go test -c`
*.test
# Output of the go coverage tool, specifically when used with LiteIDE
*.out
# OS
.DS_Store
# Test Env
env*.sh
init.sql
# Documents
LICENSE
README.md

13
Dockerfile.exec Normal file
View File

@ -0,0 +1,13 @@
FROM golang:latest AS build
WORKDIR /go/judge
COPY go.mod go.sum /go/judge/
RUN go mod download
COPY ./ /go/judge
RUN go build -o executorserver ./cmd/executorserver
ENTRYPOINT ["./executorserver"]

View File

@ -27,6 +27,14 @@ go get github.com/criyle/go-judge/cmd/executorserver
~/go/bin/executorserver # or executorserver if $(GOPATH)/bin is in your $PATH
```
Or, by docker
```bash
docker run -it --rm --privileged -p 5050:5050 criyle/executorserver:demo
```
Build by your own `docker build -t executorserver -f Dockerfile.exec .`
The `executorserver` need root privilege to create `cgroup`. Either creates sub-directory `/sys/fs/cgroup/cpuacct/go-judger`, `/sys/fs/cgroup/memory/go-judger`, `/sys/fs/cgroup/pids/go-judger` and make execution user readable or use `sudo` to run it.
The default binding address for the executor server is `:5050`. Can be specified with `-http` flag.