When modifying a Rails app on Docker, how get source code changes to load?

Multi tool use
Multi tool use
The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP


When modifying a Rails app on Docker, how get source code changes to load?



When running a Rails app on a development machine, using Docker, how does once force code changes to be used?



I'm using Docker to test out / tweak a Rails app (Helpy), but when I modify the Rails source any changes just get ignored. Even changes to dockker/run.sh or tweaking text on a view.



So docker is apparently caching everything, how to I tell docker to use the current source code that I have edited?



I tried


docker-compose down (then up)



or


docker-compose restart



or


docker-compose build



The Dockerfile is


FROM ruby:2.4

ENV HELPY_VERSION=master
RAILS_ENV=production
HELPY_HOME=/helpy
HELPY_USER=helpyuser
HELPY_SLACK_INTEGRATION_ENABLED=true

RUN apt-get update
&& apt-get upgrade -y
&& apt-get install -y nodejs postgresql-client imagemagick --no-install-recommends
&& rm -rf /var/lib/apt/lists/*
&& useradd --no-create-home $HELPY_USER
&& mkdir -p $HELPY_HOME
&& chown -R $HELPY_USER:$HELPY_USER $HELPY_HOME /usr/local/lib/ruby /usr/local/bundle

WORKDIR $HELPY_HOME

USER $HELPY_USER

RUN git clone --branch $HELPY_VERSION --depth=1 https://github.com/helpyio/helpy.git .

# add the slack integration gem to the Gemfile if the HELPY_SLACK_INTEGRATION_ENABLED is true
# use `test` for sh compatibility, also use only one `=`. also for sh compatibility
RUN test "$HELPY_SLACK_INTEGRATION_ENABLED" = "true" && sed -i '128igem "helpy_slack", git: "https://github.com/helpyio/helpy_slack.git", branch: "master"' $HELPY_HOME/Gemfile

RUN bundle install

RUN touch /helpy/log/production.log && chmod 0664 /helpy/log/production.log

# Due to a weird issue with one of the gems, execute this permissions change:
RUN chmod +r /usr/local/bundle/gems/griddler-mandrill-1.1.3/lib/griddler/mandrill/adapter.rb

# manually create the /helpy/public/assets folder and give the helpy user rights to it
# this ensures that helpy can write precompiled assets to it
RUN mkdir -p $HELPY_HOME/public/assets && chown $HELPY_USER $HELPY_HOME/public/assets

VOLUME $HELPY_HOME/public

COPY docker/database.yml $HELPY_HOME/config/database.yml
COPY docker/run.sh $HELPY_HOME/run.sh

CMD ["./run.sh"]



And the docker-compose.yml is


version: '2'

services:
frontend:
image: webwurst/caddy
volumes:
- ./docker/Caddyfile:/etc/caddy/Caddyfile
- ./certs:/etc/caddy/certs
volumes_from:
- helpy:ro
ports:
- "80:80"
- "443:443"
networks:
- front
restart: always
depends_on:
- helpy
helpy:
image: helpy/helpy
restart: always
networks:
- front
- back
volumes:
- rails-assets:/helpy/public
env_file: docker/.env
#environment:
# - DO_NOT_PREPARE=true
depends_on:
- postgres
postgres:
image: postgres:9.4
restart: always
networks:
- back
env_file: docker/.env
volumes:
- ./postgres:/var/lib/postgresql/data

volumes:
rails-assets:
driver: local

networks:
front:
driver: bridge
back:
driver: bridge



In docker-compose.yml I changed


helpy:
image: helpy/helpy



to


helpy:
build: .



expecting that to stop using the pre-built docker image, and use the code on the development machine. But any changes I make to a view (for example just changing some heading text on a view from "Admin Brand" to "My New Header") get ignored. I tried


docker-compose down
docker-compose up



Similarly I tried docker-compose build or docker-compose restart



So Docker is apparently caching the source, not using the "live" version of the source that I edit.



I've used Vagrant quite a lot but am very new to Docker so any help on modifying a Docker project to allow local development changes would be appreciated.





Your source code is in a volume right ? If not, you should look at it...
– ponsfrilus
3 hours ago





Can you show the Dockerfile?
– gasc
2 hours ago


Dockerfile




1 Answer
1



If you use:


volumes:
rails-assets:
driver: local



You tell to docker create a volume and put your data inside.



But if you want to share your local code in real-time sync with the container, you need to do that:


helpy:
image: helpy/helpy
restart: always
networks:
- front
- back
volumes:
- ./local/path/to/your/code:/helpy/public



Now when you change your local code, simultaneously the code will change inside the container.






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

aoa3y,a9jonyWeeU5kola7jwnMPf4o,vDQb9ACi9UmZZcntZs2EA
L7l,mdBblB9U0CMZGSY99TtAue0 k,ZVNGyehs4GN,y6aiOCX,FAyanfBPJFXOkWQd1P,5RltI

Popular posts from this blog

Makefile test if variable is not empty

Visual Studio Code: How to configure includePath for better IntelliSense results

Will Oldham