-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #201 from cs50/main
Merges main into help50 branch
- Loading branch information
Showing
6 changed files
with
129 additions
and
90 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
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 |
---|---|---|
@@ -1,13 +1,54 @@ | ||
# Build statge | ||
# Build stage | ||
FROM ubuntu:22.04 as builder | ||
ARG DEBIAN_FRONTEND=noninteractive | ||
|
||
|
||
# Stage-wide dependencies | ||
RUN apt update && \ | ||
apt install --no-install-recommends --no-install-suggests --yes \ | ||
build-essential \ | ||
ca-certificates \ | ||
curl | ||
|
||
|
||
# Install Java 21.x | ||
# http://jdk.java.net/21/ | ||
RUN cd /tmp && \ | ||
if [ $(uname -m) = "x86_64" ]; then ARCH="x64"; else ARCH="aarch64"; fi && \ | ||
curl --remote-name https://download.java.net/java/GA/jdk21.0.2/f2283984656d49d69e91c558476027ac/13/GPL/openjdk-21.0.2_linux-${ARCH}_bin.tar.gz && \ | ||
tar xzf openjdk-21.0.2_linux-${ARCH}_bin.tar.gz && \ | ||
rm --force openjdk-21.0.2_linux-${ARCH}_bin.tar.gz && \ | ||
mv jdk-21.0.2 /opt/jdk && \ | ||
mkdir --parent /opt/bin && \ | ||
ln --symbolic /opt/jdk/bin/* /opt/bin/ && \ | ||
chmod a+rx /opt/bin/* | ||
|
||
|
||
# Install Node.js 21.x | ||
# https://nodejs.dev/en/download/ | ||
# https://github.com/tj/n#installation | ||
RUN curl --location https://raw.githubusercontent.com/tj/n/master/bin/n --output /usr/local/bin/n && \ | ||
chmod a+x /usr/local/bin/n && \ | ||
n 21.6.1 | ||
|
||
|
||
# Install Node.js packages | ||
RUN npm install --global \ | ||
http-server | ||
|
||
|
||
# Patch index.js in http-server | ||
COPY index.js.patch /tmp | ||
RUN cd /usr/local/lib/node_modules/http-server/lib/core/show-dir && \ | ||
patch index.js < /tmp/index.js.patch && \ | ||
rm --force /tmp/index.js.patch | ||
|
||
|
||
# Suggested build environment for Python, per pyenv, even though we're building ourselves | ||
# https://github.com/pyenv/pyenv/wiki#suggested-build-environment | ||
RUN apt update && \ | ||
apt install --no-install-recommends --no-install-suggests --yes \ | ||
curl ca-certificates build-essential git \ | ||
build-essential ca-certificates curl git \ | ||
libssl-dev libbz2-dev libreadline-dev libsqlite3-dev \ | ||
llvm libncursesw5-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev \ | ||
make tk-dev unzip wget xz-utils zlib1g-dev | ||
|
@@ -16,11 +57,11 @@ RUN apt update && \ | |
# Install Python 3.11.x | ||
# https://www.python.org/downloads/ | ||
RUN cd /tmp && \ | ||
curl https://www.python.org/ftp/python/3.11.7/Python-3.11.7.tgz --output Python-3.11.7.tgz && \ | ||
curl --remote-name https://www.python.org/ftp/python/3.11.7/Python-3.11.7.tgz && \ | ||
tar xzf Python-3.11.7.tgz && \ | ||
rm --force Python-3.11.7.tgz && \ | ||
cd Python-3.11.7 && \ | ||
CFLAGS="-Os" ./configure --enable-optimizations --without-tests && \ | ||
CFLAGS="-Os" ./configure --disable-static --enable-optimizations --enable-shared --with-lto --without-tests && \ | ||
./configure && \ | ||
make && \ | ||
make install && \ | ||
|
@@ -31,14 +72,32 @@ RUN cd /tmp && \ | |
pip3 install --no-cache-dir --upgrade pip | ||
|
||
|
||
# Install R | ||
# https://docs.posit.co/resources/install-r-source/#build-and-install-r | ||
# https://cran.rstudio.com/src/base/R-4/ | ||
RUN sed --in-place "/^#.*deb-src.*universe$/s/^# //g" /etc/apt/sources.list && \ | ||
apt update && \ | ||
apt build-dep --yes r-base && \ | ||
cd /tmp && \ | ||
curl --remote-name https://cran.rstudio.com/src/base/R-4/R-4.3.2.tar.gz && \ | ||
tar xzf R-4.3.2.tar.gz && \ | ||
rm --force R-4.3.2.tar.gz && \ | ||
cd R-4.3.2 && \ | ||
./configure --enable-memory-profiling --enable-R-shlib && \ | ||
make && \ | ||
make install && \ | ||
cd .. && \ | ||
rm --force --recursive R-4.3.2 | ||
|
||
|
||
# Install Ruby 3.2.x | ||
# https://www.ruby-lang.org/en/downloads/ | ||
RUN apt update && \ | ||
apt install --no-install-recommends --no-install-suggests --yes \ | ||
autoconf \ | ||
libyaml-dev && \ | ||
apt clean && \ | ||
rm -rf /var/lib/apt/lists/* && \ | ||
rm --force --recursive /var/lib/apt/lists/* && \ | ||
cd /tmp && \ | ||
curl https://cache.ruby-lang.org/pub/ruby/3.2/ruby-3.2.2.tar.gz --output ruby-3.2.2.tar.gz && \ | ||
tar xzf ruby-3.2.2.tar.gz && \ | ||
|
@@ -66,64 +125,33 @@ RUN gem install --no-document \ | |
# https://www.sqlite.org/howtocompile.html#compiling_the_command_line_interface | ||
COPY shell.c.patch /tmp | ||
RUN cd /tmp && \ | ||
curl --remote-name https://www.sqlite.org/2023/sqlite-amalgamation-3440000.zip && \ | ||
unzip sqlite-amalgamation-3440000.zip && \ | ||
rm --force sqlite-amalgamation-3440000.zip && \ | ||
cd sqlite-amalgamation-3440000 && \ | ||
curl --remote-name https://www.sqlite.org/2024/sqlite-amalgamation-3450000.zip && \ | ||
unzip sqlite-amalgamation-3450000.zip && \ | ||
rm --force sqlite-amalgamation-3450000.zip && \ | ||
cd sqlite-amalgamation-3450000 && \ | ||
patch shell.c < /tmp/shell.c.patch && \ | ||
gcc -D HAVE_READLINE -D SQLITE_DEFAULT_FOREIGN_KEYS=1 -D SQLITE_OMIT_DYNAPROMPT=1 shell.c sqlite3.c -lpthread -ldl -lm -lreadline -lncurses -o /usr/local/bin/sqlite3 && \ | ||
cd .. && \ | ||
rm --force --recursive sqlite-amalgamation-3440000 && \ | ||
rm --force --recursive sqlite-amalgamation-3450000 && \ | ||
rm --force /tmp/shell.c.patch | ||
# Install Java 21.x | ||
# http://jdk.java.net/21/ | ||
RUN cd /tmp && \ | ||
curl --remote-name https://download.java.net/java/GA/jdk21.0.1/415e3f918a1f4062a0074a2794853d0d/12/GPL/openjdk-21.0.1_linux-x64_bin.tar.gz && \ | ||
tar xzf openjdk-21.0.1_linux-x64_bin.tar.gz && \ | ||
rm --force openjdk-21.0.1_linux-x64_bin.tar.gz && \ | ||
mv jdk-21.0.1 /opt/ && \ | ||
mkdir --parent /opt/bin && \ | ||
ln --symbolic /opt/jdk-21.0.1/bin/* /opt/bin/ && \ | ||
chmod a+rx /opt/bin/* | ||
# Install Node.js 21.x | ||
# https://nodejs.dev/en/download/ | ||
# https://github.com/tj/n#installation | ||
RUN curl --location https://raw.githubusercontent.com/tj/n/master/bin/n --output /usr/local/bin/n && \ | ||
chmod a+x /usr/local/bin/n && \ | ||
n 21.2.0 | ||
# Install GitHub CLI | ||
# https://github.com/cli/cli/blob/trunk/docs/install_linux.md#debian-ubuntu-linux-raspberry-pi-os-apt | ||
RUN curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg && \ | ||
chmod go+r /usr/share/keyrings/githubcli-archive-keyring.gpg && \ | ||
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | tee /etc/apt/sources.list.d/github-cli.list > /dev/null && \ | ||
apt update && \ | ||
apt install gh --no-install-recommends --no-install-suggests --yes | ||
# Final stage | ||
FROM ubuntu:22.04 | ||
LABEL maintainer="[email protected]" | ||
ARG DEBIAN_FRONTEND=noninteractive | ||
# Copy files from builder | ||
COPY --from=builder /usr /usr | ||
COPY --from=builder /opt /opt | ||
COPY --from=builder /usr/local /usr/local | ||
# Avoid "delaying package configuration, since apt-utils is not installed" | ||
# Install locales | ||
RUN apt update && \ | ||
apt install --no-install-recommends --no-install-suggests --yes \ | ||
apt-utils \ | ||
curl \ | ||
ca-certificates \ | ||
locales && \ | ||
locale-gen \ | ||
en_US.utf8 \ | ||
|
@@ -145,17 +173,19 @@ RUN apt update && \ | |
ENV LANG=C.UTF-8 | ||
# Install CS50, Ubuntu, and Python packages | ||
RUN curl https://packagecloud.io/install/repositories/cs50/repo/script.deb.sh | bash && \ | ||
apt update && \ | ||
# Install Ubuntu packages | ||
RUN apt update && \ | ||
apt upgrade --yes && \ | ||
apt install --no-install-recommends --no-install-suggests --yes \ | ||
astyle \ | ||
bash-completion \ | ||
build-essential `# dpkg-dev, libc, gcc, g++, make, etc.`\ | ||
ca-certificates \ | ||
clang \ | ||
colorized-logs `# For help50` \ | ||
coreutils `# For fold` \ | ||
cowsay \ | ||
curl \ | ||
dos2unix \ | ||
dnsutils `# For nslookup` \ | ||
expect `# For help50` \ | ||
|
@@ -165,24 +195,36 @@ RUN curl https://packagecloud.io/install/repositories/cs50/repo/script.deb.sh | | |
git-lfs \ | ||
jq \ | ||
less \ | ||
libcs50 \ | ||
liblapack3 `# For R` \ | ||
libmagic-dev `# For style50` \ | ||
libpango-1.0-0 libharfbuzz0b libpangoft2-1.0-0 `# For render50` \ | ||
libpangocairo-1.0-0 `# For R` \ | ||
libtiff5 `# For R` \ | ||
libxt6 `# For R` \ | ||
libyaml-0-2 `# Runtime package for gem` \ | ||
man \ | ||
man-db \ | ||
nano \ | ||
openssh-client `# For ssh-keygen` \ | ||
psmisc `# For fuser` \ | ||
ruby-dev `# Ruby development headers` \ | ||
sudo \ | ||
tzdata `# For TZ` \ | ||
unzip \ | ||
valgrind \ | ||
vim \ | ||
wget \ | ||
zip && \ | ||
apt clean && \ | ||
pip3 install --no-cache-dir \ | ||
apt clean | ||
# Install CS50 library | ||
RUN curl https://packagecloud.io/install/repositories/cs50/repo/script.deb.sh | bash && \ | ||
apt update && \ | ||
apt install --yes libcs50 | ||
# Install Python packages | ||
RUN pip3 install --no-cache-dir \ | ||
autopep8 \ | ||
black \ | ||
"check50<4" \ | ||
|
@@ -197,18 +239,6 @@ RUN curl https://packagecloud.io/install/repositories/cs50/repo/script.deb.sh | | |
"submit50<4" | ||
# Install Node.js packages | ||
RUN npm install --global \ | ||
http-server | ||
# Patch index.js in http-server | ||
COPY index.js.patch /tmp | ||
RUN cd /usr/local/lib/node_modules/http-server/lib/core/show-dir && \ | ||
patch index.js < /tmp/index.js.patch && \ | ||
rm --force /tmp/index.js.patch | ||
# Copy files to image | ||
COPY ./etc /etc | ||
COPY ./opt /opt | ||
|
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 |
---|---|---|
@@ -1,10 +1,21 @@ | ||
.PHONY: default | ||
default: run | ||
|
||
build: | ||
docker build --build-arg VCS_REF="$(shell git rev-parse HEAD)" -t cs50/cli . | ||
docker build --build-arg VCS_REF="$(shell git rev-parse HEAD)" --tag cs50/cli . | ||
$(MAKE) squash | ||
|
||
depends: | ||
pip3 install docker-squash | ||
|
||
rebuild: | ||
docker build --no-cache -t cs50/cli . | ||
docker build --no-cache --tag cs50/cli . | ||
$(MAKE) squash | ||
|
||
run: | ||
docker run --env LANG="$(LANG)" -it -P --rm --security-opt seccomp=unconfined -v "$(PWD)":/home/ubuntu cs50/cli bash --login || true | ||
docker run --env LANG="$(LANG)" --interactive --publish-all --rm --security-opt seccomp=unconfined --tty --volume "$(PWD)":/home/ubuntu cs50/cli bash --login || true | ||
|
||
squash: depends | ||
docker images cs50/codespace | ||
docker-squash --tag cs50/cli cs50/cli | ||
docker images cs50/codespace |
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
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
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 |
---|---|---|
@@ -1,25 +1,4 @@ | ||
# diff shell.c shell_modified.c > shell.c.patch | ||
28631,28641c28631,28641 | ||
< printf( | ||
< "SQLite version %s %.19s%s\n" /*extra-version-info*/ | ||
< "Enter \".help\" for usage hints.\n", | ||
< sqlite3_libversion(), sqlite3_sourceid(), zCharset | ||
< ); | ||
< if( warnInmemoryDb ){ | ||
< printf("Connected to a "); | ||
< printBold("transient in-memory database"); | ||
< printf(".\nUse \".open FILENAME\" to reopen on a " | ||
< "persistent database.\n"); | ||
< } | ||
--- | ||
> // printf( | ||
> // "SQLite version %s %.19s%s\n" /*extra-version-info*/ | ||
> // "Enter \".help\" for usage hints.\n", | ||
> // sqlite3_libversion(), sqlite3_sourceid(), zCharset | ||
> // ); | ||
> // if( warnInmemoryDb ){ | ||
> // printf("Connected to a "); | ||
> // printBold("transient in-memory database"); | ||
> // printf(".\nUse \".open FILENAME\" to reopen on a " | ||
> // "persistent database.\n"); | ||
> // } | ||
29438,29440d29437 | ||
< sputf(stdout, "SQLite version %s %.19s%s\n" /*extra-version-info*/ | ||
< "Enter \".help\" for usage hints.\n", | ||
< sqlite3_libversion(), sqlite3_sourceid(), SHELL_CIO_CHAR_SET); |