Table of Contents

1. Stuff that's good to know

1.1. nextcloud

Nextcloud is pretty hard to deploy, I regret having ever said it was easy. The good thing is there are some deployment examples on nextcloud/docker github conveniently placed under .examples/ (where of course they would be hidden).

Here's the example compose file I got to run on my machine docker-compose/insecure/mariadb/apache

The directory structure looks like this

[insecure/mariadb/apache]$ ls
db.env  docker-compose.yml

Here's the docker-compse file

# docker-compose.yml
version: '3'

services:
  db:
    image: mariadb:10.5
    command: --transaction-isolation=READ-COMMITTED --binlog-format=ROW
    restart: always
    volumes:
      - db:/var/lib/mysql
    environment:
      - MYSQL_ROOT_PASSWORD=hackme
      - MARIADB_AUTO_UPGRADE=1
      - MARIADB_DISABLE_UPGRADE_BACKUP=1
    env_file:
      - db.env

  redis:
    image: redis:alpine
    restart: always

  app:
    image: nextcloud:apache
    restart: always
    ports:
      - 127.0.0.1:8080:80
    volumes:
      - nextcloud:/var/www/html
    environment:
      - MYSQL_HOST=db
      - REDIS_HOST=redis
    env_file:
      - db.env
    depends_on:
      - db
      - redis

  cron:
    image: nextcloud:apache
    restart: always
    volumes:
      - nextcloud:/var/www/html
    entrypoint: /cron.sh
    depends_on:
      - db
      - redis

volumes:
  db:
  nextcloud:

and here's the db.env file

MYSQL_PASSWORD=hackme
MYSQL_DATABASE=nextcloud
MYSQL_USER=nextcloud

The instructions from the example README.md are as follows

  1. open `docker-compose.yml`
    1. insert your nextcloud domain behind `VIRTUALHOST=`and `LETSENCRYPTHOST=`
    2. enter a valid email behind `LETSENCRYPTEMAIL=`
    3. if you use mariadb or mysql choose a root password for the database behind `MYSQLROOTPASSWORD=`
  2. choose a password for the database user nextcloud in `db.env` behind `MYSQLPASSWORD=` (for mariadb/mysql) or `POSTGRESPASSWORD=` (for postgres)
  3. run `docker-compose build –pull` to pull the most recent base images and build the custom dockerfiles
  4. start nextcloud with `docker-compose up -d`

I already added in a password in the above examples (hackme (not recommended btw))

$ docker-compose build --pull
$ docker compose up

I left off the -d for now so I could see all the amazing things docker's doing for me.

I tested it by creating a user, uploading a file and shutting down the server and then checking to see if everything worked fine after I restarted it. Everything appears to be fine.

1.1.1. What's all this stuff?

Well in order for nextcloud to work it needs a pretty good database, an http server and a data store.

It can use a lot of different applications for this, all of which have their own costs and benefits, which is why they don't come packaged with nextcloud so you can make your own decision.

In this example we're using

  1. Mariadb for the database
  2. Redis for the datastore
  3. Apache for the webserver

1.1.2. What else do you need?

Well this example is under the `insecure` directory, so what do you need to make it secure? Well a domain with a valid SSL certificate.

If you don't have that there may be other solutions like using wireguard and a proxypass.

Created: 2023-02-08 Wed 23:12

Validate