Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added --no-install-suggests #176

Closed
wants to merge 22 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
218 changes: 101 additions & 117 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 && \
curl https://www.python.org/ftp/python/3.12.0/Python-3.12.0.tgz --output Python-3.12.0.tgz && \
tar xzf Python-3.12.0.tgz && \
rm --force Python-3.12.0.tgz && \
cd Python-3.12.0 && \
./configure && \
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,7 +32,7 @@ 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 && \
Expand All @@ -102,45 +47,109 @@ RUN apt update && \
rm --force --recursive ruby-3.2.2


# Install SQLite 3.x
# Install Ruby packages
RUN apt install --yes git
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


# 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 20.x
# http://jdk.java.net/20/
RUN cd /tmp && \
curl --remote-name https://download.java.net/java/GA/jdk20.0.2/6e380f22cbe7469fa75fb448bd903d8e/9/GPL/openjdk-20.0.2_linux-x64_bin.tar.gz && \
tar xzf openjdk-20.0.2_linux-x64_bin.tar.gz && \
rm --force openjdk-20.0.2_linux-x64_bin.tar.gz && \
mv jdk-20.0.2 /opt/ && \
mkdir --parent /opt/bin && \
ln --symbolic /opt/jdk-20.0.2/bin/* /opt/bin/ && \
chmod a+rx /opt/bin/*


# Install Node.js 20.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 20.3.1 && \
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/bin/ /usr/bin/
COPY --from=builder /usr/local/ /usr/local/
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 `# libc, gcc, g++, make, dpkg-dev etc.`\
clang \
coreutils `# for fold` \
coreutils `# For fold` \
cowsay \
dos2unix \
dnsutils `# For nslookup` \
Expand All @@ -150,28 +159,24 @@ RUN apt update && \
git-lfs \
jq \
less \
make \
libcs50 `# CS50 library` \
libmagic-dev `# For style50` \
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 +187,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 +205,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
2 changes: 1 addition & 1 deletion etc/profile.d/cli.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ if [ "$(whoami)" != "root" ]; then
export PROMPT_COMMAND='history -a' # Store Bash History Immediately

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

# Make
export CC="clang"
Expand Down
6 changes: 6 additions & 0 deletions opt/cs50/bin/sqlite3
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
#!/bin/bash

# If data is coming from stdin (pipe or redirection)
if [[ -p /dev/stdin || ! -t 0 ]]; then
/usr/local/bin/sqlite3 -nullvalue NULL -table "$@" < /dev/stdin
exit $?
fi

# If no command-line argument
if [[ $# -eq 0 ]]; then
read -p "Are you sure you want to run $(tput bold)sqlite3$(tput sgr0) without a command-line argument (e.g., the filename of a database)? [y/N] " -r
Expand Down
28 changes: 14 additions & 14 deletions shell.c.patch
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# diff shell.c shell_modified.c > shell.c.patch
27832,27842c27832,27842
28631,28641c28631,28641
< printf(
< "SQLite version %s %.19s\n" /*extra-version-info*/
< "SQLite version %s %.19s%s\n" /*extra-version-info*/
< "Enter \".help\" for usage hints.\n",
< sqlite3_libversion(), sqlite3_sourceid()
< sqlite3_libversion(), sqlite3_sourceid(), zCharset
< );
< if( warnInmemoryDb ){
< printf("Connected to a ");
Expand All @@ -12,14 +12,14 @@
< "persistent database.\n");
< }
---
> // printf(
> // "SQLite version %s %.19s\n" /*extra-version-info*/
> // "Enter \".help\" for usage hints.\n",
> // sqlite3_libversion(), sqlite3_sourceid()
> // );
> // 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");
> // }
Loading