Add Discourse container install and metadata

Add support for deploying Discourse as a container: adds ct/discourse.sh (container build/install/update flow and resource defaults), frontend/public/json/discourse.json (app metadata, install resources, and notes), and install/discourse-install.sh (full installer that installs dependencies, Postgres/Node/Ruby, clones the Discourse repo, generates secrets and DB password saved to /opt/discourse/.env, installs gems and yarn, precompiles assets, runs migrations, creates an admin user, sets up a systemd service and nginx reverse proxy, and enables required services). Admin user 'admin' is created with a generated password stored in the .env file.
This commit is contained in:
CanbiZ (MickLesk) 2026-02-02 13:45:58 +01:00
parent d3b7ea6197
commit 891d3396dc
3 changed files with 264 additions and 0 deletions

75
ct/discourse.sh Normal file
View File

@ -0,0 +1,75 @@
#!/usr/bin/env bash
source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVED/main/misc/build.func)
# Copyright (c) 2021-2026 community-scripts ORG
# Author: MickLesk (CanbiZ)
# License: MIT | https://github.com/community-scripts/ProxmoxVED/raw/main/LICENSE
# Source: https://www.discourse.org/
APP="Discourse"
var_tags="${var_tags:-forum;community;discussion}"
var_cpu="${var_cpu:-4}"
var_ram="${var_ram:-4096}"
var_disk="${var_disk:-20}"
var_os="${var_os:-debian}"
var_version="${var_version:-13}"
var_unprivileged="${var_unprivileged:-1}"
header_info "$APP"
variables
color
catch_errors
function update_script() {
header_info
check_container_storage
check_container_resources
if [[ ! -d /opt/discourse ]]; then
msg_error "No ${APP} Installation Found!"
exit
fi
if [[ ! -f /opt/discourse/.env ]]; then
msg_error "No Discourse Configuration Found!"
exit
fi
msg_info "Stopping Service"
systemctl stop discourse
msg_ok "Stopped Service"
msg_info "Backing up Data"
cp /opt/discourse/.env /opt/discourse_env.bak
msg_ok "Backed up Data"
msg_info "Updating Discourse"
cd /opt/discourse
git pull origin main
$STD bundle install --deployment --without test development
$STD yarn install
$STD bundle exec rails assets:precompile
$STD bundle exec rails db:migrate
msg_ok "Updated Discourse"
msg_info "Restoring Configuration"
mv /opt/discourse_env.bak /opt/discourse/.env
msg_ok "Restored Configuration"
msg_info "Starting Service"
systemctl start discourse
msg_ok "Started Service"
msg_ok "Updated successfully!"
exit
}
start
build_container
description
msg_ok "Completed Successfully!\n"
echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}"
echo -e "${INFO}${YW} Access it using the following URL:${CL}"
echo -e "${TAB}${GATEWAY}${BGN}http://${IP}${CL}"
echo -e "${INFO}${YW} Default Credentials:${CL}"
echo -e "${TAB}${GATEWAY}${BGN}Username: admin${CL}"
echo -e "${TAB}${GATEWAY}${BGN}Password: Check /opt/discourse/.env${CL}"

View File

@ -0,0 +1,48 @@
{
"name": "Discourse",
"slug": "discourse",
"categories": [
23
],
"date_created": "2026-02-02",
"type": "ct",
"updateable": true,
"privileged": false,
"interface_port": 80,
"documentation": "https://www.discourse.org/",
"website": "https://www.discourse.org/",
"logo": "https://cdn.jsdelivr.net/gh/selfhst/icons@main/webp/discourse.webp",
"config_path": "/opt/discourse/.env",
"description": "Discourse is the civilized discussion platform. Use it as a mailing list, discussion forum, or long-form chat room.",
"install_methods": [
{
"type": "default",
"script": "ct/discourse.sh",
"resources": {
"cpu": 4,
"ram": 4096,
"hdd": 20,
"os": "Debian",
"version": "13"
}
}
],
"default_credentials": {
"username": "admin",
"password": null
},
"notes": [
{
"text": "Minimum 4GB RAM and 4 CPU cores recommended for production use.",
"type": "warning"
},
{
"text": "Admin user is created with username 'admin'. Set password in first login.",
"type": "info"
},
{
"text": "Configure SMTP settings in admin panel for email notifications.",
"type": "info"
}
]
}

View File

