Using Raspberry Pi 5 and Cloudflare Tunnel to run GROWI at home
Published: 2024-07-10 02:49:31

---
title: Using Raspberry Pi 5 and Cloudflare Tunnel to run GROWI at home
published: true
description: 
tags: 
# cover_image: https://direct_url_to_image.jpg
# Use a ratio of 100:42 for best results.
# published_at: 2024-07-10 02:43 +0000
---


[GROWI](https://growi.org/ja/), 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](https://www.cloudflare.com/ja-jp/products/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](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/197026/a91b9968-ef59-cc0e-be59-4f70c46caae4.png)



## Installing Docker

The Docker installation procedure follows [Install Docker Engine on Ubuntu | Docker Docs](https://docs.docker.com/engine/install/ubuntu/).

```bash
# 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
```

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

```bash
$ docker --version
Docker version 27.0.3, build 7d4bcd8
```

## Clone GROWI

The GROWI to use is obtained by Git cloning.

```bash
git clone https://github.com/weseek/growi-docker-compose.git growi
cd growi
```

## Build GROWI

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

```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
```

And then build.

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

```bash
sudo docker build -t growi:7.0 --platform linux/arm64 .
```

## Fixing docker-compose

Then modify `docker-compose.yml`.

```yaml
version: '3'

services:
  app:
    image: growi:7.0 # fix to image instead of build
    ports:
      - 3000:3000 # Fix to allow external access
```

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](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/197026/0d255025-15f9-358d-8810-bd7439f34536.jpeg)

## Setting up Cloudflare Tunnel

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

```bash
wget https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-arm64.deb
sudo dpkg -i cloudflared-linux-arm64.deb
```

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.

```bash
cloudflared login
```

![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/197026/4b357837-6f52-fd14-4305-2017d5a0c489.png)


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

```bash
cloudflared tunnel create raspberry
```

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.

```yaml
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
```

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

```bash
cloudflared tunnel run raspberry
```

### 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`.

```bash
sudo cloudflared --config /home/${user}/.cloudflared/config.yml service install
```

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.

```bash
$ 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
```

## Configure GROWI

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

![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/197026/b2be274d-339a-ce99-f26b-6c2599153f36.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](https://growi.org/ja/)