:PROPERTIES:
:ID:       56f39be4-1108-4020-be5a-1f3a0fbf96fa
:END:
#+title: nextcloud
#+filetags: :self-hosting:

* The docker file:

#+begin_src bash

  version: '3.8'
  services:
    app:
      image: nextcloud
      restart: unless-stopped
      ports:
        - 8007:80
      volumes:
        - nextcloud:/var/www/html
      environment:
        - POSTGRES_DB=nextcloud
        - POSTGRES_USER=nextcloud
        - POSTGRES_PASSWORD=zxq123_nextcloud
        - POSTGRES_HOST=postgres
      networks:
        - postgres_network

  volumes:
    nextcloud:

  networks:
    postgres_network:
      external: true

#+end_src

* Database related things:

#+begin_src bash

  zxq_db=# CREATE DATABASE nextcloud;
  CREATE DATABASE
  zxq_db=# CREATE USER nextcloud WITH PASSWORD 'zxq123_nextcloud';
  CREATE ROLE
  zxq_db=# GRANT ALL PRIVILEGES ON DATABASE nextcloud TO nextcloud;
  GRANT
  zxq_db=# 

#+end_src


* Permissions:

#+begin_src bash
  
# Add yourself and www-data to a shared group

### Create a shared group:

sudo groupadd ncshare

### Add both users:

sudo usermod -aG ncshare zaine
sudo usermod -aG ncshare www-data

### Set the folder to that group:

sudo chown -R zaine:ncshare /home/zaine/master-folder
sudo chmod -R 775 /home/zaine/master-folder


#+end_src

* Config

Location is:

sudo nano /var/lib/docker/volumes/nextcloud_nextcloud/_data/config/config.php

* Accounts
User is: zaine
Pass: Shakkal123!

* Legacy stuff
Something I've been trying to reverse proxy ahead of time. Go to https://zserver.zapto.org/nextcloud , you'll be prompted to login with a username and password:
Here's your credentials:

Username: halima
Password: loser2104!

Once you've logged in, I've set up your account already, so there should be a calendar already there. 

To get your phone logged in, there's two ways:
1) go to the following address: https://zserver.zapto.org/nextcloud/settings/user/security , scroll to the bottom, under devices and sessions, type in a random name (iphone), and click create new app password. You should then be able to generate a QR code (next to or under the password field), then you can scan that on your iphone app.

2) inside the app, type the following URL:  https://zserver.zapto.org/nextcloud then follow the instructions.

Im thinking of having this as our shared calendar and file system. The only users are us 2 and its completely off the internet (self-hosted).


** network issues resolved by:

#+begin_src bash

  docker network connect postgres_network postgres

  zaine@zaine-HP-ProDesk-400-G1-SFF [21:00:27] [~/docker-services/nextcloud] 
  -> % psql -h zserver.zapto.org -p 5432 -U zaine -d zxq_db
  Password for user zaine: 
  psql (14.18 (Ubuntu 14.18-0ubuntu0.22.04.1), server 17.5 (Debian 17.5-1.pgdg120+1))
  WARNING: psql major version 14, server major version 17.
  Some psql features might not work.
  Type "help" for help.

  zxq_db=# \c nextcloud
  psql (14.18 (Ubuntu 14.18-0ubuntu0.22.04.1), server 17.5 (Debian 17.5-1.pgdg120+1))
  WARNING: psql major version 14, server major version 17.
  Some psql features might not work.
  You are now connected to database "nextcloud" as user "zaine".
  nextcloud=# GRANT ALL PRIVILEGES ON DATABASE nextcloud TO nextcloud;
  GRANT
  nextcloud=# GRANT USAGE ON SCHEMA public TO nextcloud;
  GRANT CREATE ON SCHEMA public TO nextcloud;
  GRANT
  GRANT
  nextcloud=# GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO nextcloud;
  GRANT
  nextcloud=# GRANT ALL PRIVILEGES ON ALL SEQUENCES IN SCHEMA public TO nextcloud;
  GRANT
  nextcloud=# 

  zaine
  M22ZN-fmefj-RdF36-3BMfT-LfWo8

  zaine
  zxh123!

#+end_src
