Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/docker/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 在Docker上修改Rails应用程序时,如何加载源代码更改?_Ruby On Rails_Docker - Fatal编程技术网

Ruby on rails 在Docker上修改Rails应用程序时,如何加载源代码更改?

Ruby on rails 在Docker上修改Rails应用程序时,如何加载源代码更改?,ruby-on-rails,docker,Ruby On Rails,Docker,当使用Docker在开发机器上运行Rails应用程序时,once如何强制使用代码更改 我正在使用Docker测试/调整Rails应用程序(Helpy),但当我修改Rails源代码时,任何更改都会被忽略。甚至更改dockker/run.sh或调整视图上的文本 docker显然在缓存所有东西,我如何告诉docker使用我编辑的当前源代码 我试过了 docker-compose down (then up) 或 或 Dockerfile是 FROM ruby:2.4 ENV HELPY_VERSI

当使用Docker在开发机器上运行Rails应用程序时,once如何强制使用代码更改

我正在使用Docker测试/调整Rails应用程序(Helpy),但当我修改Rails源代码时,任何更改都会被忽略。甚至更改dockker/run.sh或调整视图上的文本

docker显然在缓存所有东西,我如何告诉docker使用我编辑的当前源代码

我试过了

docker-compose down (then up)

Dockerfile是

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 '128i\gem "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"]
docker-compose.yml是

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
在docker-compose.yml中,我更改了

  helpy:
    image: helpy/helpy

希望停止使用预构建的docker映像,并在开发机器上使用代码。但我对视图所做的任何更改(例如,仅将视图上的某些标题文本从“Admin Brand”更改为“My New Header”)都会被忽略。我试过了

docker-compose down
docker-compose up
同样,我尝试了docker compose构建或docker compose重启

所以Docker显然是在缓存源代码,而不是使用我编辑的源代码的“实时”版本

我经常使用Vagrant,但我对Docker很陌生,因此如果您能帮助修改Docker项目以允许本地开发更改,我将不胜感激。

如果您使用:

volumes:
  rails-assets:
    driver: local
您告诉docker创建一个卷并将数据放入其中

但如果要与容器实时同步共享本地代码,则需要执行以下操作:

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

现在,当您更改本地代码时,容器内的代码将同时更改。

您的源代码是否正确?如果没有,您应该查看它……您能显示
Dockerfile
docker-compose down
docker-compose up
volumes:
  rails-assets:
    driver: local
helpy:
    image: helpy/helpy
    restart: always
    networks:
      - front
      - back
    volumes:
      - ./local/path/to/your/code:/helpy/public