Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 8 additions & 16 deletions ruby/Dockerfile
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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"]
Loading