Nextcloud + Raspberry Pi + Docker + Onion service = šŸ”„

Robin Riclet
ITNEXT
Published in
2 min readJul 7, 2020

--

(french version here)

A couple months ago, I had this idea to setup a private Nextcloud instance to share files with friends, have a group agenda and more collaborative stuff.

(the Nextcloud user interface)

For privacy concerns and to avoid paying a domain name, I thought of hosting this instance as a Tor hidden service.

I started asking around for hosting solutions, prices and privacy policies. After a couple weeks of unsuccessful findings, I stumbled upon this Reddit thread suggesting hosting a Nextcloud instance on a Raspberry Pi. Why havenā€™t I thought of this earlier ?!

(a beautiful Raspberry Pi 4 in its raspberry colored case ā¤)

I ordered a Raspberry Pi Starter Kit with a brand new Raspberry Pi 4 Model B (4GB memory). While I waited for the package, I found this GitHub repo. I used Docker to setup the Nextcloud instance along with MariaDb, all that behind an onion service. The docker-compose.yamllooked like this :

version: '3'services:
onionize:
image: torservers/onionize
volumes:
- /var/run/docker.sock:/tmp/docker.sock:ro
networks:
- faraday
nextcloud:
image: nextcloud:apache
environment:
- ONIONSERVICE_NAME=app
networks:
- faraday
depends_on:
- db
volumes:
- nextcloud:/var/www/html
- ./app/config:/var/www/html/config
- ./app/custom_apps:/var/www/html/custom_apps
- ./app/data:/var/www/html/data
- ./app/themes:/var/www/html/themes
- /etc/localtime:/etc/localtime:ro
restart: unless-stopped
db:
image: mariadb
networks:
- faraday
volumes:
- db:/var/lib/mysql
- /etc/localtime:/etc/localtime:ro
environment:
- MYSQL_ROOT_PASSWORD=password
- MYSQL_PASSWORD=mysql
- MYSQL_DATABASE=nextcloud
- MYSQL_USER=nextcloud
restart: unless-stopped
volumes:
nextcloud:
db:
networks:
faraday:
driver: bridge

Everything was working fine on my laptop, so I waited. Upon receiving the Raspberry, I installed Raspbian Lite and set SSH up. Next, I installed git, docker, docker-compose and added external storage.

docker-compose up andā€¦ nope. The nextcloudand dbservices startup correctly but onionizeexits with an error. It was working fine on my laptop, why not on the Raspberry ?!

The architecture of the docker imagetorservers/onionize:latestis amd64and Raspberry Pi 4 has an armhfarchitecture ! I did some research and discovered a recent tool developed by the Docker team : buildx

buildxallows to build images for specific processor architectures such as amd64 or amrhf. I forked torservers/onionize, changed the architecture of docker-genin the Dockerfile and used buildx to create an armhfcompatible image.

Example here : https://medium.com/@artur.klauser/building-multi-architecture-docker-images-with-buildx-27d80f7e2408

Containers have now been up for a week, Nextcloud works great, response time through the Tor network is pretty fast !

My Github repo : https://github.com/rriclet/tor-cloud

--

--