forked from cs50/codespace
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
160 lines (128 loc) · 4.47 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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
# Build stage
FROM cs50/cli:amd64-minimized as builder
ARG DEBIAN_FRONTEND=noninteractive
# Unset user
USER root
# Install glibc sources for debugger
# https://github.com/Microsoft/vscode-cpptools/issues/1123#issuecomment-335867997
RUN echo "deb-src http://archive.ubuntu.com/ubuntu/ jammy main restricted" > /etc/apt/sources.list.d/_.list && \
apt update && \
apt install --no-install-recommends --yes dpkg-dev && \
cd /tmp && \
apt source glibc && \
rm -rf *.tar.* *.dsc && \
mkdir --parents /build/glibc-sMfBJT && \
tar --create --gzip --file /build/glibc-sMfBJT/glibc.tar.gz glibc*
# Install BFG
RUN wget https://repo1.maven.org/maven2/com/madgag/bfg/1.14.0/bfg-1.14.0.jar -P /opt/share
# Install Lua 5.x
RUN wget http://www.lua.org/ftp/lua-5.4.4.tar.gz -P/tmp && \
cd /tmp && \
tar zxf lua-5.4.4.tar.gz && \
cd lua-5.4.4 && \
make all test install && \
cd /tmp && \
rm -rf /tmp/lua-5.4.4*
# Install noVNC (VNC client)
RUN wget https://github.com/novnc/noVNC/archive/refs/tags/v1.4.0.zip -P/tmp && \
unzip /tmp/v1.4.0.zip -d /tmp && \
mv /tmp/noVNC-1.4.0 /opt/noVNC && \
rm -rf /tmp/noVNC-1.4.0 /tmp/v1.4.0.zip && \
chown -R ubuntu:ubuntu /opt/noVNC
# Install VS Code extensions
RUN npm install -g @vscode/vsce yarn && \
mkdir --parents /opt/cs50/extensions && \
cd /tmp && \
git clone https://github.com/cs50/explain50.vsix.git && \
cd explain50.vsix && \
npm install && \
vsce package && \
mv explain50-1.0.0.vsix /opt/cs50/extensions && \
cd /tmp && \
rm -rf explain50.vsix && \
git clone https://github.com/cs50/cs50.vsix.git && \
cd cs50.vsix && \
npm install && \
vsce package && \
mv cs50-0.0.1.vsix /opt/cs50/extensions && \
mv python-clients/cs50vsix-client /opt/cs50/extensions && \
cd /tmp && \
rm -rf cs50.vsix && \
git clone https://github.com/cs50/ddb50.vsix.git && \
cd ddb50.vsix && \
npm install && \
vsce package && \
mv ddb50-2.0.0.vsix /opt/cs50/extensions && \
cd /tmp && \
rm -rf ddb50.vsix && \
git clone https://github.com/cs50/phpliteadmin.vsix.git && \
cd phpliteadmin.vsix && \
npm install && \
vsce package && \
mv phpliteadmin-0.0.1.vsix /opt/cs50/extensions && \
cd /tmp && \
rm -rf phpliteadmin.vsix && \
git clone https://github.com/cs50/style50.vsix.git && \
cd style50.vsix && \
npm install && \
vsce package && \
mv style50-0.0.1.vsix /opt/cs50/extensions && \
cd /tmp && \
rm -rf style50.vsix && \
npm uninstall -g vsce yarn
# Final stage
FROM cs50/cli:amd64-minimized
ARG DEBIAN_FRONTEND=noninteractive
# Unset user
USER root
# Copy files from builder
COPY --from=builder /build/glibc-sMfBJT /build/glibc-sMfBJT
COPY --from=builder /usr/local/bin/lua /usr/local/bin/lua
COPY --from=builder /opt/noVNC /opt/noVNC
COPY --from=builder /opt/cs50/extensions /opt/cs50/extensions
COPY --from=builder /opt/share/bfg-1.14.0.jar /opt/share/bfg-1.14.0.jar
RUN chown -R ubuntu:ubuntu /opt/share
RUN pip3 install --no-cache-dir /opt/cs50/extensions/cs50vsix-client/ && \
rm -rf /opt/cs50/extensions/cs50vsix-client
# set virtual display
ENV DISPLAY=":0"
# Install Ubuntu packages
# Install acl for temporarily removing ACLs via opt/cs50/bin/postCreateCommand
# https://github.community/t/bug-umask-does-not-seem-to-be-respected/129638/9
RUN apt update && apt install --no-install-recommends --yes \
acl \
clang-format \
dwarfdump \
jq \
manpages-dev \
mysql-client \
openbox \
pgloader \
php-cli \
php-mbstring \
php-sqlite3 \
postgresql \
xvfb \
x11vnc && \
apt clean
# Install Python packages
RUN pip3 install --no-cache-dir \
black \
cli50 \
djhtml \
matplotlib \
"pydantic<2" \
pytz
# Enforce login shell
RUN echo "shopt -q login_shell || bash --login" >> /home/ubuntu/.bashrc && \
chown -R ubuntu:ubuntu /home/ubuntu/.bashrc
# Copy files to image
COPY ./etc /etc
COPY ./opt /opt
RUN chmod a+rx /opt/cs50/bin/* && \
chmod a+rx /opt/cs50/phpliteadmin/bin/phpliteadmin && \
ln --symbolic /opt/cs50/phpliteadmin/bin/phpliteadmin /opt/cs50/bin/phpliteadmin
# Temporary workaround for https://github.com/cs50/cs50.dev/issues/19
RUN echo "if [ -z \"\$_PROFILE_D\" ] ; then for i in /etc/profile.d/*.sh; do if ["$i" == "/etc/profile.d/debuginfod*"] ; then continue; fi; . \"\$i\"; done; export _PROFILE_D=1; fi"
# Set user
USER ubuntu