Recently we have moved the rails application to docker for development. I am using MacBook Pro (M1, 2020), OS Version: 12.0.1. Now the application works, but that is extremely slow on local machine, is there anything we can do here to improve the performance, or are we doing something incorrectly?
Rails Version
rails (5.2.8.1)
Dockerfile
FROM ruby:2.5.9
ENV INSTALL_PATH /opt/app
RUN mkdir -p $INSTALL_PATH
RUN apt-get update && apt-get install -y \
# curl \
# chromium \
build-essential \
libpq-dev \
curl -sL https://deb.nodesource.com/setup_14.x | bash - && \
apt-get update && apt-get install -y nodejs
RUN gem install bundler -v 2.3.26
COPY Gemfile Gemfile
COPY Gemfile.lock Gemfile.lock
RUN bundle config build.nokogiri --use-system-libraries
RUN bundle install
WORKDIR /opt/app/core-project
VOLUME ["$INSTALL_PATH/public"]
# For Rails
EXPOSE 4000
config/database.yml
development:
adapter: postgresql
url: postgresql://postgres@host.docker.internal:5432/coredb?encoding=utf8&pool=5&timeout=5000
docker-compose.yml
version: "3.7"
services:
redis:
image: redis:6.2
rails-server:
build:
context: .
args:
USER_ID: "${USER_ID:-1000}"
GROUP_ID: "${GROUP_ID:-1000}"
command: ["bundle", "exec", "rails", "s", "-b", "0.0.0.0"]
depends_on:
- redis
volumes:
- type: bind
source: ./
target: /opt/app/core-project
ports:
- '4000:3000'
env_file:
- .env
sidekiq:
build:
context: .
args:
USER_ID: "${USER_ID:-1000}"
GROUP_ID: "${GROUP_ID:-1000}"
command: ["bundle", "exec", "sidekiq"]
depends_on:
- redis
volumes:
- type: bind
source: ./
target: /opt/app/core-project
env_file:
- .env
application.rb
# Added to resolve the segmentation issue when running the application in Docker.
config.assets.configure do |env|
env.export_concurrent = false
end