diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 67731ef..001d0ae 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -26,6 +26,12 @@ jobs: cache-from: type=registry,ref=cs50/cli:amd64-buildcache cache-to: type=registry,ref=cs50/cli:amd64-buildcache,mode=max + - name: Squash for linux/amd64 + if: ${{ github.ref == 'refs/heads/develop' }} + run: | + pip3 install docker-squash + docker-squash --cleanup --tag cs50/cli:amd64 cs50/cli:amd64 + - name: Push linux/amd64 build to Docker Hub if: ${{ github.ref == 'refs/heads/main' }} run: | @@ -42,6 +48,12 @@ jobs: cache-from: type=registry,ref=cs50/cli:arm64-buildcache cache-to: type=registry,ref=cs50/cli:arm64-buildcache,mode=max + - name: Squash for linux/arm64 + if: ${{ github.ref == 'refs/heads/develop' }} + run: | + pip3 install docker-squash + docker-squash --cleanup --tag cs50/cli:arm64 cs50/cli:arm64 + - name: Push linux/arm64 build to Docker Hub if: ${{ github.ref == 'refs/heads/main' }} run: | diff --git a/Dockerfile b/Dockerfile index 9460ad6..da2dd9d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -61,7 +61,7 @@ RUN cd /tmp && \ 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 && \ @@ -205,7 +205,6 @@ RUN apt update && \ nano \ openssh-client `# For ssh-keygen` \ psmisc `# For fuser` \ - ruby-dev `# Ruby development headers` \ sudo \ tzdata `# For TZ` \ unzip \ @@ -239,15 +238,6 @@ RUN pip3 install --no-cache-dir \ "submit50<4" -# Install GitHub CLI (after builder stage, because writes to /usr/share) -# https://github.com/cli/cli/blob/trunk/docs/install_linux.md#debian-ubuntu-linux-raspberry-pi-os-apt -RUN curl --fail --location --show-error --silent 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 --no-install-recommends --no-install-suggests --yes gh - - # Copy files to image COPY ./etc /etc COPY ./opt /opt diff --git a/Makefile b/Makefile index 790902b..d63bd9b 100644 --- a/Makefile +++ b/Makefile @@ -1,10 +1,19 @@ +.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-squash --tag cs50/cli cs50/cli