Reference: https://github.com/logseq/logseq/tree/defclass/electron#set-up-development-environment
Prerequisites
-
Make sure all requirements listed at https://github.com/logseq/logseq/tree/defclass/electron#1-requirements are met
-
Install PostgreSQL create a DB called "logseq" and a user with SUPERUSER permissions
-
Install nginx & Certbot on your sever
-
Create GitHub application as discribed in https://docs.github.com/en/free-pro-team@latest/developers/apps/creating-a-github-app in the App set the Homepage URL to https://yourdomain.com - call back URL to https://yourdomain.com/auth/github Create a "client secret" & a "Private Key" for your app in app permissions set "Contents" access to "read and Write" Copy from your app
- App ID
- Client ID
- Client Secret upload the pem file that was automatically downloaded when you created your app "Private Key" to your sever
Running LogSeq
- Clone the logseq repo git clone
https://github.com/logseq/logseq
- Download backend.jar from https://github.com/logseq/logseq/releases/tag/0.0.1-100 and place it in
~/logsec/resources
- In ~/logseq/src/main/frontend/config.cljs line 18 replace
(def website
(if dev?
"http://localhost:3000"
(util/format "https://%s.com" app-name)))
by
(def website
(if dev?
"http://localhost:3000"
"https://yourdomain.com"))
line 38 replace
(def github-app-name (if dev? GITHUB_APP_NAME "logseq"))
by
(def github-app-name (if dev? GITHUB_APP_NAME "yourappname"))
- Set the envrionment variables
export GITHUB_REDIRECT_URI="https://yourdomain.com/auth/github"
export ENVIRONMENT="production"
export JWT_SECRET="somepass"
export COOKIE_SECRET="54676c2c5324279480a6ee1af0792588"
export GITHUB_APP2_NAME="yourappname"
export GITHUB_APP2_ID="appID"
export GITHUB_APP2_KEY="AppClientID"
export GITHUB_APP2_SECRET="AppClientSecret"
export GITHUB_APP_PEM="/path/to/github/pem/file/yourappname.2021-01-19.private-key.pem"
export LOG_PATH="/tmp/logseq"
export DATABASE_URL="postgres://localhost:5432/logseq"
export PG_USERNAME="username"
export PG_PASSWORD="password"
export WEBSITE_URL="https://yourdomain.com/"
export COOKIE_DOMAIN="yourdomain.com"
- switch to
~/logsec
and runyarn
then, compile usingyarn release
- run from
~/logsec
usingjava -Duser.timezone=UTC -jar ./static/logseq.jar
Publishing LogSeq
Now we need to "server" your self hosted logseq to the internet to do that
- Create 2 DNS records
domain.com
&asset.domain.com
& get a certificate for each using [[Certbot]] - configure Nginx to
- rewrite 'asset.logseq.com' to 'asset.domain.com';
- rewrite 'logseq.com' to 'domain.com';
- reverse proxy requests to 'domain.com' to 'logseq.jar' (http://localhost:3000)
- serve 'asset.domain.com' to
/path/to/logseq/public/
A dummy copy of the ngix.conf file can be found here
Hardcoded values
shadow-cljs.edn
: line 16
:release {:asset-path "https://asset.logseq.com/static/js"}
src/main/frontend/config.cljs
: line 17
(def app-name "logseq")
src/main/frontend/config.cljs
: line 18-21
(def website
(if dev?
"http://localhost:3000"
(util/format "https://%s.com" app-name)))
src/main/frontend/config.cljs
: line 28
(def asset-domain (util/format "https://asset.%s.com"
app-name))
logseq.jar/static/js/publishing/cljs-runtime
: line 34
frontend.config.app_name = "logseq";
logseq.jar/static/js/publishing/cljs-runtime
: line 34
frontend.config.website = (cljs.core.truth_(frontend.config.dev_QMARK_)?"http://localhost:3000":frontend.util.format.cljs$core$IFn$_invoke$arity$variadic("https://%s.com",cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2([frontend.config.app_name], 0)));
logseq.jar/static/js/publishing/cljs-runtime
: line 36
frontend.config.asset_domain = frontend.util.format.cljs$core$IFn$_invoke$arity$variadic("https://asset.%s.com",cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2([frontend.config.app_name], 0));
logseq.jar/static/js/cljs-runtime/frontend.config.js
: line 34
frontend.config.app_name = "logseq";
logseq.jar/static/js/cljs-runtime/frontend.config.js
: line 34
frontend.config.website = (cljs.core.truth_(frontend.config.dev_QMARK_)?"http://localhost:3000":frontend.util.format.cljs$core$IFn$_invoke$arity$variadic("https://%s.com",cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2([frontend.config.app_name], 0)));
logseq.jar/static/js/cljs-runtime/frontend.config.js
: line 36
frontend.config.asset_domain = frontend.util.format.cljs$core$IFn$_invoke$arity$variadic("https://asset.%s.com",cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2([frontend.config.app_name], 0));