2 years ago

#32024

test-img

Aniket Tiwari

app changes not reflecting while runnning docker image

I am running a docker image and whenever I make any new changes inside the app folder such as in controllers or views the changes are not relfected in browser. Everytime I need to create a new image inorder to reflect the changes.

Dockerfile

FROM ruby:3.0

USER root

RUN apt-get  update && apt-get install -y build-essential libpq-dev nodejs

RUN rm -rf .idea \
    rm -rf .gitignore

ENV LC_ALL=en_US.UTF-8
ENV LANG=en_US.UTF-8
ENV LANGUAGE=en_US.UTF-8

RUN mkdir -p /app
WORKDIR /app

COPY Gemfile Gemfile.lock ./

RUN gem install bundler && bundle install --jobs 20 --retry 5

COPY . ./

# Adding a non root user
RUN groupadd --system non-root-user
RUN useradd -u 1001 --system non-root-user -g non-root-user -d /home/non-root-user -m -s /bin/bash
RUN chown -R non-root-user /app
RUN chmod -R 777 /app

# Switching to non-root user 'non-root-user'
USER non-root-user

# Exposing port 3010
EXPOSE 3010

# Default entry point (i.e. will be appened before every command being executed)
ENTRYPOINT ["sh", "./config/docker/startup.sh"]

startup.sh

#! /bin/sh
echo "Creating tmp/pids..."
mkdir -p tmp/pids/


# Start Application
echo "Starting up puma(app server)..."
bundle exec puma -p 3010 -C ./config/puma.rb

I have updated the below configuration in my development.rb still no success

config.file_watcher = ActiveSupport::FileUpdateChecker

Ruby - 3.0.0
Rails - 6.1

I am running the container with the below command

docker run -it -p 3010:3010 -e RAILS_ENV=development  my_image

ruby-on-rails

ruby

docker

ruby-on-rails-6.1

0 Answers

Your Answer

Accepted video resources