Discourse 설치 및 운영

한국에서는 사용자가 많이 없는데, 해외에서는 기술분야 커뮤니티 구축솔루션으로 많이 사용하는 discourse설치 방법을 정리한다.

가능한 Ubuntu 공식 패키지를 사용하고, 최소한의 설치, 설정으로 빠르게 구축한다.

Ubuntu22.04LTS
Discourse공식 권장방법으로 설치
Cyberpanel을 설치하면서 자동으로 설치된 OpenLiteSpeed에서 SSL, Reverse Proxy 설정

sudo apt-get install docker.io
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:
  bridge-utils containerd dns-root-data dnsmasq-base pigz runc
  ubuntu-fan
Suggested packages:
  ifupdown aufs-tools cgroupfs-mount | cgroup-lite debootstrap
  docker-buildx docker-compose-v2 docker-doc rinse zfs-fuse
  | zfsutils
The following NEW packages will be installed:
  bridge-utils containerd dns-root-data dnsmasq-base docker.io
  pigz runc ubuntu-fan
0 upgraded, 8 newly installed, 0 to remove and 0 not upgraded.
Need to get 79.6 MB of archives.
After this operation, 300 MB of additional disk space will be used.
Do you want to continue? [Y/n]
sudo mkdir /var/discourse
sudo git clone https://github.com/discourse/discourse_docker.git /var/discourse
cd /var/discourse
sudo cp samples/standalone.yml containers/app.yml
sudo vi containers/app.yml
#프록시 서버 관련 설정
expose:
  - "80:80"   # http
  - "443:443" # https

#아마존 SES 관련 설정  
DISCOURSE_HOSTNAME: 'discourse.example.com'
DISCOURSE_DEVELOPER_EMAILS: 'me@example.com,you@example.com'
DISCOURSE_SMTP_ADDRESS: smtp.example.com
#DISCOURSE_SMTP_PORT: 587
DISCOURSE_SMTP_USER_NAME: user@example.com
DISCOURSE_SMTP_PASSWORD: "pa$$word"
#DISCOURSE_SMTP_ENABLE_START_TLS: true # (optional, default: true)

#처음 메일 인증 관련 설정
#- exec: rails r "SiteSetting.notification_email='info@unconfigured.discourse.org'"
#프록시 서버 관련 설정
expose:
  - "8080:80"   # http
  - "8443:443" # https

#운영 관련 일반 설정  
DISCOURSE_HOSTNAME: 'discourse.example.com'
DISCOURSE_DEVELOPER_EMAILS: 'me@example.com,you@example.com'

#아마존 SES 관련 설정  
DISCOURSE_SMTP_ADDRESS: smtp.example.com
#DISCOURSE_SMTP_PORT: 587
DISCOURSE_SMTP_USER_NAME: user@example.com
DISCOURSE_SMTP_PASSWORD: "pa$$word"
#DISCOURSE_SMTP_ENABLE_START_TLS: true # (optional, default: true)

#처음 메일 인증 관련 설정
#- exec: rails r "SiteSetting.notification_email='info@unconfigured.discourse.org'"
swaks --to admin@myfirstbusiness.co.kr \
  --from admin@myfirstbusiness.co.kr \
  --server email-smtp.ap-northeast-2.amazonaws.com \
  --port 587 \
  --auth LOGIN \
  --auth-user 'AKIASUGLFGUILHVRAYFX' \
  --auth-password 'XXX' \
  --tls

입력한 정보가 맞는지 확인하기 위해 swaks로 테스트한다.

sudo ./launcher bootstrap app
WARNING Memory overcommit must be enabled! Without it, a background save or replication may fail under low memory condition. Being disabled, it can can also cause failures without low memory condition, see https://github.com/jemalloc/jemalloc/issues/1328. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
WARNING: containers/app.yml file is world-readable. You can secure this file by running: chmod o-rwx containers/app.yml