Performance: Docker deployment
Docker deployment affects the initial page load speed and server response time by controlling how the Rails app and its dependencies are packaged and started.
FROM ruby:3.1-slim RUN apt-get update && apt-get install -y --no-install-recommends nodejs yarn WORKDIR /app COPY Gemfile Gemfile.lock ./ RUN bundle install --without development test COPY . . CMD ["rails", "server", "-b", "0.0.0.0"]
FROM ruby:3.1 RUN apt-get update && apt-get install -y nodejs COPY . /app WORKDIR /app RUN bundle install CMD ["rails", "server", "-b", "0.0.0.0"]
| Pattern | Image Size | Startup Time | Resource Usage | Verdict |
|---|---|---|---|---|
| Full Ruby image with all packages | Large (700MB+) | Slow (10+ sec) | High CPU & Memory | [X] Bad |
| Slim Ruby image with cached dependencies | Smaller (400MB) | Faster (5 sec) | Lower CPU & Memory | [OK] Good |
FROM ruby:3.1 WORKDIR /app COPY . . RUN bundle install EXPOSE 3000 CMD ["rails", "server", "-b", "0.0.0.0"]
http://localhost:3000 on your host machine?FROM ruby:3.1 WORKDIR /app COPY . . RUN bundle install EXPOSE 3000 CMD ["rails", "server"]
http://localhost:3000?rails server -b 0.0.0.0 mounts code and binds correctly. Others miss volume or binding, causing no reload or no access.Pass the test and this pattern moves unknown