Skip to content

Commit

Permalink
Reimplement multi-stage build
Browse files Browse the repository at this point in the history
  • Loading branch information
jgarber623 committed Apr 10, 2024
1 parent 2b2f5f3 commit 44be05e
Showing 1 changed file with 24 additions and 3 deletions.
27 changes: 24 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
FROM ruby:3.3.0-slim-bookworm
################################################################################
# Base Stage
################################################################################
FROM ruby:3.3.0-slim-bookworm AS base-stage

EXPOSE 8080

Expand All @@ -12,15 +15,26 @@ WORKDIR /usr/src/app
# Install system dependencies.
RUN apt update && \
apt install --no-install-recommends --yes \
g++ \
libjemalloc2 \
make \
&& \
rm -rf /var/lib/apt/lists/*

# Configure memory allocation.
ENV LD_PRELOAD="/usr/lib/x86_64-linux-gnu/libjemalloc.so.2"

################################################################################
# Build Stage
################################################################################
FROM base-stage AS build-stage

# Install system dependencies.
RUN apt update && \
apt install --no-install-recommends --yes \
g++ \
make \
&& \
rm -rf /var/lib/apt/lists/*

COPY .ruby-version Gemfile Gemfile.lock ./

RUN bundle install \
Expand All @@ -32,4 +46,11 @@ COPY . .

RUN bundle exec rake assets:precompile

################################################################################
# Production
################################################################################
FROM base-stage AS production

COPY --from=build-stage /usr/src/app ./

CMD ["bundle", "exec", "puma", "--config", "config/puma.rb"]

0 comments on commit 44be05e

Please sign in to comment.