Skip to content

Commit 905cc70

Browse files
authored
Merge pull request #203 from DefangLabs/jordan/apt-clean-after-install
consistenly clean up apt artifacts after apt-get install in slim images
2 parents f08ffb8 + 7d88c33 commit 905cc70

File tree

3 files changed

+14
-6
lines changed

3 files changed

+14
-6
lines changed

.devcontainer/Dockerfile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
ARG RUBY_VERSION=3.3.4
22
FROM ghcr.io/rails/devcontainer/images/ruby:$RUBY_VERSION
33

4-
RUN apt-get update && apt-get install -y postgresql-client libpq-dev
4+
RUN apt-get update -qq \
5+
&& apt-get install -y postgresql-client libpq-dev \
6+
&& apt-get clean \
7+
&& rm -rf /var/lib/apt/lists/*

app/Dockerfile

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,10 @@ ENV RAILS_ENV="production" \
1717
FROM base as build
1818

1919
# Install packages needed to build gems
20-
RUN apt-get update -qq && \
21-
apt-get install --no-install-recommends -y build-essential git libvips pkg-config libpq-dev
20+
RUN apt-get update -qq \
21+
&& apt-get install --no-install-recommends -y build-essential git libvips pkg-config libpq-dev \
22+
&& apt-get clean \
23+
&& rm -rf /var/lib/apt/lists/*
2224

2325
# Set bundler config to force ruby platform
2426
RUN bundle config set force_ruby_platform true
@@ -45,7 +47,8 @@ FROM base
4547
# Install packages needed for deployment
4648
RUN apt-get update -qq && \
4749
apt-get install --no-install-recommends -y curl libvips libpq-dev && \
48-
rm -rf /var/lib/apt/lists /var/cache/apt/archives
50+
&& apt-get clean \
51+
&& rm -rf /var/lib/apt/lists/*
4952

5053
# Copy built artifacts: gems, application
5154
COPY --from=build /usr/local/bundle /usr/local/bundle

app/Dockerfile.dev

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@ ENV RAILS_ENV="development" \
1111
PORT=3000
1212

1313
# Install packages needed to build gems
14-
RUN apt-get update -qq && \
15-
apt-get install --no-install-recommends -y build-essential git libvips pkg-config libpq-dev postgresql-client
14+
RUN apt-get update -qq \
15+
&& apt-get install --no-install-recommends -y build-essential git libvips pkg-config libpq-dev postgresql-client \
16+
&& apt-get clean \
17+
&& rm -rf /var/lib/apt/lists/*
1618

1719
# Set bundler config to force ruby platform
1820
RUN bundle config set force_ruby_platform true

0 commit comments

Comments
 (0)