DockerコンテナでSMTPを設定する

Helmチャート経由でDiscourseをデプロイすると、

helm repo add bitnami https://charts.bitnami.com/bitnami
helm install my-release bitnami/discourse

意図したとおりに動作しますが、Dockerコンテナ内のSMTPメール設定を変更できません。

こちらを再現しようとすると、コンテナに移動して

cd /opt/bitnami/discourse/config

を実行します。このディレクトリで discourse.conf ファイルを見つけますが、例えば vi が利用できないと表示されるため、変更できません。

何か提案はありますか?

フォーラムで尋ねることもできますが、閉鎖されています。

または、標準インストールをして、ここでヘルプを得ることもできます。

環境変数を設定できるかもしれません。例を参照してください。

@pfaffman さん、ご入力ありがとうございます。

BitnamiのHelmチャートに環境変数を渡す方法がわかりました。

トランザクションメールのプロバイダーであるSendinblueのSMTP認証情報がありますが、

Dsicourseコンテナに渡す必要がある環境変数がどのようなものかご存知ですか?

通常のGmailアカウントを使用してメールを送信しようとすると、利用規約違反となり、(その他の多くの理由により)機能しません。

SMTP環境変数の例は、以下にあります。

「いいね!」 1

Hi @pfaffman @Falco
ありがとうございます。

環境変数は以下のようになっています。

discourse:
  extraEnvVars:
    - name: DISCOURSE_SMTP_ADDRESS
      value: "smtp-relay.sendinblue.com"
    - name: DISCOURSE_SMTP_PORT
      value: "587"
    - name: DISCOURSE_NOTIFICATION_EMAIL
      value: "no-reply@my-domain.com"
    - name: DISCOURSE_SMTP_USER_NAME
      value: "my-email@googlemail.com"
    - name: DISCOURSE_SMTP_PASSWORD
      value: "my-pw"
    - name: DISCOURSE_SMTP_DOMAIN
      value: "my-domain.com"

その後、コンテナが起動しました。管理パネルからGmailアカウントにテストメールを送信しようとしました。結果は以下の通りです。

現時点では機能していません。

Discourseコンテナのログは以下の通りです。

Processing by Admin::UsersController#show as JSON
  Parameters: {"id"=>"1"}
Completed 200 OK in 1978ms (Views: 0.6ms | ActiveRecord: 0.0ms | Allocations: 195416)
Started GET "/groups/search.json" for 10.0.0.50 at 2022-08-10 11:55:05 +0000
Processing by GroupsController#search as JSON
Completed 200 OK in 1189ms (Views: 0.5ms | ActiveRecord: 0.0ms | Allocations: 133325)
Started GET "/admin/email.json" for 10.0.0.50 at 2022-08-10 11:55:17 +0000
Processing by Admin::EmailController#index as JSON
Completed 200 OK in 23ms (Views: 1.2ms | ActiveRecord: 0.0ms | Allocations: 864)
Started POST "/admin/email/test" for 10.0.0.50 at 2022-08-10 11:55:20 +0000
Processing by Admin::EmailController#test as */*
  Parameters: {"email_address"=>"test@gmail.com"}
Completed 422 Unprocessable Entity in 20ms (Views: 1.1ms | ActiveRecord: 0.0ms | Allocations: 2037)
Started GET "/about.json" for 10.0.0.47 at 2022-08-10 11:55:46 +0000
Processing by AboutController#index as JSON
Completed 200 OK in 67ms (Views: 0.3ms | ActiveRecord: 0.0ms | Allocations: 9503)
Started GET "/site/basic-info.json" for 10.0.0.47 at 2022-08-10 11:55:46 +0000
Processing by SiteController#basic_info as JSON
Completed 200 OK in 254ms (Views: 0.5ms | ActiveRecord: 0.0ms | Allocations: 33103)
Started GET "/site/basic-info.json" for 10.0.0.47 at 2022-08-10 11:55:47 +0000
Processing by SiteController#basic_info as JSON
Completed 200 OK in 80ms (Views: 0.8ms | ActiveRecord: 0.0ms | Allocations: 4260)

