将Discourse作为Docker Swarm服务运行

我正在尝试将 Discourse 部署为 Docker Swarm 服务。
使用官方启动器方法在单容器设置中部署 Discourse。
将所需文件从独立容器内的 /var/www/discourse 复制到主机服务器上的某个位置,以在 Swarm 服务中使用。
使用了现有的 postgre 服务器
为 Discourse 创建了一个专用的 Redis 容器
Discourse 无法启动并退出,显示:uninitialized constant Discourse::SiteSetting (NameError)
容器可以毫无问题地连接到 PostgreSQL 和 Redis。
DISCOURSE_HOSTNAME 在环境中已正确设置为 discourse.xyz。
这可能是由于缺少依赖项或资产编译中断导致的吗?
Discourse 是否需要任何修改才能在 Swarm 环境中正常运行?

version: '3.7'

services:
  app:
    image: discourse-app:latest
    user: "1000:1000"
    working_dir: /var/www/discourse
    deploy:
      replicas: 1
      restart_policy:
        condition: on-failure
      labels:
        - "traefik.enable=true"
        - "traefik.backend=discourse"
        - "traefik.docker.network=service"
        - "traefik.frontend.rule=Host:discourse.xyz"
        - "traefik.port=80"
    command:
      - "/bin/bash"
      - "-c"
      - |
        bundle config set deployment true 						&& \
        bundle config set without 'test development' 				&& \
        RAILS_ENV=production bundle install 						&& \
        RAILS_ENV=production bundle exec rake db:migrate 			&& \
        RAILS_ENV=production bundle exec rails server -b 0.0.0.0
    environment:
      DISCOURSE_DB_HOST: "postgrest1"
      DISCOURSE_DB_PORT: "5432"
      DISCOURSE_DB_USERNAME: "postgres"
      DISCOURSE_DB_PASSWORD: "****"
      DISCOURSE_DB_NAME: "discourse"
      DISCOURSE_REDIS_HOST: "redis-discourse"
      DISCOURSE_REDIS_PORT: "6379"
      DISCOURSE_REDIS_PASSWORD: "****"
      DISCOURSE_HOSTNAME: "discourse.xyz"
      DISCOURSE_DEVELOPER_EMAILS: "abc@xyz.com"
      DISCOURSE_SMTP_ADDRESS: "xyz"
      DISCOURSE_SMTP_PORT: "25"
      DISCOURSE_NOTIFICATION_EMAIL: "donotreply@xyz.com"
    networks:
      - service
    ports:
      - "8080:80"
      - "8443:443"
    volumes:
      - type: bind
        source: /discourse/discourse_files/discourse
        target: /var/www/discourse
        bind:
          propagation: rprivate

      - type: bind
        source: /discourse/shared/standalone
        target: /shared
        bind:
          propagation: rprivate

      - type: bind
        source: /discourse/shared/standalone/log/rails
        target: /data/modulusdata/infra/discourse/shared/standalone/log/rails
        bind:
          propagation: rprivate

      - type: bind
        source: /discourse/shared/standalone/log/var-log
        target: /var/log
        bind:
          propagation: rprivate

networks:
  service:
    external: true

这超出了这里的支持范围。可能出错的细微之处太多了,因此标准安装才是唯一受支持的。这里有一些提示。如果您遇到困难并且有预算,可以联系我或在 Marketplace 中提问。

您不能使用基础映像。您必须引导自己的映像并将其推送到存储库。如果您很聪明并且有很多时间,您可以让 GitHub 为您完成。

您需要将您的资产放在 S3 上(配置 S3 兼容对象存储提供商以下载)。

您是否试图让所有这些写入同一个日志文件?我只会将它们保留在容器中并忽略它们。

我认为您不需要端口 8080 和 8443——traefik 正在处理这些,对吗?Discourse 不能在非标准端口上运行。

类似这样:

./launcher bootstrap app
docker push-that-container-to-your-private-repo
./launcher start-cmd

然后您可以使用 start-cmd 中的变量来启动您的 swarm,其中包含正确的内容,以便它可以找到您的数据库、redis 等。我看到您有很多,但不确定是否都是您需要的。

2 个赞