forked from autolab/Tango
-
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.
Don't hardcode container interface in Docker vmms
Instead of putting all the file copying and su-ing in the docker run command constructed by the vmm, include an interface script in the container and use it as the container entrypoint. The only thing passed from the vmm to the container are the resource limit parameters. In addition, rewrite the dockerfile so it (1) includes fewer RUN lines, and (2) does not need to fetch Tango from github in order to build autodriver; Instead, the autodriver source is copied to the container using the ADD instruction
- Loading branch information
Showing
4 changed files
with
66 additions
and
57 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,32 @@ | ||
# Autolab - autograding docker image | ||
|
||
FROM ubuntu:14.04 | ||
MAINTAINER Mihir Pandya <mihir.m.pandya@gmail.com> | ||
|
||
RUN apt-get update && apt-get install -y build-essential wget | ||
|
||
# Install autodriver | ||
WORKDIR /home | ||
RUN useradd autolab && useradd autograde | ||
RUN mkdir autolab autograde output && chown autolab:autolab autolab output && chown autograde:autograde autograde | ||
ADD . /home/autodriver | ||
WORKDIR /home/autodriver | ||
RUN make clean && make && install -c -o root -g root -m 4755 autodriver /usr/bin/autodriver && install -c -m 755 autograde_wrapper.py /usr/bin/autograde_wrapper | ||
ENTRYPOINT ["/usr/bin/autograde_wrapper"] | ||
|
||
# Install C0 | ||
WORKDIR /home | ||
RUN wget http://c0.typesafety.net/dist/cc0-v0440-linux3.18.1-64bit-bin.tgz | ||
RUN tar -xvzf cc0-* | ||
WORKDIR /home/cc0 | ||
RUN bin/cc0 -d doc/src/exp.c0 doc/src/exp-test.c0 | ||
#RUN ./a.out | ||
RUN cp bin/cc0 /usr/bin/cc0 | ||
|
||
# Clean up | ||
WORKDIR /home | ||
RUN apt-get remove -y wget && apt-get -y autoremove | ||
RUN rm -rf autodriver cc0* | ||
|
||
# Check installation | ||
RUN ls -l /home && which autodriver && which cc0 |
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,33 @@ | ||
#!/usr/bin/python3 | ||
import sys | ||
import os | ||
import pwd | ||
import shutil | ||
import subprocess | ||
print("Running "+ str(sys.argv)) | ||
|
||
for f in os.listdir("mount"): | ||
src=os.path.join("mount", f) | ||
dst=os.path.join("autolab", f) | ||
shutil.copy(src, dst) | ||
|
||
autolabuser=pwd.getpwnam("autolab") | ||
pid=os.fork() | ||
if pid == 0: | ||
os.setgroups([]) | ||
os.setgid(autolabuser.pw_gid) | ||
os.setuid(autolabuser.pw_uid) | ||
outfile=open("output/feedback", "w") | ||
args=["autodriver"] | ||
args.extend(sys.argv[1:]) | ||
args.append("autolab") | ||
print("Executing "+str(args), file=outfile) | ||
sys.exit(subprocess.call(args, stdout=outfile, stderr=outfile, close_fds=True)) | ||
(np, status)=os.waitpid(pid, 0) | ||
# if core, exit -1, else pass through code. | ||
if status & 0xff: | ||
status=-1 | ||
else: | ||
status>>=8; | ||
shutil.copy("output/feedback", "mount/feedback") | ||
sys.exit(status) |
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