他に何かできることはありますか?

実行中のコンテナに入り、以下を実行して、発生する例外を調べて、手がかりを得ることができます。

message = TestMailer.send_test("test@gmail.com")
Email::Sender.new(message, :test_message).send
「いいね!」 1

これは最初の行から取得したものです

bash: syntax error near unexpected token `('

まず、レールコンソールにドロップする必要があります。Discourse ディレクトリに移動し、「rails c」と入力してください。

「いいね!」 1

これが出力されます

root@discourse-69c7f5475c-h9qf5:/opt/bitnami/discourse# rails c
bash: rails: command not found
root@discourse-69c7f5475c-h9qf5:/opt/bitnami/discourse# ls
Brewfile         Gemfile.lock  adminjs  config.ru                  docs                 lefthook.yml  package.json             plugins  test            yarn.lock
CONTRIBUTING.md  LICENSE.txt   app      d                          images               lib           passenger.3000.pid.lock  public   tmp
COPYRIGHT.md     README.md     bin      db                         install-imagemagick  licenses      passenger.8080.pid       script   translator.yml
Gemfile          Rakefile      config   discourse.sublime-project  jsapp                log           passenger.8080.pid.lock  spec     vendor

実行中です

RAILS_ENV=production bundle exec rails c

irb(main):002:0> message = TestMailer.send_test("test@gmail.com")
Traceback (most recent call last):
        2: from app/mailers/test_mailer.rb:7:in `send_test'
        1: from lib/email/build_email_helper.rb:8:in `build_email'
ArgumentError (:arguments expected to be an Array of individual string args)

また、これも機能しません。

root@discourse-69c7f5475c-h9qf5:/opt/bitnami/discourse# RAILS_ENV=production bundle exec rails c message = TestMailer.send_test("test@gmail.com")
bash: syntax error near unexpected token `('

何か間違っていますか?

私の環境では問題なく動作します:

[5] pry(main)> message = TestMailer.send_test("test@gmail.com")
  TranslationOverride Exists? (0.8ms)  SELECT 1 AS one FROM "translation_overrides" WHERE "translation_overrides"."locale" = 'en' AND "translation_overrides"."translation_key" = 'test_mailer.subject_template' LIMIT 1
  (0.2ms)  SELECT "translation_overrides"."translation_key", "translation_overrides"."value" FROM "translation_overrides" WHERE "translation_overrides"."locale" = 'en'
TestMailer#send_test: processed outbound mail in 259.9ms
=> #<Mail::Message:212740, Multipart:false, Headers:<From: "Discourse" <noreply@unconfigured.discourse.org>>, <Reply-To: "Discourse" <noreply@unconfigured.discourse.org>>, <To: test@gmail.com>, <Subject: [Discourse] Email Deliverability Test>, <Mime-Version: 1.0>, <Content-Type: text/plain>, <X-Auto-Response-Suppress: All>, <Auto-Submitted: auto-generated>>

Bitnamiによってパッケージ化された#unsupported-installを使用しているため、微妙な点で破損していることが予想されます。ここではそのようなインストールはサポートしていないため、GitHub · Where software is built で独自のサポートチャネルに問い合わせる必要があります。

「いいね!」 1

Falcoさん、ご返信ありがとうございます。

サポートされていないインストールとはどういう意味ですか?サポートされているインストールなら喜んで行います。:slight_smile:

Helmチャートで全て完了できますか?

できません。公式のインストールのみサポートされています。Can Discourse ship frequent Docker images that do not need to be bootstrapped? を参照してください。

先週、誰かの K8s インストールを手伝いましたが、彼らのツールを使用してセットアップするのに、私と数名の優秀なエンジニアで 6 時間以上かかりました(私なしの時間を含めると 10 時間だったかもしれませんが)。

helm chart から起動するイメージの作成を検討しましたが、まだ行っていません。予算がある場合は、プライベートメッセージまたはメールでご連絡いただければ、お手伝いできるかもしれません。

「いいね!」 2