Skip to content

Commit

Permalink
docker: Clean up build and actually copy over the code
Browse files Browse the repository at this point in the history
I'm not sure how it was working before but we weren't copying the
application code into the container. This does that and moves things
around to better support development (only install when package files
are updated for example).
  • Loading branch information
gaffneyc committed May 22, 2024
1 parent 2a4f436 commit 54020c7
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 13 deletions.
44 changes: 31 additions & 13 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
# syntax=docker/dockerfile:1
ARG RUBY_VERSION=3.3.1

FROM ruby:$RUBY_VERSION

RUN apt-get update -qq && apt-get install -y postgresql-client
WORKDIR /myapp
COPY Gemfile /myapp/Gemfile
COPY Gemfile.lock /myapp/Gemfile.lock
COPY mruby_build_config.rb /myapp/mruby_build_config.rb
RUN bundle install
RUN apt-get update -qq && apt-get upgrade -y && \
apt-get install -y libcurl4 postgresql-client tmux && \
rm -rf /var/lib/apt/lists/* /var/cache/apt/archives/*

# Update Rubygems and Bundler
RUN \
gem update --system --no-document && \
gem install --no-document bundler

WORKDIR /app
COPY mruby_build_config.rb /app/mruby_build_config.rb

# mruby
RUN git clone https://github.com/mruby/mruby.git && cd mruby && git checkout 3.0.0 && MRUBY_CONFIG="/myapp/mruby_build_config.rb" rake && mv ./bin/mruby /usr/bin/mruby && /usr/bin/mruby -v
RUN git clone https://github.com/mruby/mruby.git && cd mruby && git checkout 3.0.0 && MRUBY_CONFIG="/app/mruby_build_config.rb" rake && mv ./bin/mruby /usr/bin/mruby && /usr/bin/mruby -v

# Overmind
RUN apt-get install -y tmux

ARG OVERMIND_VERSION=2.5.1
RUN curl -sL "https://github.com/DarthSim/overmind/releases/download/v${OVERMIND_VERSION}/overmind-v${OVERMIND_VERSION}-linux-arm64.gz" -o overmind.gz \
&& gunzip overmind.gz \
Expand All @@ -30,10 +32,26 @@ RUN curl -sL https://github.com/nodenv/node-build/archive/master.tar.gz | tar xz
corepack enable && \
rm -rf /tmp/node-build-master

# Install Ruby dependencies
COPY Gemfile Gemfile.lock /app/
RUN bundle install && \
bundle exec bootsnap precompile --gemfile && \
rm -rf ~/.bundle/ $BUNDLE_PATH/ruby/*/cache $BUNDLE_PATH/ruby/*/bundler/gems/*/.git

# Copy application code
COPY --link . .

# Install NodeJS dependencies
RUN npm install --package-lock-only

# Precompile bootsnap code for faster boot times
RUN \
bundle exec bootsnap precompile app/ lib/ && \
bundle exec rake assets:precompile && \
bundle binstubs --force bundler

# Add a script to be executed every time the container starts.
COPY entrypoint.sh /usr/bin/
RUN chmod +x /usr/bin/entrypoint.sh
ENTRYPOINT ["entrypoint.sh"]
ENTRYPOINT ["/app/entrypoint.sh"]
EXPOSE 3000

ENV MRUBY_BIN=/usr/bin/mruby
Expand Down
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ gem "propshaft"
gem "actionpack-page_caching"
gem "active_model_serializers"
gem "bigdecimal"
gem "bootsnap", require: false
gem "dotenv-rails"
gem "honeybadger"
gem "pagy"
Expand Down
4 changes: 4 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ GEM
base64 (0.2.0)
benchmark-ips (2.13.0)
bigdecimal (3.1.5)
bootsnap (1.18.3)
msgpack (~> 1.2)
builder (3.2.4)
capybara (3.39.2)
addressable
Expand Down Expand Up @@ -204,6 +206,7 @@ GEM
mini_histogram (0.3.1)
mini_mime (1.1.5)
minitest (5.21.1)
msgpack (1.7.2)
multi_json (1.15.0)
mutex_m (0.2.0)
net-imap (0.4.9.1)
Expand Down Expand Up @@ -375,6 +378,7 @@ DEPENDENCIES
actionpack-page_caching
active_model_serializers
bigdecimal
bootsnap
cssbundling-rails
cuprite
derailed
Expand Down

0 comments on commit 54020c7

Please sign in to comment.