Skip to content

Instantly share code, notes, and snippets.

@hi-ko
Last active September 30, 2023 01:28
Show Gist options
  • Save hi-ko/fbbd6f0f82955f55bb23c6f4db29bdb2 to your computer and use it in GitHub Desktop.
Save hi-ko/fbbd6f0f82955f55bb23c6f4db29bdb2 to your computer and use it in GitHub Desktop.
joplin server install

this gist is no longer maintained

Please use https://github.com/hi-ko/joplin-server-ubuntu-install instead

Install joplin server on Ubuntu (20.04)

  1. as root run joplin-requirements.sh to install the joplin requirements but please take this script with causion since it is not well tested in existing environments. You could also create the requirements by yourself by
    1. create user joplin with home /home/joplin
    2. install nodejs 16
    3. install packages vim git build-essential python curl dirmngr apt-transport-https lsb-release ca-certificates
    4. checkout your desired version from https://github.com/laurent22/joplin.git to /home/joplin
  2. collect expected files and folders and build joplin by running joplin-build.sh.
  3. create a new db joplin in postgres (running on the same or on another server) and adapt run.sh with your db credentials
  4. test run.sh
  5. if run.sh works as expected you can use joplin.service to run joplin as a systemd service

s. Joplin Server pre-release is now available

#!/bin/bash
# adapted from https://github.com/laurent22/joplin/blob/dev/Dockerfile.server
cd /home/joplin
# Install the root scripts but don't run postinstall (which would bootstrap
# and build TypeScript files, but we don't have the TypeScript files at
# this point)
cp joplin/package*.json ./
npm install --ignore-scripts
# To take advantage of the Docker cache, we first copy all the package.json
# and package-lock.json files, as they rarely change, and then bootstrap
# all the packages.
#
# Note that bootstrapping the packages will run all the postinstall
# scripts, which means that for packages that have such scripts, we need to
# copy all the files.
#
# We can't run boostrap with "--ignore-scripts" because that would
# prevent certain sub-packages, such as sqlite3, from being built
mkdir packages
rsync -r joplin/packages/fork-sax/package*.json ./packages/fork-sax/
rsync -r joplin/packages/htmlpack/package*.json ./packages/htmlpack/
rsync -r joplin/packages/renderer/package*.json ./packages/renderer/
rsync -r joplin/packages/tools/package*.json ./packages/tools/
rsync -r joplin/packages/lib/package*.json ./packages/lib/
rsync -r joplin/lerna.json .
rsync -r joplin/tsconfig.json .
# The following have postinstall scripts so we need to copy all the files.
# Since they should rarely change this is not an issue
rsync -r joplin/packages/turndown/ ./packages/turndown/
rsync -r joplin/packages/turndown-plugin-gfm/ ./packages/turndown-plugin-gfm/
rsync -r joplin/packages/fork-htmlparser2/ ./packages/fork-htmlparser2/
# Then bootstrap only, without compiling the TypeScript files
npm run bootstrap
# We have a separate step for the server files because they are more likely to
# change.
rsync -r joplin/packages/server/package*.json ./packages/server/
npm run bootstrapServerOnly
# Now copy the source files. Put lib and server last as they are more likely to change.
rsync -r joplin/packages/fork-sax/ ./packages/fork-sax/
rsync -r joplin/packages/htmlpack/ ./packages/htmlpack/
rsync -r joplin/packages/renderer/ ./packages/renderer/
rsync -r joplin/packages/tools/ ./packages/tools/
rsync -r joplin/packages/lib/ ./packages/lib/
rsync -r joplin/packages/server/ ./packages/server/
# Finally build everything, in particular the TypeScript files.
npm run build
#!/bin/bash
apt update
apt -y install vim git
## install nodejs 16
# remove old version
apt purge nodejs npm
# add repo
apt -y install curl dirmngr apt-transport-https lsb-release ca-certificates
curl -sL https://deb.nodesource.com/setup_16.x | sudo -E bash -
apt -y install nodejs
# # in case we need to compile modules
apt -y install build-essential python
JOPLIN_USER=joplin
id -u $JOPLIN_USER &>/dev/null || sudo useradd --create-home --shell /bin/bash $JOPLIN_USER
# as user joplin create dirs and checkout specific version
sudo su - $JOPLIN_USER <<'EOF'
mkdir -p logs
if [ ! -d joplin ];then
git clone https://github.com/laurent22/joplin.git
fi
cd joplin
git fetch --tags
git checkout server-v2.4.1-beta
exit
EOF
[Unit]
Description=
Documentation=https://discourse.joplinapp.org/t/joplin-server-pre-release-is-now-available/13605
After=network.target
[Service]
#Environment=NODE_PORT=3001
Type=simple
User=joplin
ExecStart=/home/joplin/run.sh
WorkingDirectory=/home/joplin
Restart=on-failure
[Install]
WantedBy=multi-user.target
#!/bin/bash
########################
export APP_BASE_URL=https://joplin.me.org
export APP_PORT=22300
export DB_CLIENT=pg
export POSTGRES_PASSWORD=*********************
export POSTGRES_DATABASE=joplin
export POSTGRES_USER=joplin
export POSTGRES_PORT=5432
export POSTGRES_HOST=db.me.org
#export RUNNING_IN_DOCKER=1
cd /home/joplin
npm --prefix packages/server start
@hi-ko
Copy link
Author

hi-ko commented Dec 5, 2021

@fulljackz I moved the scripts to https://github.com/hi-ko/joplin-server-ubuntu-install
and updated them for the latest version. Please check ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment