Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
3370557
minimizing image
dmalan Jun 6, 2023
ab0980e
removed workaround fix for liveshare extension
rongxin-liu Jun 6, 2023
33e1db0
use docker multi-statge build, push minimized for testing
rongxin-liu Jun 6, 2023
c2ef0f0
install build-essential for runtime
rongxin-liu Jun 6, 2023
18f4619
install ruby-dev, consolidated RUN statements
rongxin-liu Jun 6, 2023
61cd0cf
cleaned up dockerfile
rongxin-liu Jun 7, 2023
21cf85b
Adds Bulgarian
rongxin-liu Jul 3, 2023
5a74679
updates runtime versions
rongxin-liu Jul 3, 2023
95bb931
updated Java runtime
rongxin-liu Aug 10, 2023
7517ba0
updated jdk path
rongxin-liu Aug 22, 2023
5a76305
updated sqlite3 wrapper to get input from stdin
rongxin-liu Aug 28, 2023
2daac76
rebuild image
rongxin-liu Sep 12, 2023
7635d92
trigger deployment
rongxin-liu Oct 2, 2023
fb900a5
rebuild image (style50 updates)
rongxin-liu Oct 5, 2023
9a0e2f9
update python version to 3.12.0
rongxin-liu Oct 17, 2023
81d0021
update python-cs50
rongxin-liu Oct 17, 2023
16bb7ff
install setuptools
rongxin-liu Oct 17, 2023
2b6c1d8
rebuild image (style50 updates)
rongxin-liu Oct 27, 2023
5139441
rebuild image (cs50 packages updates)
rongxin-liu Oct 31, 2023
a218b00
updated sqlite3 version
rongxin-liu Nov 1, 2023
8db1140
fixed patch file
rongxin-liu Nov 1, 2023
6d068a2
updates Node
dmalan Nov 19, 2023
02bfc75
Adds --no-install-suggests to minimizing branch
dmalan Nov 19, 2023
a2ab5bf
Merge pull request #179 from cs50/nodejs
rongxin-liu Nov 19, 2023
95931ca
Merge pull request #180 from cs50/minimizing-patch
rongxin-liu Nov 19, 2023
3acb330
Removes weasyprint, gh
dmalan Nov 19, 2023
5e4d518
using --remote-name
dmalan Nov 19, 2023
f9fdda6
Updates Java, shrinks Python
dmalan Nov 19, 2023
d542104
shrunk ruby
dmalan Nov 19, 2023
5cf3c27
Merge pull request #183 from cs50/java
rongxin-liu Nov 19, 2023
9af09a9
updated HISTCONTROL
dmalan Nov 19, 2023
f737dcb
fixed style
dmalan Nov 19, 2023
4572cfd
Merge pull request #181 from cs50/tweaks
rongxin-liu Nov 20, 2023
464c1ea
adds check for app.py to http-server
dmalan Nov 21, 2023
e653eda
tidies formatting
dmalan Nov 21, 2023
4b10bc5
added wsgi.py detection to match flask's application discovery behavior
rongxin-liu Nov 21, 2023
221ff24
Merge pull request #184 from cs50/scripts
rongxin-liu Nov 21, 2023
f228df5
updates http-server wrapper to check for path
dmalan Nov 22, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,23 @@ jobs:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build minimized image for linux/amd64
uses: docker/build-push-action@v3
with:
build-args: |
VCS_REF=${{ github.sha }}
load: true
platforms: linux/amd64
tags: cs50/cli:amd64-minimized
cache-from: type=registry,ref=cs50/cli:amd64-minimized-buildcache
cache-to: type=registry,ref=cs50/cli:amd64-minimized-buildcache,mode=max

- name: Push linux/amd64 build to Docker Hub
if: ${{ github.ref == 'refs/heads/minimizing' }}
run: |
docker push cs50/cli:amd64-minimized


- name: Build for linux/amd64
uses: docker/build-push-action@v3
with:
Expand Down
227 changes: 106 additions & 121 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,84 +1,29 @@
FROM ubuntu:22.04
LABEL maintainer="[email protected]"
# Build statge
FROM ubuntu:22.04 as builder
ARG DEBIAN_FRONTEND=noninteractive


# Avoid "delaying package configuration, since apt-utils is not installed"
RUN apt update && apt install --yes apt-utils


# Install locales
RUN apt update && \
apt install --yes locales && \
locale-gen \
en_US.utf8 \
zh_CN.utf8 \
zh_TW.utf8 \
fr_FR.utf8 \
de_DE.utf8 \
it_IT.utf8 \
es_ES.utf8 \
ja_JP.utf8 \
ko_KR.utf8 \
ru_RU.utf8 \
pt_BR.utf8 \
tr_TR.utf8 \
pl_PL.utf8 \
cs_CZ.utf8 \
hu_HU.utf8
ENV LANG=C.UTF-8


# Unminimize system
RUN yes | unminimize


# Install curl
RUN apt update && \
apt install --yes curl


