DEV Community

Atsushi
Atsushi

Posted on

Using Raspberry Pi 5 and Cloudflare Tunnel to run GROWI at home

GROWI, an open source wiki, can be easily installed and used by individuals. It is useful for using it as a substitute for everyday memos or for compiling information to be shared with family members.

As an easy way to operate such GROWI, we built it on a Raspberry Pi 5. I also used Cloudflare Tunnel to make it accessible from the Internet, so I will write down the contents.

Notes.

Cloudflare Tunnel requires a domain managed by Cloudflare. If you don't mind changing the URL each time, you don't need a domain.

Setting up Raspberry Pi 5

The Raspberry Pi Imager is used to install the Raspberry Pi OS. Note that Ubuntu Server 24.04 LTS (64bit) is selected as the OS, not Raspberry Pi OS.

スクリーンショット 2024-07-10 11.17.24.png

Installing Docker

The Docker installation procedure follows Install Docker Engine on Ubuntu | Docker Docs.

# Add Docker's official GPG key:
sudo apt-get update
sudo apt-get install ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc

# Add the repository to Apt sources:
echo \
  "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
  $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
  sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update

sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin -y
Enter fullscreen mode Exit fullscreen mode

At the time of writing, 27.0.3 was installed; for the Raspberry Pi OS, this version appears to be out of date.

$ docker --version
Docker version 27.0.3, build 7d4bcd8
Enter fullscreen mode Exit fullscreen mode

Clone GROWI

The GROWI to use is obtained by Git cloning.

git clone https://github.com/weseek/growi-docker-compose.git growi
cd growi
Enter fullscreen mode Exit fullscreen mode

Build GROWI

Since we can't build GROWI as is because of the different architecture, modify the Dockerfile.

# syntax = docker/dockerfile:1.4

# fix version
ARG version=7.0

FROM debian:stable-slim as fetch-dockerize
# fix dockerize version
ENV DOCKERIZE_VERSION v0.7.0
# Change dockerize URL for ARM64
RUN apt-get update && apt-get install -y curl \
    && curl -sL https://github.com/jwilder/dockerize/releases/download/$DOCKERIZE_VERSION/dockerize-linux-arm64-$DOCKERIZE_VERSION.tar.gz \x}}
        | tar -xz -C /usr/local/bin

FROM weseek/growi:${version}
LABEL maintainer Yuki Takei <yuki@weseek.co.jp>

COPY --from=fetch-dockerize --link /usr/local/bin/dockerize /usr/local/bin/dockerize
Enter fullscreen mode Exit fullscreen mode

And then build.

Then, build. Don't forget to specify the platform.

sudo docker build -t growi:7.0 --platform linux/arm64 .
Enter fullscreen mode Exit fullscreen mode

Fixing docker-compose

Then modify docker-compose.yml.

version: '3'

services:
  app:
    image: growi:7.0 # fix to image instead of build
    ports:
      - 3000:3000 # Fix to allow external access
Enter fullscreen mode Exit fullscreen mode

Now you can run docker-compose up -d to start GROWI. It will take a while for the startup to complete, so be patient. Once it is up, operation from a browser is smooth.

image.jpg

Setting up Cloudflare Tunnel

We will use Cloudflare Tunnel so that we can access the site from the Internet as well.

wget https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-arm64.deb
sudo dpkg -i cloudflared-linux-arm64.deb
Enter fullscreen mode Exit fullscreen mode

Next, log in using your Cloudflare account. During authentication, specify the domain you wish to use. The domain must be set up in advance with Cloudflare.

cloudflared login
Enter fullscreen mode Exit fullscreen mode

image.png

Once authenticated, create a Tunnel. The configuration will be stored in ~/.cloudflared/{id}.json. raspberry is an arbitrary name.

cloudflared tunnel create raspberry
Enter fullscreen mode Exit fullscreen mode

At this point, the configuration is done for the subdomain. For example, raspberry.example.com.

Create configuration file.

Create ~/.cloudflared/config.yaml. Replace ${name}, ${user}, and ${id} with the Tunnel name, user name, and ID, respectively.

tunnel: ${name}
credentials-file: /home/${user}/.cloudflared/${id}.json
ingress: ${name}
  - hostname: raspberry.example.com
    service: http://127.0.0.1:3000
  - service: http_status:404
Enter fullscreen mode Exit fullscreen mode

Now start Tunnel and see if you can access it from the appropriate domain.

cloudflared tunnel run raspberry
Enter fullscreen mode Exit fullscreen mode

Servicing

As it is, we have to maintain SSH connection while Tunnel is running. So, we need to make Tunnel a service.

Create /etc/systemd/system/cloudflared.service.

sudo cloudflared --config /home/${user}/.cloudflared/config.yml service install
Enter fullscreen mode Exit fullscreen mode

You will probably have it up and running as a service when you are done. The configuration file is copied to /etc/cloudflared/config.yml as follows.

$ systemctl status cloudflared

cloudflared.service - cloudflared
     Loaded: loaded (/etc/systemd/system/cloudflared.service; enabled; preset: enabled)
     Active: active (running) since Wed 2024-07-10 09:26:48 JST; 2h 7min ago
   Main PID: 66342 (cloudflared)
      Tasks: 11 (limit: 9074)
     Memory: 16.4M (peak: 19.7M)
        CPU: 15.731s
     CGroup: /system.slice/cloudflared.service
             └─66342 /usr/bin/cloudflared --no-autoupdate --config /etc/cloudflared/config.yml tunnel run
Enter fullscreen mode Exit fullscreen mode

Configure GROWI

GROWI requires URL configuration, so please set the URL that is accessed externally in the admin panel.

image.png

Summary

Using Raspberry Pi 5 and Cloudflare Tunnel, we have shown how GROWI can be accessed from the Internet while operating GROWI at home, and it is easy and convenient to use HTTPS access with Cloudflare Tunnel!

GROWI, an OSS development wiki tool | comfortable information sharing for all

Top comments (0)