Skip to content

Commit 3d177dd

Browse files
reduce image size (#83)
1 parent e103ab5 commit 3d177dd

File tree

1 file changed

+44
-22
lines changed

1 file changed

+44
-22
lines changed

Dockerfile

Lines changed: 44 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -106,30 +106,34 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
106106
### PYTHON ###
107107

108108
ARG PYENV_VERSION=v2.5.5
109-
ARG PYTHON_VERSION=3.11.12
109+
ARG PYTHON_VERSIONS="3.11.12 3.10 3.12 3.13"
110110

111111
# Install pyenv
112112
ENV PYENV_ROOT=/root/.pyenv
113113
ENV PATH=$PYENV_ROOT/bin:$PATH
114-
ENV PYTHON_VERSIONS="3.10 3.11.12 3.12 3.13"
115114
RUN git -c advice.detachedHead=0 clone --branch "$PYENV_VERSION" --depth 1 https://github.com/pyenv/pyenv.git "$PYENV_ROOT" \
116115
&& echo 'export PYENV_ROOT="$HOME/.pyenv"' >> /etc/profile \
117-
&& echo 'export PATH="$$PYENV_ROOT/shims:$PYENV_ROOT/bin:$PATH"' >> /etc/profile \
116+
&& echo 'export PATH="$PYENV_ROOT/shims:$PYENV_ROOT/bin:$PATH"' >> /etc/profile \
118117
&& echo 'eval "$(pyenv init - bash)"' >> /etc/profile \
119-
&& cd "$PYENV_ROOT" && src/configure && make -C src \
118+
&& cd "$PYENV_ROOT" \
119+
&& src/configure \
120+
&& make -C src \
120121
&& pyenv install $PYTHON_VERSIONS \
121-
&& pyenv global "$PYTHON_VERSION"
122+
&& pyenv global "${PYTHON_VERSIONS%% *}" \
123+
&& rm -rf "$PYENV_ROOT/cache"
122124

123125
# Install pipx for common global package managers (e.g. poetry)
124126
ENV PIPX_BIN_DIR=/root/.local/bin
125127
ENV PATH=$PIPX_BIN_DIR:$PATH
126-
RUN apt-get update && apt-get install -y --no-install-recommends pipx=1.4.* \
128+
RUN apt-get update \
129+
&& apt-get install -y --no-install-recommends pipx=1.4.* \
127130
&& rm -rf /var/lib/apt/lists/* \
128-
&& pipx install poetry==2.1.* uv==0.7.* \
129-
# Preinstall common packages for each version
131+
&& pipx install --pip-args="--no-cache-dir --no-compile" poetry==2.1.* uv==0.7.* \
130132
&& for pyv in "${PYENV_ROOT}/versions/"*; do \
131-
"${pyv}/bin/pip" install --upgrade pip ruff black mypy pyright isort pytest; \
132-
done
133+
"$pyv/bin/python" -m pip install --no-cache-dir --no-compile --upgrade pip && \
134+
"$pyv/bin/pip" install --no-cache-dir --no-compile ruff black mypy pyright isort pytest; \
135+
done \
136+
&& rm -rf /root/.cache/pip ~/.cache/pip ~/.cache/pipx
133137

134138
# Reduce the verbosity of uv - impacts performance of stdout buffering
135139
ENV UV_NO_PROGRESS=1
@@ -155,12 +159,18 @@ RUN git -c advice.detachedHead=0 clone --branch "$NVM_VERSION" --depth 1 https:/
155159
&& nvm install 18 && nvm use 18 && npm install -g [email protected] [email protected] && corepack enable && corepack install -g yarn \
156160
&& nvm install 20 && nvm use 20 && npm install -g [email protected] [email protected] && corepack enable && corepack install -g yarn \
157161
&& nvm install 22 && nvm use 22 && npm install -g [email protected] [email protected] && corepack enable && corepack install -g yarn \
158-
&& nvm alias default "$NODE_VERSION"
162+
&& nvm alias default "$NODE_VERSION" \
163+
&& nvm cache clear \
164+
&& npm cache clean --force || true \
165+
&& pnpm store prune || true \
166+
&& yarn cache clean || true
159167

160168
### BUN ###
161169

162170
ARG BUN_VERSION=1.2.14
163-
RUN mise use --global "bun@${BUN_VERSION}"
171+
RUN mise use --global "bun@${BUN_VERSION}" \
172+
&& mise cache clear || true \
173+
&& rm -rf "$HOME/.cache/mise" "$HOME/.local/share/mise/downloads"
164174

165175
### JAVA ###
166176

@@ -175,7 +185,9 @@ RUN JAVA_VERSIONS="$( [ "$TARGETARCH" = "arm64" ] && echo "$ARM_JAVA_VERSIONS" |
175185
&& for v in $JAVA_VERSIONS; do mise install "java@${v}"; done \
176186
&& mise use --global "java@${JAVA_VERSIONS%% *}" \
177187
&& mise use --global "gradle@${GRADLE_VERSION}" \
178-
&& mise use --global "maven@${MAVEN_VERSION}"
188+
&& mise use --global "maven@${MAVEN_VERSION}" \
189+
&& mise cache clear || true \
190+
&& rm -rf "$HOME/.cache/mise" "$HOME/.local/share/mise/downloads"
179191

180192
### SWIFT ###
181193

@@ -185,21 +197,22 @@ RUN if [ "$TARGETARCH" = "amd64" ]; then \
185197
for v in $SWIFT_VERSIONS; do \
186198
mise install "swift@${v}"; \
187199
done && \
188-
mise use --global "swift@${SWIFT_VERSIONS%% *}"; \
200+
mise use --global "swift@${SWIFT_VERSIONS%% *}" \
201+
&& mise cache clear || true \
202+
&& rm -rf "$HOME/.cache/mise" "$HOME/.local/share/mise/downloads"; \
189203
else \
190204
echo "Skipping Swift install on $TARGETARCH"; \
191205
fi
192206

193207
### RUST ###
194208

195209
ARG RUST_VERSIONS="1.89.0 1.88.0 1.87.0 1.86.0 1.85.1 1.84.1 1.83.0"
196-
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y \
210+
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal --default-toolchain none \
197211
&& . "$HOME/.cargo/env" \
198212
&& echo 'source $HOME/.cargo/env' >> /etc/profile \
199-
&& rustup install $RUST_VERSIONS \
213+
&& rustup toolchain install $RUST_VERSIONS --profile minimal --component rustfmt --component clippy \
200214
&& rustup default ${RUST_VERSIONS%% *}
201215

202-
203216
### RUBY ###
204217

205218
ARG RUBY_VERSIONS="3.2.3 3.3.8 3.4.4"
@@ -208,11 +221,14 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
208221
libgmp-dev=2:6.3.* \
209222
&& rm -rf /var/lib/apt/lists/* \
210223
&& for v in $RUBY_VERSIONS; do mise install "ruby@${v}"; done \
211-
&& mise use --global "ruby@${RUBY_VERSIONS%% *}"
224+
&& mise use --global "ruby@${RUBY_VERSIONS%% *}" \
225+
&& mise cache clear || true \
226+
&& rm -rf "$HOME/.cache/mise" "$HOME/.local/share/mise/downloads"
212227

213228
### C++ ###
214229
# gcc is already installed via apt-get above, so these are just additional linters, etc.
215-
RUN pipx install cpplint==2.0.* clang-tidy==20.1.* clang-format==20.1.* cmakelang==0.6.*
230+
RUN pipx install --pip-args="--no-cache-dir --no-compile" cpplint==2.0.* clang-tidy==20.1.* clang-format==20.1.* cmakelang==0.6.* \
231+
&& rm -rf /root/.cache/pip ~/.cache/pip ~/.cache/pipx
216232

217233
### BAZEL ###
218234

@@ -231,7 +247,9 @@ ARG GOLANG_CI_LINT_VERSION=2.1.6
231247
ENV PATH=/usr/local/go/bin:$HOME/go/bin:$PATH
232248
RUN for v in $GO_VERSIONS; do mise install "go@${v}"; done \
233249
&& mise use --global "go@${GO_VERSIONS%% *}" \
234-
&& mise use --global "golangci-lint@${GOLANG_CI_LINT_VERSION}"
250+
&& mise use --global "golangci-lint@${GOLANG_CI_LINT_VERSION}" \
251+
&& mise cache clear || true \
252+
&& rm -rf "$HOME/.cache/mise" "$HOME/.local/share/mise/downloads"
235253

236254
### PHP ###
237255

@@ -252,14 +270,18 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
252270
re2c=3.1-* \
253271
&& rm -rf /var/lib/apt/lists/* \
254272
&& for v in $PHP_VERSIONS; do mise install "php@${v}"; done \
255-
&& mise use --global "php@${PHP_VERSIONS%% *}"
273+
&& mise use --global "php@${PHP_VERSIONS%% *}" \
274+
&& mise cache clear || true \
275+
&& rm -rf "$HOME/.cache/mise" "$HOME/.local/share/mise/downloads"
256276

257277
### ELIXIR ###
258278

259279
ARG ERLANG_VERSION=27.1.2
260280
ARG ELIXIR_VERSION=1.18.3
261281
RUN mise install "erlang@${ERLANG_VERSION}" "elixir@${ELIXIR_VERSION}-otp-27" \
262-
&& mise use --global "erlang@${ERLANG_VERSION}" "elixir@${ELIXIR_VERSION}-otp-27"
282+
&& mise use --global "erlang@${ERLANG_VERSION}" "elixir@${ELIXIR_VERSION}-otp-27" \
283+
&& mise cache clear || true \
284+
&& rm -rf "$HOME/.cache/mise" "$HOME/.local/share/mise/downloads"
263285

264286
### SETUP SCRIPTS ###
265287

0 commit comments

Comments
 (0)