mediacms-io / mediacms

MediaCMS is a modern, fully featured open source video and media CMS, written in Python/Django and React, featuring a REST API.
https://mediacms.io
GNU Affero General Public License v3.0
2.86k stars 533 forks source link

can not change MEDIA_ROOT to an USB drive #1091

Open SDFTDusername opened 1 month ago

SDFTDusername commented 1 month ago

Describe the issue I want to store all media and their encoded files on my USB drive, but when I try to do that I can't upload videos anymore.

I tried setting MEDIA_ROOT in /home/mediacms.io/mediacms/cms/settings.py to /mnt/f/media_files/ and tried mounting the usb to /home/mediacms.io/mediacms/media_files

but neither worked. when I try to upload something, it retries twice and then fails. it only works if MEDIA_ROOT points at /home/mediacms.io/mediacms/media_files (default) without the usb mounted to that path.

I tried this with the USB formatted to exFAT and NTFS

Expected behavior it should work like normal.

Environment

yatesdr commented 1 month ago

Did you check the permissions on the mount location? The docker install needs write access to whatever you're trying to write.

cd /mnt/f ls -lah check the permissions assigned, if they're 755 for your user / your group, mediaCMS won't be able to write there as it runs under some other user typically. chmod 777 media_files

If that fixes it, you know it's a permissions issue with your mount. It's not really a great idea to just leave it as 777, so you'll have to figure out what user and group mediacms is running as and change to 775 and chgrp to the appropriate permissions.

SDFTDusername commented 1 month ago

when i run ls -lah, it says that the media_files directory is drwxrwxrwx, which means full permission, and running chmod 777 media_files doesn't change anything. also it writes just fine. i tried uploading an image and even though the website says it fails, i can see the image at /mnt/f/media_files/uploads/{random-uuid} but i don't see the videos of failed uploads at /mnt/f/media_files/original/user/{username} and /mnt/f/media_files/encoded/{num}/{username}

yatesdr commented 1 month ago

That almost sounds like it's writing with permissions it can't read. Did you check the permissions that got set on the "failed" image upload that appeared? If those are okay, then you may need to also check your postgres_data directory and make sure the database writes aren't failing for some reason.

I have had a bunch of trouble with permissions trying to run it for development with docker on MacOS that I was unable to solve, but it ran properly on ubuntu server in docker as a generic user.

SDFTDusername commented 1 month ago

where's the postgres_data directory? the files also have full permissions. also i checked and i'm able to see the failed video uploads, i just didn't check the right directory

yatesdr commented 1 month ago

On my system, it created it in the root folder, but I'm running a docker instance. It should be set in your config somewhere, check there. Aside from that, I'm out of ideas, will have to wait for someone more knowledgeable to come along if you can't get it sorted.

SDFTDusername commented 3 weeks ago

there is no postgres_data directory. i ran find / -type d -name 'postgres_data' but nothing was found, maybe that directory is only for docker instances?

gimail commented 3 weeks ago

Installing Docker on WSL (Windows Subsystem for Linux) and deploying MediaCMS can be done using the following steps. Here we will assume that you are using WSL 2 and the Ubuntu distribution. If WSL 2 is not configured yet, make sure that you have done so before you start installing Docker.

   Step 1: Make sure that WSL 2 is installed and configured
  1. Open PowerShell as an administrator and run: bash wsl --set-default-version 2

  2. Make sure that you have the Ubuntu distribution installed. If not, install it through the Microsoft Store. Step 2: Install Docker on Ubuntu in WSL

  3. Open your Ubuntu session in WSL.

  4. Update the package list and install the necessary dependencies: bash sudo apt update sudo apt install apt-transport-https ca-certificates curl software-properties-common

  5. Install the Docker GPG key: bash curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

  6. Add the Docker repository to the list of package sources: bash echo "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list

  7. Update the package list again: bash sudo apt update

  8. Install Docker: bash sudo apt install docker-ce

  9. After installing Docker, run the Docker daemon: bash sudo service docker start

    Step 3: Configure Docker to work without sudo (optional) If you want to run Docker without using sudo, add your user to the Docker group. bash sudo usermod -aG docker $USER

After executing this command, you will need to log out and log in again for the changes to take effect. Step 4: Install Docker Compose (optional) If MediaCMS requires Docker Compose, install it:

  1. Install Docker Compose: bash sudo apt install docker-compose

  2. Check the installation: bash docker-compose --version

    Step 5: Install MediaCMS Now you are ready to install MediaCMS. Create a directory in Windows in another drive for your project and navigate to it and copy mediacms there: in WSL Ubuntu, go to the directory in Windows cd /mnt/d/mediacms

Edit the 'docker-compose' file.yml` with settings for MediaCMS. Sample content: version: "3" services: migrations: image: mediacms/mediacms:latest volumes:

After that, check the operation of the container. docker start $(docker ps -aq) starting all containers after installing MediaCMS

mgogoulos commented 3 weeks ago

That almost sounds like it's writing with permissions it can't read. Did you check the permissions that got set on the "failed" image upload that appeared? If those are okay, then you may need to also check your postgres_data directory and make sure the database writes aren't failing for some reason.

I have had a bunch of trouble with permissions trying to run it for development with docker on MacOS that I was unable to solve, but it ran properly on ubuntu server in docker as a generic user.

i don't have much experience with MacOS but if there are specific suggestions to improve things it would be great! I'm mainly using/developing in Linux where things run smoothly, however I see there are many people in MacOS and Windows too

yatesdr commented 3 weeks ago

That almost sounds like it's writing with permissions it can't read. Did you check the permissions that got set on the "failed" image upload that appeared? If those are okay, then you may need to also check your postgres_data directory and make sure the database writes aren't failing for some reason. I have had a bunch of trouble with permissions trying to run it for development with docker on MacOS that I was unable to solve, but it ran properly on ubuntu server in docker as a generic user.

i don't have much experience with MacOS but if there are specific suggestions to improve things it would be great! I'm mainly using/developing in Linux where things run smoothly, however I see there are many people in MacOS and Windows too

I wasn't able to get it to run in Docker on MacOS, and wound up spinning up a new VM on Ubuntu 22 to test on instead. I think it has to do with the way bind mounts are set up for Colima vs dockerd / containerd, in that the permissions for some files can't be directly set by Colima as you would with a rootful normal docker compose. The failure is when it gets into chown the files that are passed into the container - and It's not clear why exactly this is the case but I wouldn't worry about it too much, it works great with the regular docker compose client everywhere else I've tried it!