Nextcloud + Raspberry Pi + Docker + Onion service = š„
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.
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 ?!
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.yaml
looked 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-stoppedvolumes:
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 nextcloud
and db
services startup correctly but onionize
exits with an error. It was working fine on my laptop, why not on the Raspberry ?!
The architecture of the docker imagetorservers/onionize:latest
is amd64
and Raspberry Pi 4 has an armhf
architecture ! I did some research and discovered a recent tool developed by the Docker team : buildx
buildx
allows to build images for specific processor architectures such as amd64
or amrhf
. I forked torservers/onionize
, changed the architecture of docker-gen
in the Dockerfile and used buildx
to create an armhf
compatible 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