Home>

I want to reflect the changes in public/robots.txt

Rails is set up with docker.
Even if you change the contents of public/robots.txthttps: //localhost/robots.txtNot reflected in

It will be reflected when you enter bash in docker and change robots.txt
I think it's probably a docker volume issue,
I don't know what can be fixed and how to find out what to look for.

Corresponding source code
version: "3.8"
services: services:
  web:
    image: nginx: 1.18
    ports: ports:
      -"80:80"
    volumes:
      --./docker/nginx/default.conf:/etc/nginx/conf.d/default.conf
      --public:/myapp/public
      --log:/var/log/nginx
    depends_on:
      --app
  db:
    image: postgres: 11.0-alpine
    volumes:
      --postgres:/var/lib/postgresql/data: cached
    ports: ports:
      -"5432: 5432"
    environment: environment:
      TZ: Asia/Tokyo
  app:
    build:
      context: ..
    image: rails_app
    tty: true
    stdin_open: true
    command: bash -c "rm -f tmp/pids/server.pid&&./bin/rails s -p 3000 -b '0.0.0.0'"
    volumes:
      --.:/Myapp: cached
      --rails_cache:/myapp/tmp/cache: cached
      --node_modules:/myapp/node_modules: cached
      --yarn_cache: /usr/local/share/.cache/yarn/v6:cached
      --bundle:/bundle: cached
      --public:/myapp/public
      --log:/myapp/log
    tmpfs:
      -/ tmp
    ports: ports:
      -"3000: 3000"
    environment: environment:
    depends_on:
      --db
      --webpacker
  webpacker:
    image: rails_app
    command: ./bin/webpack-dev-server
    volumes:
      --.:/Myapp: cached
      --public:/myapp/public
      --node_modules:/myapp/node_modules: cached
    environment: environment:
    tty: false
    stdin_open: false
    ports: ports:
      -"3035:30 35"
volumes:
  rails_cache:
  node_modules:
  yarn_cache:
  postgres:
  bundle: bundle:
  public:
  log: log:
What I tried

docker-compose down -v
After doing
docker-compose up -d
It was reflected when I did.

  • Answer # 1

    Files on the host side on the host siderobots.txtYou mean editing?
    The above question didn't hit the mark. Excuse me.

    In the current definition of docker-compose.yml, the public volume managed by Docker is mounted on/webapp/public, so it looks like the file on the host side is not mounted on Docker side.

    If you delete the definition of public volume from the definition of volumes of the web container and do as follows, the question will behave as intended.

    volumes:
      --.:/Webapp: cached

    Below is a snake leg.

    However, if you do this, the output to the public volume that is also mounted in the webpacker container will not be readable by the web container (nginx), so I think that webpacker will not work as intended.

    You can meet the requirement to edit robots.txt on the guest side, but I think this is what you want to achieve in the end.

    I hope it gives you some hints.