Skip to content

Commit

Permalink
Merge pull request #455 from betadots/container
Browse files Browse the repository at this point in the history
feat: do multi stage build
  • Loading branch information
rwaffen authored Sep 30, 2024
2 parents 86a4d3d + 3632cc3 commit 5edd8ee
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 5edd8ee

Please sign in to comment.