-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathDockerfile
99 lines (81 loc) · 4.77 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
FROM debian:buster
# Prepare image and install dependencies
ENV LANG=C.UTF-8
ARG DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y \
flex bison build-essential \
csh libxaw7-dev wget \
libc6-i386 default-jdk
RUN mkdir -p /tmp/build
COPY . /tmp/build
# Install student dist
# Note that this is _not_ what is in the `/usr/class/cs143` subdirectory in the
# VM! The `cs143` contains make files that generate the assignments in an
# arbitrary folder from skeleton files. Essentially this step was already done
# in the `student-dist.tar.gz`. The assignments just have to be completed and
# submitted in the respective /class/assignments/PA* subdirectories.
# Prepare the immutable distribution
RUN mkdir -p /usr/class \
&& wget https://courses.edx.org/asset-v1:StanfordOnline+SOE.YCSCS1+1T2020+type@[email protected] -P /tmp \
&& tar xzf "/tmp/asset-v1:StanfordOnline+SOE.YCSCS1+1T2020+type@[email protected]" -C /usr/class
ENV PATH=/usr/class/bin:$PATH
# Download submission scripts
RUN wget -O - https://courses.edx.org/asset-v1:StanfordOnline+SOE.YCSCS1+1T2020+type@[email protected] \
| tee /usr/class/assignments/PA2J/grade.pl /usr/class/assignments/PA2/grade.pl > /dev/null
RUN wget -O - https://courses.edx.org/asset-v1:StanfordOnline+SOE.YCSCS1+1T2020+type@[email protected] \
| tee /usr/class/assignments/PA3J/grade.pl /usr/class/assignments/PA3/grade.pl > /dev/null
RUN wget -O - https://courses.edx.org/asset-v1:StanfordOnline+SOE.YCSCS1+1T2020+type@[email protected] \
| tee /usr/class/assignments/PA4J/grade.pl /usr/class/assignments/PA4/grade.pl > /dev/null
RUN wget -O - https://courses.edx.org/asset-v1:StanfordOnline+SOE.YCSCS1+1T2020+type@[email protected] \
| tee /usr/class/assignments/PA5J/grade.pl /usr/class/assignments/PA5/grade.pl > /dev/null
# Download additional resources to `class/handouts`. We scrape the whole
# websites every time we build the container. On the other hand they could just
# provide the resources in the course ¯\_(ツ)_/¯
# Move the handouts in the student-dist.tar.gz to edx subfolder
RUN mkdir -p /usr/class/handouts/edx \
&& cd /usr/class/handouts \
&& mv *.pdf edx
# Download cs143 resources. This contains e.g. latex templates for the assignments, previous finals
# https://web.stanford.edu/class/cs143/
RUN mkdir -p /usr/class/handouts/cs143 \
&& cd /usr/class/handouts/cs143 \
&& wget -r -k -l1 https://web.stanford.edu/class/cs143/ \
&& mv web.stanford.edu/class/cs143/* . && rm -fR web.stanford.edu
# Download openclassroom resources. this contains e.g. the annotated video slides.
# We are downloading the directory listing from
# http://openclassroom.stanford.edu/MainFolder/courses/Compilers/docs
# here, so we can use mirror (-m) without parents (-np) here.
# see also: http://openclassroom.stanford.edu/MainFolder/CoursePage.php?course=Compilers
RUN mkdir -p /usr/class/handouts/openclassroom \
&& cd /usr/class/handouts/openclassroom \
&& wget -np -m http://openclassroom.stanford.edu/MainFolder/courses/Compilers/docs/ \
&& mv openclassroom.stanford.edu/MainFolder/courses/Compilers/docs/* . && rm -fR openclassroom.stanford.edu
# Patch tar arguments in submission scripts
# We add -o to tar command since --preserve-permissions and --same-owner
# are default in tar for superuser. Since we are running as root
# in the container this messes up ownership of the `grading` folders
# created by the `grade.pl` scripts
RUN sed -i 's/-zx/-ozx/g' \
/usr/class/assignments/PA2J/grade.pl /usr/class/assignments/PA2/grade.pl \
/usr/class/assignments/PA3J/grade.pl /usr/class/assignments/PA3/grade.pl \
/usr/class/assignments/PA4J/grade.pl /usr/class/assignments/PA4/grade.pl \
/usr/class/assignments/PA5J/grade.pl /usr/class/assignments/PA5/grade.pl
# Patch cool.flex, cool.y in submission folder
# This is a hack to
# a) satisfy the cool compiler which expects yylex to be named cool_yylex
# b) satisfy libfl > 2.5.39 which expects a yylex symbol
# c) fix mangling errors of yylex when compiled with a c++ compiler
# d) be as non-invasive as possible to the existing assignment code
RUN patch -u /usr/class/assignments/PA2/cool.flex -i /tmp/build/cool.flex.patch \
&& patch -u /usr/class/assignments/PA3/cool.y -i /tmp/build/cool.y.patch \
&& patch -u /usr/class/assignments/PA4/Makefile -i /tmp/build/Makefile.patch \
&& patch -u /usr/class/assignments/PA5/Makefile -i /tmp/build/Makefile.patch
# Setup working directory
RUN mkdir -p /class
WORKDIR /class
# Run entrypoint to connect working directory to mounted host volume. This
# copies files to the (potentially host-mounted) volume, s.t. files can be
# edited on the host and are also visible in the container.
COPY entrypoint.sh /usr/bin/entrypoint.sh
ENTRYPOINT ["entrypoint.sh"]
CMD ["/bin/bash"]