Collecting the formatting I use most, so new members can copy it.
Collapsible section
Click to expand
Hidden until someone opens it. Handy for long logs.
Code with highlighting
fmt.Println("hello from casnode")
Tables
| Database | driverName |
|---|---|
| MySQL | mysql |
| PostgreSQL | postgres |
| SQLite | sqlite |
| SQL Server | mssql |
Emoji: đ đ đ
Mention someone with @ and their user name, like @priya_r.
There's a general importer now, tools/import_topics. It reads an import.json with categories, users and topics (each post with its author, time and files in a media/ folder) and brings them in with their original authors and times, without notifying anyone:
go run ./tools/import_topics <dir> # shows what it would do
go run ./tools/import_topics -apply <dir> # does it
Run it in the forum's folder so it uses the forum's database and uploads. Every user and topic carries an externalId, so running it again skips what was already imported.
There's no ready-made converter for Discourse yet: you'd write a small script that turns Discourse's data into that import.json. The format is described at the top of tools/import_topics/main.go.
Most of our members won't open the forum every day. An email when someone replies to them or mentions them would bring them back to the discussion.
conf/app.local.conf: same format as conf/app.conf, ignored by git, and every item in it overrides app.conf. Pulling a new version never conflicts with it.
Every item can also be set as an environment variable of the same name (clientSecret=...), which is what the Docker example does.
Turn on trustProxyHeader = true in conf/app.local.conf, so that Casnode takes the client IP from X-Forwarded-For, and make sure Nginx sets it:
location / {
proxy_pass http://127.0.0.1:16900;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
Only proxy to httpport. The Next.js server on httpport + 1 listens on 127.0.0.1 and gets its requests through the Go backend.
Leave trustProxyHeader off when nothing is in front of Casnode, otherwise anyone could pick their own IP with that header.
Put this in conf/app.local.conf:
driverName = postgres
dataSourceName = user=casnode password=secret host=localhost port=5432 sslmode=disable
dbName = casnode
On the first start Casnode creates the database if it's missing, then the tables. For MySQL it's driverName = mysql with dataSourceName = casnode:secret@tcp(localhost:3306)/, and mssql works for SQL Server.
Casnode doesn't move the data of the SQLite file into the new database, so either start fresh or copy it over with your own tools.
Docker is the quickest. The repository has a Dockerfile, so build the image and run it:
git clone https://github.com/casnode/casnode
cd casnode
docker build -t casnode .
docker run -d -p 16900:16900 -v casnode-data:/app/data \
-e casdoorEndpoint=https://door.casdoor.com -e clientId=<client id> -e clientSecret=<client secret> \
-e casdoorOrganization=<organization> -e casdoorApplication=<application> -e admins=<your user name> \
casnode
Then open http://your-server:16900. The only other thing you need is a Casdoor application for sign-in: its client ID and secret go in the variables above, and https://<your forum>/callback goes in its redirect URLs.
By default the data is a SQLite file kept, together with the uploads, in the casnode-data volume, which is fine for a trial.
