perf: shrink images and harden downloads

- Keep Go module/build and bun caches in cache mounts instead of layers.
- Split base tool downloads into layers ordered by change frequency.
- Use curl -f and pipefail so failed downloads break the build.
- Resolve the lazygit version from the release redirect instead of the
  rate-limited GitHub API.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Job79andClaude Opus 5.5 committed 2026-11-08 11:46:59 +01:00
1 parent 0397174460
commit 9c6569fa29
2 files changed
+32 -15

No files matched your search

+14 -6
View File
@@ -7,12 +7,20 @@ RUN --mount=type=cache,id=dnf-cache,target=/var/cache/libdnf5 \
bash-completion git-core fzf curl awk jq rg unzip which \ bash-completion git-core fzf curl awk jq rg unzip which \
host-spawn wl-copy gcc tree-sitter-cli host-spawn wl-copy gcc tree-sitter-cli
RUN LAZYGIT_VERSION=$(curl -s "https://api.github.com/repos/jesseduffield/lazygit/releases/latest" | jq -r .tag_name | sed 's/^v//') && \ # === install tools (least to most frequently changing) ===
curl -sL "https://github.com/jesseduffield/lazygit/releases/latest/download/lazygit_${LAZYGIT_VERSION}_linux_x86_64.tar.gz" | tar xz -C /usr/local/bin lazygit && \ RUN set -o pipefail && \
curl -sL "https://github.com/jorgerojas26/lazysql/releases/latest/download/lazysql_Linux_x86_64.tar.gz" | tar xz -C /usr/local/bin lazysql && \ LAZYGIT_URL=$(curl -fsSLI -o /dev/null -w '%{url_effective}' https://github.com/jesseduffield/lazygit/releases/latest) && \
curl -sL "https://github.com/neovim/neovim/releases/download/nightly/nvim-linux-x86_64.tar.gz" | tar xz -C /usr/local --strip-components=1 && \ curl -fsSL "https://github.com/jesseduffield/lazygit/releases/latest/download/lazygit_${LAZYGIT_URL##*/v}_linux_x86_64.tar.gz" | tar xz -C /usr/local/bin lazygit && \
curl -fsSL https://bun.sh/install | BUN_INSTALL="/usr/local" bash && \ curl -fsSL "https://github.com/jorgerojas26/lazysql/releases/latest/download/lazysql_Linux_x86_64.tar.gz" | tar xz -C /usr/local/bin lazysql
ln -sf /usr/local/bin/bun /usr/local/bin/node && \
RUN set -o pipefail && \
curl -fsSL https://bun.sh/install | BUN_INSTALL=/usr/local bash && \
ln -sf /usr/local/bin/bun /usr/local/bin/node
RUN set -o pipefail && \
curl -fsSL https://github.com/neovim/neovim/releases/download/nightly/nvim-linux-x86_64.tar.gz | tar xz -C /usr/local --strip-components=1
RUN set -o pipefail && \
curl -fsSL https://claude.ai/install.sh | bash && \ curl -fsSL https://claude.ai/install.sh | bash && \
cp -L /root/.local/bin/claude /usr/local/bin/ && \ cp -L /root/.local/bin/claude /usr/local/bin/ && \
rm -rf /root/.local rm -rf /root/.local
+18 -9
View File
@@ -2,14 +2,23 @@ ARG TAG
FROM job79/base:${TAG} FROM job79/base:${TAG}
USER root USER root
RUN GO_VERSION=$(curl -sL "https://go.dev/VERSION?m=text" | head -n 1 | tr -d '\r\n') && \ RUN set -o pipefail && \
curl -sL "https://go.dev/dl/${GO_VERSION}.linux-amd64.tar.gz" | tar xz -C /usr/local && \ GO_VERSION=$(curl -fsSL "https://go.dev/VERSION?m=text" | head -n 1 | tr -d '\r\n') && \
ln -sf /usr/local/go/bin/go /usr/local/bin/go && \ curl -fsSL "https://go.dev/dl/${GO_VERSION}.linux-amd64.tar.gz" | tar xz -C /usr/local && \
ln -sf /usr/local/go/bin/gofmt /usr/local/bin/gofmt && \ ln -sf /usr/local/go/bin/go /usr/local/go/bin/gofmt /usr/local/bin/
GOBIN=/usr/local/bin /usr/local/go/bin/go install golang.org/x/tools/gopls@latest && \
GOBIN=/usr/local/bin /usr/local/go/bin/go install mvdan.cc/gofumpt@latest && \ # Build caches live in cache mounts so they don't end up in the image.
GOBIN=/usr/local/bin /usr/local/go/bin/go install golang.org/x/tools/cmd/goimports@latest && \ RUN --mount=type=cache,id=go-mod,target=/root/go/pkg/mod \
GOBIN=/usr/local/bin /usr/local/go/bin/go install github.com/go-delve/delve/cmd/dlv@latest && \ --mount=type=cache,id=go-build,target=/root/.cache/go-build \
BUN_INSTALL="/usr/local" bun install -g typescript typescript-language-server @tailwindcss/language-server svelte-language-server @biomejs/biome for pkg in \
golang.org/x/tools/gopls \
golang.org/x/tools/cmd/goimports \
mvdan.cc/gofumpt \
github.com/go-delve/delve/cmd/dlv; \
do GOBIN=/usr/local/bin go install "$pkg@latest" || exit 1; done
RUN --mount=type=cache,id=bun-cache,target=/root/.bun-cache \
BUN_INSTALL=/usr/local BUN_INSTALL_CACHE_DIR=/root/.bun-cache bun install -g \
typescript typescript-language-server @tailwindcss/language-server svelte-language-server @biomejs/biome
USER user USER user