Skip to content

Commit

Permalink
feat: do multi stage build
Browse files Browse the repository at this point in the history
Signed-off-by: Robert Waffen <[email protected]>
  • Loading branch information
rwaffen committed Sep 26, 2024
1 parent 0fc4dd4 commit 3849329
Showing 1 changed file with 20 additions and 9 deletions.
29 changes: 20 additions & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ruby:3.3.5-slim-bookworm
FROM ruby:3.3.5-slim-bookworm AS builder

RUN apt update && apt install -y \
g++ \
Expand All @@ -17,19 +17,30 @@ RUN apt update && apt install -y \
tzdata \
&& rm -rf /var/lib/apt/lists/*

ENV APP_HOME /hdm
ENV RAILS_ENV production
ENV HDM_PORT 3000
ENV HDM_HOST 0.0.0.0
ENV APP_HOME=/hdm
WORKDIR $APP_HOME

COPY . $APP_HOME
COPY config/hdm.yml.template $APP_HOME/config/hdm.yml

RUN bundle check || (bundle config set --local without 'development test release' && bundle install)

###############################################################################

FROM ruby:3.3.5-slim-bookworm

ENV APP_HOME=/hdm
ENV RAILS_ENV=production
ENV HDM_PORT=3000
ENV HDM_HOST=0.0.0.0
ENV RUBYOPT="--yjit"

EXPOSE $HDM_PORT

WORKDIR $APP_HOME

COPY . $APP_HOME
COPY config/hdm.yml.template $APP_HOME/config/hdm.yml

RUN bundle check || (bundle config set --local without 'development test' && bundle install)
# copy only the needed files from the builder image
COPY --from=builder /usr/local/bundle /usr/local/bundle
COPY --from=builder $APP_HOME $APP_HOME

CMD ["sh", "-c", "/hdm/bin/entry.sh ${HDM_PORT} ${HDM_HOST}"]

0 comments on commit 3849329

Please sign in to comment.