@ -0,0 +1,141 @@
#!/usr/bin/env bash
# Copyright (c) 2021-2026 community-scripts ORG
# Author: MickLesk (CanbiZ)
# License: MIT | https://github.com/community-scripts/ProxmoxVED/raw/main/LICENSE
# Source: https://www.discourse.org/
source /dev/stdin <<<"$FUNCTIONS_FILE_PATH"
color
verb_ip6
catch_errors
setting_up_container
network_check
update_os
msg_info "Installing Dependencies"
$STD apt install -y \
build-essential \
libssl-dev \
libreadline-dev \
zlib1g-dev \
libyaml-dev \
curl \
git \
imagemagick \
gsfonts \
nginx \
redis-server
msg_ok "Installed Dependencies"
PG_VERSION="16" setup_postgresql
PG_DB_NAME="discourse" PG_DB_USER="discourse" setup_postgresql_db
NODE_VERSION="22" setup_nodejs
RUBY_VERSION="3.3" setup_ruby
msg_info "Configuring Discourse"
DISCOURSE_SECRET_KEY=$(openssl rand -hex 32)
DISCOURSE_DB_PASS=$(openssl rand -base64 18 | tr -dc 'a-zA-Z0-9' | cut -c1-13)
git clone --depth 1 https://github.com/discourse/discourse.git /opt/discourse
cd /opt/discourse
cat <<EOF >/opt/discourse/.env
RAILS_ENV=production
RAILS_LOG_TO_STDOUT=true
RAILS_SERVE_STATIC_FILES=true
SECRET_KEY_BASE=${DISCOURSE_SECRET_KEY}
DISCOURSE_DB_HOST=localhost
DISCOURSE_DB_PORT=5432
DISCOURSE_DB_NAME=discourse
DISCOURSE_DB_USERNAME=discourse
DISCOURSE_DB_PASSWORD=${DISCOURSE_DB_PASS}
DISCOURSE_REDIS_URL=redis://localhost:6379
DISCOURSE_DEVELOPER_EMAILS=admin@local
DISCOURSE_HOSTNAME=${LOCAL_IP}
DISCOURSE_SMTP_ADDRESS=localhost
DISCOURSE_SMTP_PORT=25
DISCOURSE_SMTP_AUTHENTICATION=none
DISCOURSE_NOTIFICATION_EMAIL=noreply@${LOCAL_IP}
EOF
chown -R root:root /opt/discourse
chmod 755 /opt/discourse
msg_ok "Configured Discourse"
msg_info "Installing Discourse Dependencies"
cd /opt/discourse
$STD bundle install --deployment --without test development
$STD yarn install
msg_ok "Installed Discourse Dependencies"
msg_info "Building Discourse Assets"
cd /opt/discourse
$STD bundle exec rails assets:precompile
msg_ok "Built Discourse Assets"
msg_info "Setting Up Database"
cd /opt/discourse
$STD bundle exec rails db:migrate
$STD systemctl enable --now redis-server
$STD systemctl enable --now postgresql
msg_ok "Set Up Database"
msg_info "Creating Discourse Admin User"
cd /opt/discourse
$STD bundle exec rails runner -e production "User.create!(email: 'admin@local', username: 'admin', password: '${DISCOURSE_DB_PASS}', admin: true)" || true
msg_ok "Created Discourse Admin User"
msg_info "Creating Service"
cat <<EOF >/etc/systemd/system/discourse.service
[Unit]
Description=Discourse Forum
After=network.target postgresql.service redis-server.service
[Service]
Type=simple
User=root
WorkingDirectory=/opt/discourse
Environment=RAILS_ENV=production
ExecStart=/usr/local/bin/bundle exec puma -w 2
Restart=on-failure
RestartSec=5
[Install]
WantedBy=multi-user.target
EOF
systemctl enable -q --now discourse
msg_ok "Created Service"
msg_info "Configuring Nginx"
cat <<EOF >/etc/nginx/sites-available/discourse
server {
listen 80 default_server;
server_name _;
client_max_body_size 100M;
proxy_busy_buffers_size 512k;
proxy_buffers 4 512k;
location / {
proxy_pass http://127.0.0.1:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade \$http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host \$host;
proxy_set_header X-Real-IP \$remote_addr;
proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto \$scheme;
}
}
EOF
ln -sf /etc/nginx/sites-available/discourse /etc/nginx/sites-enabled/discourse
rm -f /etc/nginx/sites-enabled/default
$STD nginx -t
$STD systemctl enable --now nginx
msg_ok "Configured Nginx"
motd_ssh
customize
cleanup_lxc