Skip to content

Instantly share code, notes, and snippets.

@sahal
Last active November 18, 2024 20:36
Show Gist options
  • Select an option

  • Save sahal/ec57d2e63764e7b125fca54267977bdc to your computer and use it in GitHub Desktop.

Select an option

Save sahal/ec57d2e63764e7b125fca54267977bdc to your computer and use it in GitHub Desktop.
Build Joplin in Docker

Multi build

This will create a whole bunch of node-xx version docker images preloaded with the official Joplin 3.1.24 tarball. Then, we'll try to build it.

Currently, I've tested the build with node 18 19 20 21 22 and 23.

Canvas is seemingly not building on node 20+, this is to validate that theory. See: Automattic/node-canvas#2448

I'll post the results later... my laptop takes about 20 minutes per build, so see you in a few hours.

grab the github.com star cert (public)

$ openssl s_client -showcerts codeload.github.com:443 &> github.cer

Put it next to the Dockerfile here.

I really just kept the CERT parts and not the comments.. YMMV.

Run the script to build the docker images and test yarn install

$ ./create-node-dirs.sh
. . .
$ ./build-joplin-all-images.sh
. . .
#!/usr/bin/env bash
set -o errexit
set -o nounset
for ver in 18 19 20 21 22 23; do
podman run -it --entrypoint /home/node/install.sh "joplin-build-node-${ver}"
done
#!/usr/bin/env bash
set -o errexit
set -o nounset
for ver in 18 19 20 21 22 23; do
node_ver_dir_name="node-${ver}"
mkdir "${node_ver_dir_name}"
pushd "${node_ver_dir_name}"
cp ../github.cer ./
cp ../Dockerfile ./
cp ../install.sh ./
sed -i s/node:18/node:${ver}/ ./Dockerfile
podman build -t "joplin-build-node-${ver}" .
popd
done
FROM node:18-slim AS build
ARG JOPLIN_VERSION=3.1.24
RUN apt-get update && apt-get install -y --no-install-recommends \
make \
g++ \
dumb-init \
build-essential \
libcairo2-dev \
libpango1.0-dev \
libjpeg-dev \
libgif-dev \
librsvg2-dev \
python3 \
wget \
rsync \
git \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /home/node/
COPY github.cer .
# super annoying to get this file over and over again
# lets put it in a layer
RUN wget \
--quiet \
--ca-certificate=github.cer \
--no-clobber \
"https://github.com/laurent22/joplin/archive/refs/tags/v${JOPLIN_VERSION}.tar.gz" \
-O joplin.tar.gz
COPY install.sh .
#!/usr/bin/env bash
set -o errexit
set -o nounset
# some dependencies require https connections to github?
git config --global http.sslCAInfo /home/node/github.cer
echo "Node $( node -v )"
echo "Yarn $( yarn --version )"
echo "Debian version $(cat /etc/debian_version)"
echo "Kernel Version $(uname -r)"
mkdir -p buildcanvas2112
cd buildcanvas2112
yes | yarn init
yarn add canvas@2.11.2 --verbose
#!/usr/bin/env bash
set -o errexit
set -o nounset
# some dependencies require https connections to github?
git config --global http.sslCAInfo /home/node/github.cer
mkdir -p joplin
# no need to see the output of this
tar xf joplin.tar.gz -C joplin &>/dev/null
cd joplin
JOPLIN_VER_DIR=$(find . -maxdepth 1 -type d -name "joplin*")
cd "${JOPLIN_VER_DIR}"
yarn_bin="$(find .yarn/releases -type f -name "*.cjs")"
echo "Node $( node -v )"
echo "Yarn $( ${yarn_bin} -v )"
echo "Debian version $(cat /etc/debian_version)"
echo "Kernel Version $(uname -r)"
"${yarn_bin}" install --inline-builds
@sahal
Copy link
Author

sahal commented Nov 17, 2024

I really don't understand the inconsistencies around this build. If I look at it wrong, Joplin doesn't seem to build.

I used this to build Joplin a few times in all these versions and it looks like only node 23 seems to fail consistently for me.

Yet, if i just build canvas with yarn -- it builds on all node versions perfectly. 🤔

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