스테이징 서버 설정하기

스테이징 서버를 설정할 때 도움이 되는 몇 가지 팁이 있습니다.

스테이징 서버란?

스테이징 서버는 기본적으로 프로덕션 사이트의 클론입니다. 이 역시 서버에 위치하며 동일한 방식으로 작동합니다. 일반적인 Discourse 사이트와 마찬가지로 Docker 컨테이너 내에서 실행됩니다.

이것은 위험한 사항을 시도하거나, 사용자에게 쉽게 숨길 수 없는 사항을 시험해 볼 수 있는 장소를 제공하기 위해 존재합니다. Discourse Advertising Plugin (Ads) 를 사용하여 광고를 시험하거나, 포럼 가져오기나 병합과 같은 특별한 작업을 수행하려는 경우 매우 유용합니다.

이것은 개발 서버와 대비됩니다. 개발 서버는 일반적으로 개발자가 안전하게 코드를 조정할 수 있도록 쉽게 접근할 수 있는(또는 샌드박싱된) 장소에서 실행됩니다.

무엇이 필요한가요?

  1. 표준 셀프호스팅 설치를 위해 필요한 모든 것

  2. S3 백업이 설정되어 있다면 작업이 훨씬 쉬워집니다

    • 그렇지 않다면 SSH를 통해 서버로 대용량 파일을 넣고 빼는 방법이 필요합니다

단계

원하는 대로 서버를 설정하세요

일반적으로 Digital Ocean에 호스팅된 가상 Ubuntu 서버를 사용하지만, 익숙한 도구를 사용하면 됩니다.

Discourse 설치

이 가이드(또는 dashboard.literatecomputing.com)를 통해 설치합니다. ‘쓰레기’ 이메일 자격 증명을 사용하는 것을 권장합니다(이메일이 작동할 필요가 없거나 원하지 않기 때문이죠).

설치된 것이 작동하는지 확인하세요:

관리자 계정 생성 (필요한 경우)

명령줄에서 관리자 계정을 설정합니다. 이렇게 하면 이메일을 통한 인증 과정을 생략할 수 있습니다.

./launcher enter app
rake admin:create

명령줄에서 백업으로 복원할 수 있으므로, 설치 테스트를 제외하면 엄밀히 말해서 필수 사항은 아닙니다.

app.yml 편집 및 몇 가지 조정 추가

  1. 원래 app.yml의 사본을 만들어 두는 것이 좋습니다(저는 app.vanilla.yml이라고 부릅니다). 문제를 일으켰을 때 되돌릴 수 있습니다.

  2. env 섹션의 끝에 다음 줄을 추가하세요:

      ## Staging server specific settings
      DISCOURSE_BACKUP_FREQUENCY: 0
      DISCOURSE_LOGIN_REQUIRED: true
      DISCOURSE_DISABLE_EMAILS: 'yes'
      DISCOURSE_S3_DISABLE_CLEANUP: true
      DISCOURSE_ALLOW_RESTORE: true
    
  3. S3(또는 유사한) 백업이 구성되어 있다면 이것도 추가하세요(메인 사이트의 설정을 사용하세요)

      ## S3 Configuration
      DISCOURSE_S3_ACCESS_KEY_ID: 'your_key'
      DISCOURSE_S3_SECRET_ACCESS_KEY: 'your_secret'
      DISCOURSE_BACKUP_LOCATION: 's3'
      DISCOURSE_S3_BACKUP_BUCKET: 'your_backups_location'
      DISCOURSE_S3_REGION: 'your_s3_region'
      DISCOURSE_S3_DISABLE_CLEANUP: true
    

    그리고 S3 업로드도 수행하고 있다면:

      DISCOURSE_ENABLE_S3_UPLOADS: true
      DISCOURSE_S3_UPLOAD_BUCKET: 'your_uploads_location' 
    

4.在那里 계신 동안 프로덕션 사이트에 있는 것과 동일한 플러그인을 추가하는 것도 좋습니다.

  1. 재빌드 수행

    • ./launcher rebuild app

스테이징 서버 관리

이제 S3 백업에 연결되어 있지만(백업을 덮어쓰지 않음), 복원이 쉽고, 어떤 상황에서도 누구에게도 이메일을 보내지 못하는 스테이징 서버를 갖추게 되었습니다. 완벽합니다!

새로운 백업을 스테이징 서버로 복원하고 마음껏 작업할 수 있습니다. 결과물이 마음에 들지 않으면 단순히 다시 복원하면 됩니다.

켜기 또는 끄기

스테이징 서버를 ‘켜진’ 상태로 장기간 두면 Google에 색인될 위험이 있으며, 사용자가 실수로 프로덕션 대신 여기에 로그인할 수 있습니다. 자격 증명은 프로덕션 사이트의 클론이므로 이는 매우 가능성이 높습니다.

이 두 가지 문제를 완화하는 간단한 방법은 Discourse를 단순히 꺼두는 것입니다:

 ./launcher stop app

그리고 사용 가능하도록 다시 켜려면:

./launcher restart app

업데이트

플러그인과 코드의 관점에서 정렬이 유지되도록 하려면 스테이징 서버와 프로덕션 사이트 모두를 동시에 업데이트/재빌드해야 합니다. app.yml 변경 사항도 마찬가지입니다.

S3를 사용하지 않는다면 백업을 서버 간에 수동으로 이동해야 합니다. 그리고 그것들은 큽니다!

테스트 서버 시드 데이터 생성

스테이징 서버가 필요하다면, Restore를 통해 실제 포럼의 실제 데이터로 채워 넣어야 합니다. 때로는 특정 데이터가 문제를 일으키는 원인이며, 다른 데이터 세트로 포럼을 테스트하면 잘못된 희망을 줄 수 있습니다.

그러나 Discourse가 어떤 모습인지 확인하기 위한 테스트 서버가 필요하다면, 가짜 데이터로 확인해 보고 싶을 수 있습니다. 그렇다면 이렇게 할 수 있습니다:

./launcher enter app
ALLOW_DEV_POPULATE=1 bundle install
ALLOW_DEV_POPULATE=1 rake dev:populate

이것은 포럼에 가짜 데이터를 시드하여 원하는 테마와 플러그인으로 어떤 모습인지 볼 수 있게 해줍니다. 아직 포럼을 시작하지 않았다면, 이것이 어떤 모습일지 약간의 아이디어를 얻을 수 있습니다.

2단계 인증 관리

메인 사이트의 계정 사용자 이름/비밀번호는 스테이징 사이트에서도 잘 작동해야 하지만, 2FA의 경우 그렇게 깔끔하지 않습니다. 문제가 발생하면 2FA를 끄세요:

./launcher enter app
rake users:disable_2fa[<USERNAME>]
32개의 좋아요

Nathan, a great idea to put this guide together.

Maybe I’ve missed it, but what step here disables email?

5개의 좋아요

Good question. Putting in junk SMTP credentials absolutely prevents it, but it would make sense to turn off emails as well with:

DISCOURSE_DISABLE_EMAILS = yes

Also, that is turned on automatically when you do a restore so it isn’t really necessary.

8개의 좋아요

Added some instructions for turning off the app to the OP.

2개의 좋아요

Right, and, it’s often nice to be able to get a login link, so, I’d recommend

 DISCOURSE_DISABLE_EMAILS = 'non-staff'
6개의 좋아요

How about a section on creating fake users? Some admins may not want any personally identifiable information on staging servers. What are people using to create fake users on a bigger scale or get rid of PII?

I thought about using a production import and then running the anon job on each, but that would end up with a very dull looking staging site!

Can I suggest the OP is made into a Wiki?

Some links:

I made it a wiki.

Generally, I want a staging site to be using the same data as the production site so that you can test that things will work with the actual data. But maybe people want fake data to see what discourse can do before they start to use it? (Oh, I guess those links have some more sophisticated solutions.)

