Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Davis on Proxmox TrueNAS Scale SMB SQLite Docker-compose #164

Closed
tikr7 opened this issue Jul 27, 2024 · 9 comments
Closed

Davis on Proxmox TrueNAS Scale SMB SQLite Docker-compose #164

tikr7 opened this issue Jul 27, 2024 · 9 comments
Assignees

Comments

@tikr7
Copy link

tikr7 commented Jul 27, 2024

I switched to a Proxmox and TrueNAS Scale setup (as time of writing TrueNAS Charts got depricated) and was looking for a solution to manage WebDAV via GUI. Davis is really great for that because it separates users very well. Other WebDAV servers require one instance per user which is really in annoying.
In the past I used Nextcloud for it, but it is slow and updates were a huge pain. One day my Nextcloud instance got corrupted (the PostgreSQL to be more specific).

However, it took me some time to get it fully up and running, and therefore I want to write it down. Perhaps it helps somebody else in the future.

Some decisions I took:

  • I want TrueNAS for all data, since backup is very comfortable via ZFS and GUI. So I created a dataset, user, group and made SMB available.
  • I want to use docker-compose on Proxmox. Unfortunately, in order to bind a SMB, it needs to be a VM and not LXC on Proxmox.
  • I want a very lightweight database - so SQLite. It is easier to backup.

Mount SMB:

sudo apt-get install cifs-utils 

sudo mkdir /davis

vi /home/davis/.smbcredentials
username=davis
password=davispassword
chmod 600 /home/davis/.smbcredentials

#,nobrl ==> for fixing sqllite "database is locked"
sudo vi /etc/fstab
//192.168.XXX.XXX/Davis /davis cifs uid=82,gid=82,credentials=/home/davis/.smbcredentials,nobrl 0 0

sudo reboot now

I use the following folder structure:

sudo mkdir -p /davis/davis/data
sudo mkdir -p /davis/webdav/tmp
sudo mkdir -p /davis/webdav/public
sudo mkdir -p /davis/webdav/homes

Checkout repo:

git clone https://github.com/tchapi/davis.git
cd davis
git checkout -b v4.4.4 v4.4.4 # Use latest version

cd /home/davis/davis/docker

Fix Webdav Nginx: 413 Request Enity Too Large

vi configurations/davis.conf
server {
        client_max_body_size 100M;
...

Fix missing permissions on /var/www/davis:

vi Dockerfile
...
RUN chown -R ${FPM_USER} /var/www/davis

USER $FPM_USER
...

A bunch of configs:

vi .env
ADMIN_PASSWORD=<...>

#WEBDAV_ENABLED=false
WEBDAV_ENABLED=true

#WEBDAV_TMP_DIR='/tmp'
#WEBDAV_PUBLIC_DIR='/webdav'
WEBDAV_TMP_DIR='/webdav/tmp'
WEBDAV_PUBLIC_DIR='/webdav/public'
WEBDAV_HOMES_DIR='/webdav/homes'

Adjusting the docker-compose file:

vi docker-compose-sqlite.yml
    restart: always # VM restart safe
...
    restart: always # VM restart safe
...
    volumes:
      - davis_www:/var/www/davis
#      - davis_data:/data
      - /davis/davis/data:/data
      - /davis/webdav/tmp:/webdav/tmp
      - /davis/webdav/public:/webdav/public
      - /davis/webdav/homes:/webdav/homes
volumes:
  davis_www:
    name: davis_www
#  davis_data:
#    name: davis_data

Let's start it =)

cd /home/davis/davis/docker
sudo docker compose -f docker-compose-sqlite.yml up -d 

#⚠ Do not forget to run all the database migrations the first time you run the container :
sudo docker exec -it davis sh -c "APP_ENV=prod bin/console doctrine:migrations:migrate --no-interaction"
@tikr7
Copy link
Author

tikr7 commented Jul 27, 2024

@tchapi maybe you want to fix something upstream but not needed.

Feel free to close this here!

@tchapi
Copy link
Owner

tchapi commented Jul 27, 2024

Thanks for the clear write up. I think 44eae84 is the solution to the ../.env problem (the env var was not bubbled up the container via the example compose file)

Can you confirm by any chance?

@tchapi tchapi self-assigned this Aug 3, 2024
@tchapi
Copy link
Owner

tchapi commented Aug 3, 2024

Hello @tikr7 👋🏼
Have you had a change to test the commit in my message above? Thanks!

@tikr7
Copy link
Author

tikr7 commented Aug 5, 2024

Still have it on my todo list. I was 1 week off.
I hope I can do it today in the evening =)

@tchapi
Copy link
Owner

tchapi commented Aug 5, 2024

I hope I can do it today in the evening =)

No pressure at all, just wanted to make sure we can converge on a solution :) I'll be less active in the coming two weeks in any case

@tikr7
Copy link
Author

tikr7 commented Aug 6, 2024

Cool. I tested it and I can confirm WEBDAV_HOMES_DIR works now in .env !
I updated my manual above.

Another thing I found out during my testing: Just if I use docker-compose-sqlite.yml with the default - davis_data:/data (my manual uses SMB mount there) then after:

#⚠ Do not forget to run all the database migrations the first time you run the container :
sudo docker exec -it davis sh -c "APP_ENV=prod bin/console doctrine:migrations:migrate --no-interaction"

It creates the /data/davis-database.db as root.
The following needs to be done then:

sudo docker exec -it davis sh -c "chown www-data: /data /data/davis-database.db" # Yes, possible also with -R

Hard to debug because the Davis homepage only gives a non-meaningful error when trying to create a user.

@tchapi
Copy link
Owner

tchapi commented Aug 6, 2024

It creates the /data/davis-database.db as root.

As yes, it's expected. I'll add a warning in the README, thanks!

EDIT: it's already in there in the fullstack section (the warning block): https://github.com/tchapi/davis?tab=readme-ov-file#full-stack

@tikr7
Copy link
Author

tikr7 commented Aug 7, 2024

True, I missed that.
Thank you so much for your support, @tchapi !

@tchapi
Copy link
Owner

tchapi commented Aug 17, 2024

(Closing this issue for housekeeping but I'll probably add a section with "how-to's" in the readme soon)

https://github.com/tchapi/davis?tab=readme-ov-file#-how-tos

@tchapi tchapi closed this as completed Aug 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants