Commit 94d75e92 94d75e922dafc8a2720f33646eb9ea7e60746c27 by cnb.bofCdSsphPA

Optimize Dockerfile: reduce image size from 4.51GB to 2.16GB

Remove code-server, build-essential, gcc, libc6-dev, pkg-config, libssl-dev
from final stage. Add conda clean post-install in builder. Strip
unnecessary opencode platform binaries (musl/baseline variants) post-npm-install.
Remove redundant COPY layers for opencode (already covered by full
node directory copy). Keep opencode.exe entry point (Node.js bootstrap).

Constraint: buildkit crashes with 'frontend grpc server closed unexpectedly' on this host; legacy builder used
Confidence: high
Scope-risk: narrow
Directive: opencode.exe is the Node.js bootstrapper, not a Windows binary; do not delete
Tested: docker run --rm verified node/npm/bun/python/hx/claude/opencode/nvim all work
1 parent 6a97ca13
......@@ -17,7 +17,8 @@ RUN apt-get update && \
RUN curl -sSLk https://mirrors.tuna.tsinghua.edu.cn/anaconda/miniconda/Miniconda3-py310_23.11.0-2-Linux-x86_64.sh \
-o /tmp/miniconda.sh && \
bash /tmp/miniconda.sh -b -p /usr/local/miniconda3 && \
rm /tmp/miniconda.sh
rm /tmp/miniconda.sh && \
/usr/local/miniconda3/bin/conda clean -a -y
# Node.js (prebuilt binary, no build tools needed)
RUN curl -sSLk https://unofficial-builds.nodejs.org/download/release/v22.22.2/node-v22.22.2-linux-x64-glibc-217.tar.gz \
......@@ -30,8 +31,12 @@ RUN curl -sSLk https://unofficial-builds.nodejs.org/download/release/v22.22.2/no
# Bun
RUN curl -fsSL https://bun.sh/install | BUN_INSTALL=/usr/local/bun bash
# opencode-ai
RUN npm i -g opencode-ai --registry https://mirrors.cloud.tencent.com/npm/
# opencode-ai + strip unnecessary platform binaries
RUN npm i -g opencode-ai --registry https://mirrors.cloud.tencent.com/npm/ && \
rm -rf /usr/local/node-v22.22.2-linux-x64-glibc-217/lib/node_modules/opencode-ai/node_modules/opencode-linux-x64-musl && \
rm -rf /usr/local/node-v22.22.2-linux-x64-glibc-217/lib/node_modules/opencode-ai/node_modules/opencode-linux-x64-baseline && \
rm -rf /usr/local/node-v22.22.2-linux-x64-glibc-217/lib/node_modules/opencode-ai/node_modules/opencode-linux-x64-baseline-musl && \
npm cache clean --force
# ---- Stage 2: Minimal final image ----
FROM debian:13.4-slim
......@@ -46,8 +51,7 @@ RUN apt-get update && \
git git-lfs \
zsh tmux \
ripgrep jq sudo \
build-essential gcc libc6-dev \
pkg-config libssl-dev vim \
vim \
tzdata locales \
lsof nload htop net-tools dnsutils \
openssh-server && \
......@@ -73,8 +77,6 @@ RUN useradd -m -s /bin/bash user && \
COPY --from=builder /usr/local/miniconda3 /usr/local/miniconda3
COPY --from=builder /usr/local/node-v22.22.2-linux-x64-glibc-217 /usr/local/node-v22.22.2-linux-x64-glibc-217
COPY --from=builder /usr/local/bun /usr/local/bun
COPY --from=builder /usr/local/node-v22.22.2-linux-x64-glibc-217/lib/node_modules /usr/local/node-v22.22.2-linux-x64-glibc-217/lib/node_modules
COPY --from=builder /usr/local/node-v22.22.2-linux-x64-glibc-217/bin/opencode /usr/local/node-v22.22.2-linux-x64-glibc-217/bin/opencode
RUN ln -sf /usr/local/node-v22.22.2-linux-x64-glibc-217/bin/node /usr/local/bin/node && \
ln -sf /usr/local/node-v22.22.2-linux-x64-glibc-217/bin/npm /usr/local/bin/npm && \
......@@ -95,24 +97,6 @@ COPY scripts/ /home/user/scripts/
RUN chown -R user:user /home/user/scripts && \
chmod +x /home/user/scripts/*.sh
# code-server
RUN curl -fsSL https://code-server.dev/install.sh | sh
# code-server extensions (run as user so they install to ~/.local)
USER user
RUN code-server --install-extension golang.go \
&& code-server --install-extension cnbcool.cnb-welcome \
&& code-server --install-extension formulahendry.code-runner \
&& code-server --install-extension ms-kubernetes-tools.vscode-kubernetes-tools \
&& code-server --install-extension tencent-cloud.coding-copilot \
&& code-server --install-extension github.github-vscode-theme \
&& code-server --install-extension ms-ceintl.vscode-language-pack-zh-hans \
&& code-server --install-extension eddieposey.vscode-icons-mac \
&& code-server --install-extension oderwat.indent-rainbow \
&& code-server --install-extension yzhang.markdown-all-in-one
USER root
# oh-my-zsh
RUN RUNZSH=no CHSH=no sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" && \
chsh -s $(which zsh) user
......