Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: do multi stage build #455

Merged
merged 1 commit into from
Sep 30, 2024
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
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}"]
Loading