# Install Java 19.x
# http://jdk.java.net/19/
RUN cd /tmp && \
curl --remote-name https://download.java.net/java/GA/jdk19.0.2/fdb695a9d9064ad6b064dc6df578380c/7/GPL/openjdk-19.0.2_linux-x64_bin.tar.gz && \
tar xzf openjdk-19.0.2_linux-x64_bin.tar.gz && \
rm --force openjdk-19.0.2_linux-x64_bin.tar.gz && \
mv jdk-19.0.2 /opt/ && \
mkdir --parent /opt/bin && \
ln --symbolic /opt/jdk-19.0.2/bin/* /opt/bin/ && \
chmod a+rx /opt/bin/*


# Install Node.js 19.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 19.8.1


# 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 --yes \
apt install --no-install-recommends --no-install-suggests --yes \
make build-essential libssl-dev zlib1g-dev \
libbz2-dev libreadline-dev libsqlite3-dev llvm ca-certificates curl wget unzip \
libncursesw5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev


# Install Python 3.11.x
# Install Python 3.12.x
# https://www.python.org/downloads/
RUN cd /tmp && \
curl https://www.python.org/ftp/python/3.11.3/Python-3.11.3.tgz --output Python-3.11.3.tgz && \
tar xzf Python-3.11.3.tgz && \
rm --force Python-3.11.3.tgz && \
cd Python-3.11.3 && \
./configure && \
curl --remote-name https://www.python.org/ftp/python/3.12.0/Python-3.12.0.tgz && \
tar xzf Python-3.12.0.tgz && \
rm --force Python-3.12.0.tgz && \
cd Python-3.12.0 && \
CFLAGS="-Os" ./configure --enable-optimizations --without-tests && \
make && \
make install && \
cd .. && \
rm --force --recursive Python-3.11.3 && \
rm --force --recursive Python-3.12.0 && \
ln --relative --symbolic /usr/local/bin/pip3 /usr/local/bin/pip && \
ln --relative --symbolic /usr/local/bin/python3 /usr/local/bin/python && \
pip3 install --upgrade pip
Expand All @@ -87,60 +32,125 @@ RUN cd /tmp && \
# Install Ruby 3.2.x
# https://www.ruby-lang.org/en/downloads/
RUN apt update && \
apt install --no-install-recommends --yes \
apt install --no-install-recommends --no-install-suggests --yes \
autoconf \
libyaml-dev && \
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 && \
curl --remote-name https://cache.ruby-lang.org/pub/ruby/3.2/ruby-3.2.2.tar.gz && \
tar xzf ruby-3.2.2.tar.gz && \
rm --force ruby-3.2.2.tar.gz && \
cd ruby-3.2.2 && \
./configure && \
CFLAGS="-Os" ./configure --disable-install-doc --enable-load-relative && \
make && \
make install && \
cd .. && \
rm --force --recursive ruby-3.2.2


# Install SQLite 3.x
# Install Ruby packages
RUN apt install --yes git
RUN gem install --no-document \
jekyll \
minitest `# So that Bundler needn't install` \
pygments.rb \
specific_install && \
gem specific_install https://github.com/cs50/jekyll-theme-cs50 develop && \
gem cleanup


# Install SQLite 3.4x
# https://www.sqlite.org/download.html
# 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-3420000.zip && \
unzip sqlite-amalgamation-3420000.zip && \
rm --force sqlite-amalgamation-3420000.zip && \
cd sqlite-amalgamation-3420000 && \
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 && \
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-3420000 && \
rm --force --recursive sqlite-amalgamation-3440000 && \
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 cd /usr/local/bin && \
curl --remote-name https://raw.githubusercontent.com/tj/n/master/bin/n && \
chmod a+x n && \
./n 21.2.0 && \
npm install --global http-server


# 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 --yes
apt install gh --no-install-recommends --no-install-suggests --yes


# Install CS50 packages
RUN curl https://packagecloud.io/install/repositories/cs50/repo/script.deb.sh | bash && \
apt update && \
apt install --yes \
libcs50
# Final stage
FROM ubuntu:22.04
LABEL maintainer="[email protected]"
ARG DEBIAN_FRONTEND=noninteractive

COPY --from=builder /usr /usr
COPY --from=builder /opt /opt


# Install Ubuntu packages
# Avoid "delaying package configuration, since apt-utils is not installed"
RUN apt update && \
apt install --no-install-recommends --yes \
apt install --no-install-recommends --no-install-suggests --yes \
apt-utils \
ca-certificates \
curl \
locales && \
locale-gen \
en_US.utf8 \
zh_CN.utf8 \
zh_TW.utf8 \
fr_FR.utf8 \
de_DE.utf8 \
it_IT.utf8 \
es_ES.utf8 \
ja_JP.utf8 \
ko_KR.utf8 \
ru_RU.utf8 \
pt_BR.utf8 \
tr_TR.utf8 \
pl_PL.utf8 \
cs_CZ.utf8 \
hu_HU.utf8 \
bg_BG.UTF-8 && \
apt clean
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 && \
apt install --no-install-recommends --no-install-suggests --yes \
astyle \
bash-completion \
build-essential `# dpkg-dev, libc, gcc, g++, make, etc.`\
clang \
coreutils `# for fold` \
coreutils `# For fold` \
cowsay \
dos2unix \
dnsutils `# For nslookup` \
Expand All @@ -150,28 +160,24 @@ RUN apt update && \
git-lfs \
jq \
less \
make \
libcs50 \
libmagic-dev `# For style50` \
libpango-1.0-0 libharfbuzz0b libpangoft2-1.0-0 `# For render50` \
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 \
weasyprint `# For render50` \
zip


# Install Node.js packages
RUN npm install --global http-server


# Install Python packages
RUN apt update && \
apt install --yes libmagic-dev `# For style50` && \
pip3 install \
zip && \
apt clean && \
pip3 install --no-cache-dir \
awscli \
"check50<4" \
compare50 \
Expand All @@ -182,29 +188,11 @@ RUN apt update && \
pytest \
render50 \
s3cmd \
setuptools \
style50 \
"submit50<4"


# Install Ruby packages
RUN gem install \
bundler \
jekyll \
minitest `# So that Bundler needn't install` \
pygments.rb \
specific_install && \
gem specific_install https://github.com/cs50/jekyll-theme-cs50 develop


# Temporary fix for "libssl.so.1.1: cannot open shared object file: No such file or directory" on Ubuntu 22.04
# https://stackoverflow.com/questions/72133316/ubuntu-22-04-libssl-so-1-1-cannot-open-shared-object-file-no-such-file-or-di
RUN cd /tmp && \
curl --remote-name http://archive.ubuntu.com/ubuntu/pool/main/o/openssl/libssl1.1_1.1.1f-1ubuntu2.18_amd64.deb && \
curl --remote-name http://ports.ubuntu.com/pool/main/o/openssl/libssl1.1_1.1.1f-1ubuntu2.18_arm64.deb && \
(dpkg --install libssl1.1_1.1.1f-1ubuntu2.18_amd64.deb || dpkg --install libssl1.1_1.1.1f-1ubuntu2.18_arm64.deb) && \
rm --force --recursive libssl1.1_1.1.1f-1ubuntu2.18*


# Copy files to image
COPY ./etc /etc
COPY ./opt /opt
Expand All @@ -218,15 +206,12 @@ RUN echo >> /etc/inputrc && \
echo "set enable-bracketed-paste off" >> /etc/inputrc


# Add user
# Add user to sudoers
RUN useradd --home-dir /home/ubuntu --shell /bin/bash ubuntu && \
umask 0077 && \
mkdir --parents /home/ubuntu && \
chown --recursive ubuntu:ubuntu /home/ubuntu


# Add user to sudoers
RUN echo "\n# CS50 CLI" >> /etc/sudoers && \
chown --recursive ubuntu:ubuntu /home/ubuntu && \
echo "\n# CS50 CLI" >> /etc/sudoers && \
echo "ubuntu ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers && \
echo "Defaults umask_override" >> /etc/sudoers && \
echo "Defaults umask=0022" >> /etc/sudoers && \
Expand Down
4 changes: 2 additions & 2 deletions etc/profile.d/cli.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ if [ "$(whoami)" != "root" ]; then

# History
# https://www.shellhacks.com/tune-command-line-history-bash/
export HISTCONTROL='ignoreboth' # Ignore duplicates and command lines starting space
export HISTCONTROL='ignoredupes' # Ignore duplicates
export PROMPT_COMMAND='history -a' # Store Bash History Immediately

# Java
export JAVA_HOME="/opt/jdk-19.0.2"
export JAVA_HOME="/opt/jdk-21.0.1"

# Make
export CC="clang"
Expand Down
20 changes: 20 additions & 0 deletions opt/cs50/bin/http-server
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,26 @@ port="-p 8080"
options="--no-dotfiles"
t="-t0"

# Formatting
bold=$(tput bold)
normal=$(tput sgr0)

# Check for app.py or wsgi.py
if [[ -f app.py ]] || [[ -f wsgi.py ]]; then
read -p "Are you sure you want to run ${bold}http-server${normal} and not ${bold}flask${normal}? [y/N] " -r
if [[ ! "${REPLY,,}" =~ ^y|yes$ ]]; then
exit 1
fi
fi

# Check for path
if [[ $# -eq 1 ]] && [[ $1 != -* ]] && [[ ! $1 =~ ^\./?$ ]]; then
read -p "Are you sure you want to serve ${bold}${1}${normal} and not your current directory? [y/N] " -r
if [[ ! "${REPLY,,}" =~ ^y|yes$ ]]; then
exit 1
fi
fi

# Override default options
while test ${#} -gt 0
do
Expand Down
Loading