From 3487b65407f0327f4609a89e85666304f673ddfe Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 14 Mar 2026 05:51:33 +0000 Subject: [PATCH] Collapse fake multi-stage build into single stage MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The "build" stage was the final stage in the Dockerfile, so the multi-stage split did nothing — all build tools ended up in the published image anyway. Merge both stages into one and combine the apt-get installs into a single RUN to reduce layers. https://claude.ai/code/session_01GgxFojxadiw6FgKrketpn3 --- ruby/Dockerfile | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/ruby/Dockerfile b/ruby/Dockerfile index 68f8b76..781253a 100644 --- a/ruby/Dockerfile +++ b/ruby/Dockerfile @@ -1,17 +1,22 @@ ARG RUBY_VERSION -FROM registry.docker.com/library/ruby:$RUBY_VERSION-slim as base +FROM registry.docker.com/library/ruby:$RUBY_VERSION-slim # The app lives here WORKDIR /app -# Install base packages +# Install base packages and packages needed to build gems RUN apt-get update -qq \ && apt-get install --no-install-recommends -y \ + build-essential \ curl \ + git \ + libpq-dev \ + libyaml-dev \ + pkg-config \ postgresql-client \ && rm -rf /var/lib/apt/lists /var/cache/apt/archives -# Non-root user for runtime stages (USER not set here so build stage keeps root) +# Non-root user for downstream runtime stages RUN useradd --system --uid 1000 app && chown app:app /app # Set production environment @@ -20,18 +25,5 @@ ENV BUNDLE_DEPLOYMENT="1" \ BUNDLE_CACHE_PATH="/usr/local/bundle/cache" \ BUNDLE_WITHOUT="development" -# Throw-away build stage to reduce size of final image -FROM base as build - -# Install packages needed to build gems -RUN apt-get update -qq \ - && apt-get install --no-install-recommends -y \ - build-essential \ - git \ - libpq-dev \ - libyaml-dev \ - pkg-config \ - && rm -rf /var/lib/apt/lists /var/cache/apt/archives - # This can be overwritten at runtime CMD ["ruby", "-v"]