ruby-on-rails 运行rake assets后重启docker-compose:precompile重置更改

plicqrtu  于 2023-06-25  发布在  Ruby
关注(0)|答案(1)|浏览(166)

我目前正在尝试使用Zammad开源,这是一个带有Docker-compose的帮助台票务系统。然而,我以前在非docker设置中使用过它,我编辑了html视图,并添加了一些徽标和我的团队需要的额外功能。然而,由于某些原因,我们需要很快进入基于docker的示例。
我成功地正常安装了它,并且默认的合成文件在打开容器时确实挂载了一个映像。之后,我去和应用的变化,因为我如何对我现有的设置。这些变化要求我

rake assets:precompile

并仅重新启动Rails容器。重新启动后,它工作,并反映了更改。
然而,一旦我跑了

docker-compose restart

所有的容器都重新启动(如预期的那样),但是rails服务器似乎丢弃了我所做的每一个更改,一切看起来就像我刚刚打开了一个新的容器。
我尝试过的:

  • 应用更改,重新启动rails容器,并将容器提交到自定义映像中并从中拉取。没成功
  • 编辑dockerfile,入口点脚本以应用更改,并在安装期间运行预编译。没成功

docker-compose.yml

version: '3'

services:

  zammad-backup:
    command: ["zammad-backup"]
    depends_on:
      - zammad-railsserver
      - zammad-postgresql
    entrypoint: /usr/local/bin/backup.sh
    environment:
      - BACKUP_SLEEP=86400
      - HOLD_DAYS=10
      - POSTGRESQL_USER=${POSTGRES_USER}
      - POSTGRESQL_PASSWORD=${POSTGRES_PASS}
    image: ${IMAGE_REPO}:zammad-postgresql${VERSION}
    restart: ${RESTART}
    volumes:
      - zammad-backup:/var/tmp/zammad
      - zammad-data:/opt/zammad

  zammad-elasticsearch:
    environment:
      - discovery.type=single-node
    image: ${IMAGE_REPO}:zammad-elasticsearch${VERSION}
    restart: ${RESTART}
    volumes:
      - elasticsearch-data:/usr/share/elasticsearch/data

  zammad-init:
    command: ["zammad-init"]
    depends_on:
      - zammad-postgresql
    environment:
      - MEMCACHE_SERVERS=${MEMCACHE_SERVERS}
      - POSTGRESQL_USER=${POSTGRES_USER}
      - POSTGRESQL_PASS=${POSTGRES_PASS}
      - REDIS_URL=${REDIS_URL}
    image: ${IMAGE_REPO}:zammad${VERSION}
    restart: on-failure
    volumes:
      - zammad-data:/opt/zammad

  zammad-memcached:
    command: memcached -m 256M
    image: memcached:1.6.10-alpine
    restart: ${RESTART}

  zammad-nginx:
    command: ["zammad-nginx"]
    expose:
      - "8080"
    depends_on:
      - zammad-railsserver
    image: ${IMAGE_REPO}:zammad${VERSION}
    restart: ${RESTART}
    volumes:
      - zammad-data:/opt/zammad

  zammad-postgresql:
    environment:
      - POSTGRES_USER=${POSTGRES_USER}
      - POSTGRES_PASSWORD=${POSTGRES_PASS}
    image: ${IMAGE_REPO}:zammad-postgresql${VERSION}
    restart: ${RESTART}
    volumes:
      - postgresql-data:/var/lib/postgresql/data

  zammad-railsserver:
    command: ["zammad-railsserver"]
    depends_on:
      - zammad-memcached
      - zammad-postgresql
      - zammad-redis
    environment:
      - MEMCACHE_SERVERS=${MEMCACHE_SERVERS}
      - REDIS_URL=${REDIS_URL}
    image: ${IMAGE_REPO}:zammad${VERSION}
    restart: ${RESTART}
    volumes:
      - zammad-data:/opt/zammad

  zammad-redis:
    image: redis:6.2.5-alpine
    restart: ${RESTART}

  zammad-scheduler:
    command: ["zammad-scheduler"]
    depends_on:
      - zammad-memcached
      - zammad-railsserver
      - zammad-redis
    environment:
      - MEMCACHE_SERVERS=${MEMCACHE_SERVERS}
      - REDIS_URL=${REDIS_URL}
    image: ${IMAGE_REPO}:zammad${VERSION}
    restart: ${RESTART}
    volumes:
      - zammad-data:/opt/zammad

  zammad-websocket:
    command: ["zammad-websocket"]
    depends_on:
      - zammad-memcached
      - zammad-railsserver
      - zammad-redis
    environment:
      - MEMCACHE_SERVERS=${MEMCACHE_SERVERS}
      - REDIS_URL=${REDIS_URL}
    image: ${IMAGE_REPO}:zammad${VERSION}
    restart: ${RESTART}
    volumes:
      - zammad-data:/opt/zammad

volumes:
  elasticsearch-data:
    driver: local
  postgresql-data:
    driver: local
  zammad-backup:
    driver: local
  zammad-data:
    driver: local
x759pob2

x759pob21#

在这里和那里的一些头痛之后,我找到了一个解决方案:
我做了什么:
在文件中发现它从github中提取了一个图像,下载了图像。解压tar.gz文件后,我应用了所有需要的更改,重新打包tar.gz,并编辑dockerfile以指向新映像。
在那之后,我需要强制docker-compose来重建图像。这样,即使在重新启动后,更改也是持久的。

相关问题