I guess you could have a User.create in a loop with a list of names from somewhere.

2개의 좋아요

Obviously not my forte :slightly_smiling_face:, but would this be a good opportunity to use rake dev:populate?

cd /var/www/discourse
ALLOW_DEV_POPULATE=1 bundle install
ALLOW_DEV_POPULATE=1 rake dev:populate

I think that would also work on a production site that is more a staging environment/test site.

4개의 좋아요

Apparently that’s no hindrance!

That’s a great suggestion:

Task code: discourse/populate.rake at 1472e47aae5bfdfb6fd9abfe89beb186c751f514 · discourse/discourse (github.com)

User specific actions:

1개의 좋아요

Nice! Indeed, someone already thought of this problem!

EDIT: and for kicks, I tried this out on a recently installed test site; I pasted in your bundle and rake tasks and it did this:

root@test2-app:/var/www/discourse# ALLOW_DEV_POPULATE=1 rake dev:populate
OK
I did no detect a custom `config/dev.yml` file, creating one for you where you can amend defaults.
There are 9 group records. Creating 6 more.
......
There are 3 user records. Creating 27 more.
...........................
There are 4 category records. Creating 26 more.
..........................
discourse-solved enabled on category 'Recipes' (12).
Creating 30 sample tag records
..............................
There are 6 topic records. Creating 24 more.
........................
root@test2-app:/var/www/discourse# 


3개의 좋아요

The big problem with this is that your data set no longer represents your live data.

A staging server needs to be representative of live, otherwise you can’t test everything prior to going to production with whatever changes are planned.

I’ve spectated some pretty impressive failures where non-representative tests failed to identify issues which later arose in the live environment. More often than not they occurred because of data quality issues.

Double-barreled surnames (with and without the hyphen) and accented characters for example caused tremendous amounts of hurt.

If it’s a true staging server then it needs to mimic live precisely. The copy doesn’t need to be visible to normal users and disabling non-staff email is pretty advisable, but otherwise it’s just inviting problems.

5개의 좋아요

Oh I agree. My question was driven by a client who was nervous about having real client identities in staging.

Optimally we should have a script to jumble names and email addresses and leave everything else the same.

1개의 좋아요

It sounds like a pretty straightforward conversation. If they don’t have a representative copy, then they don’t have a staging site.

If it’s deployed and secured in the same way as live what is their perceived risk?

2개의 좋아요

I’m with Stephen. Is the client more nervous having real data on a staging site, or not having a staging site that’s actually testing your actual data?

If you’re not testing with your actual live data from production, then you don’t know what will happen when you do use the live data.

And this discussion is getting far afield from the OP. :slight_smile:

2개의 좋아요

I think that this should be set up to delete posts after 30 days or something. I added this to the OP. There are times when fake data is handy. The more paranoid amongst us (myself included), have real world reasons not to trust a staging server if it hasn’t been tested with your actual data.

4개의 좋아요

After having a few issues after implementing 2FA on our site I’ve added this:

1개의 좋아요

WoW – that was so awesome! Bada-bing-bada-boom!

I feel so productive after importing that dummy data… all of a sudden my testing forum automagically populated with a bunch of users and posts and tags and categories and groups… oh my!

Thank you so much @nathank and @pfaffman and @merefield and @JammyDodger and @Stephen… oh my!

Happy So Excited GIF

5개의 좋아요

I would love to read recommendations, how to disable pop polling via command line.

The best way is to set an env variable DISCOURSE_pop3_polling_enabled=false

You need to upcase the entire variable name, but I can’t do it on my phone.

2개의 좋아요

I recently migrted my production forum to S3 and CloudFront. I already had a staging server up-and-running but it’s now out of step with production and S3 because I’m not sure whether I need a separate bucket and CDN connection - I don’t particularly want to incur additional AWS costs just for a staging server. Presumably pointing both servers at the same S3 bucket isn’t recommended? What’s the right way to do this?

1개의 좋아요