DISCOURSE_CDN_URL이 rebuild/restore를 방해합니다

수정: 글쎄요, 18시간이 걸렸지만 DISCOURSE_CDN_URL을 정의하면 (최소한) 이 사이트가 복원 후 재빌드되거나 작동하지 않는 문제를 방지하는 것 같습니다. 다음으로 테스트할 것은 DISCOURSE_CDN_URL 없이 빌드를 수행한 후, 해당 환경 변수가 설정된 상태로 컨테이너를 실행해 보는 것입니다.

이전에 알고 있던 것들

어제 이 문제가 있었지만 사라진 줄 알았으나, 알고 보니 1개월 전의 데이터베이스를 복원한 것이었습니다. 최근 데이터베이스를 복원하면 사이트가 멈춥니다.

사이트를 처음부터 빌드할 수 있으므로 코드나 표준 플러그인의 문제는 아닙니다. 하지만 데이터베이스를 복원한 후 사이트가 다운되며, 데이터베이스를 삭제하더라도 재빌드가 불가능합니다. 따라서 문제는 JavaScript를 압축할 때 읽히는 파일 안에 있는 것 같습니다.

onebox.scss의 모든 background: image-url을 제거해 보았더니 사이트 재빌드는 가능해졌지만, 디스플레이가 완전히 엉망이 되어 해당 에러는 문제의 원인이라기보다 증상인 것으로 보입니다.

데이터베이스(와 파일)를 복원하거나 재빌드할 때 rails 로그에 다음과 같은 에러가 발생합니다.


I, [2019-12-22T21:21:25.532604 #1]  INFO -- : > cd /var/www/discourse && su discourse -c 'bundle exec rake db:migrate'
NOTE: Inheriting Faraday::Error::ClientError is deprecated; use Faraday::ClientError instead. It will be removed in or after version 1.0
Faraday::Error::ClientError.inherited called from /var/www/discourse/plugins/discourse-github/gems/2.6.5/gems/octokit-4.14.0/lib/octokit/middleware/follow_redirects.rb:14.
> Seeding dark and light themes
[SassC::FunctionsHandler] undefined method `protocol' for nil:NilClass
rake aborted!
Discourse::ScssError: Error: error in C function image-url: undefined method `protocol' for nil:NilClass
        on line 90 of app/assets/stylesheets/common/base/onebox.scss, in function `image-url`
        from line 90 of app/assets/stylesheets/common/base/onebox.scss, in mixin `onebox-favicon`
        from line 110 of app/assets/stylesheets/common/base/onebox.scss
        from line 34 of app/assets/stylesheets/common.scss
        from line 1 of desktop.scss
>>     background: image-url("favicons/#{$image}.png") no-repeat 0% 50%;

   ----------------^
/var/www/discourse/lib/stylesheet/manager.rb:183:in `rescue in compile'
/var/www/discourse/lib/stylesheet/manager.rb:171:in `compile'
/var/www/discourse/lib/stylesheet/manager.rb:80:in `block (2 levels) in stylesheet_details'
/var/www/discourse/lib/stylesheet/manager.rb:66:in `each'
/var/www/discourse/lib/stylesheet/manager.rb:66:in `block in stylesheet_details'
/var/www/discourse/lib/stylesheet/manager.rb:64:in `synchronize'
/var/www/discourse/lib/stylesheet/manager.rb:64:in `stylesheet_details'
/var/www/discourse/lib/stylesheet/manager.rb:34:in `stylesheet_data'
/var/www/discourse/app/models/theme.rb:280:in `block in refresh_message_for_targets'
/var/www/discourse/app/models/theme.rb:279:in `map'
/var/www/discourse/app/models/theme.rb:279:in `refresh_message_for_targets'
/var/www/discourse/app/models/theme.rb:267:in `notify_theme_change'
/var/www/discourse/app/models/theme.rb:275:in `notify_theme_change'
/var/www/discourse/app/models/theme.rb:61:in `block in <class:Theme>'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/activesupport-6.0.1/lib/active_support/callbacks.rb:429:in `instance_exec'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/activesupport-6.0.1/lib/active_support/callbacks.rb:429:in `block in make_lambda'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/activesupport-6.0.1/lib/active_support/callbacks.rb:239:in `block in halting_and_conditional'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/activesupport-6.0.1/lib/active_support/callbacks.r

@pfaffman S3 설정을 시도하면서 다른 문제들과 씨름하다가 마침내 이 동일한 문제에 부딪혔습니다. 원인을 찾아내셨나요?

수정했습니다. CDN URL 앞에 http://를 붙여야 한다는 걸 꼭 확인하세요 :facepalm:

즉, DISCOURSE_CDN_URL=your-cdn-url.com 대신 DISCOURSE_CDN_URL=http://your-cdn-url.com으로 설정해야 합니다.

디버깅에 2시간이나 낭비했네요 :smiley:

음, @eviltrout 이거 여기에 어떤 경고 메시지를 추가할 수 있을까요? 앞으로 사람들이 이런 문제를 겪지 않도록요.

프로토콜을 추가하지 않으면 경고가 표시됩니다:

하지만 ENV 변수를 이렇게 사용하는 멍청한 사람들(나 포함)은 여전히 문제를 겪을 것입니다. 경고 메시지를 출력하는 것과 함께 https://를 앞에 붙이는 데 어떤 단점이 있을까요?

GlobalSetting은 ENV 변수를 Discourse로 가져오는 객체이므로, 그렇게 하면 경고 메시지도 함께 표시되어야 합니다.

나도 이 함정에 빠진 게 꽤 부끄럽습니다! :laughing:

기억이 맞다면, 크리스마스 휴가 기간에 18시간을 그걸에 쏟아부었습니다. :frowning_face: