Selfhosted Youtube Alternative On Unraid - Part 2

Okay, we've gotten the docker-compose container stack running on our Unraid server, now to configure it! This is going to be unique to my install somewhat, but hopefully bits and pieces may be helpful.


Email via Gmail SMTP

I currently use a Gmail account to send email notifications from my various apps, so I wanted to get that hooked up.

The first catch is, you can no longer just log into an account automatically on the Gmail smtp servers. Once you have an account, you have to set it up properly with an application specific password.

Once we have an account to use, in order to override settings in our docker-compose-driven stack, we want to follow the official instructions and copy/change configs from the MediaCMS/root/settings.py file to the MediaCMS/deploy/docker/local_settings.py file. Remember to restart your stack after changing this file.

settings.py default email settings

For Gmail,  you want to set these as follows:

#email settings
DEFAULT_FROM_EMAIL = "from address"
EMAIL_HOST_PASSWORD = "application password you set up above"
EMAIL_HOST_USER = "account to send emails from"
EMAIL_USE_TLS = True
SERVER_EMAIL = DEFAULT_FROM_EMAIL
EMAIL_HOST = "smtp.gmail.com"
EMAIL_PORT = 587
ADMIN_EMAIL_LIST = ["admins@email.address", "admins@second_email.address"] # only one email is necessary I think


Application Settings

Most of the rest of the settings have labels or names that are self-explanatory. Here are some values to look out for that you may want to update:

FRONTEND_HOST, PORTAL_NAME, TIME_ZONE, everything in the block under the line # django-allauth settings, CAN_ADD_MEDIA

Also, the ALLOWED_HOSTS value should contain a python formatted list of strings that contains all of the IP addresses and hosts the server could be using. I added my public URL, and my docker IPs (with wildcard asterisks * in place of any part of the docker IPs that might change).

Here's a fun note: Make sure your email settings work properly before changing ACCOUNT_EMAIL_VERIFICATION to 'mandatory' or you will just not be able to log in to any accounts since no emails are verified.


Admin Controls

You may have noticed that once you log into your MediaCMS instance as an admin, if you click your profile pic in the top right of the page, the dropdown has a link for "MediaCMS adminstration." This takes you to the site's admin panel (which is a django feature, if you know python web development) where you can access and modify data stored in the database. This might be useful if you need to mark an email address as verified, flip through your site's data, or similar.


Media Storage

So I don't want my media stored in the same place as my website container code/configs. On Unraid, those things should live on your cache and in my previous post I indicated I left them in an Unraid /mnt/user/appdata/ directory.

Quick note before you go through this, the easiest way I've found to test that your storage location works is to log into the site and then go to your profile and attempt to upload a new profile pic. If you get an error page, something's wrong!
docker-compose section for the web container

So by default, MediaCMS wants to put your uploaded media into media_files/ in its root directory. So what I did, as per a discussion thread I found on the MediaCMS code repo, is just to mount an external directory as the /mediacms/media_files/ directory. If you don't understand Docker volumes, this means the container thinks /mediacms/ is in one place and has a media_files/ directory, but actually that points to a separate location on your host server. I believe that you do have to do this for both the "web" and the "celery-worker" containers.

If you want to know more about Celery, I'm just now learning it for the first time at work, but you can read documentation on their website.

Another note: For some reason this wouldn't work if I mounted media_files/ to an external storage NAS. I think I need to use a slightly more complex method in the docker-config by naming a separate location, but I'll circle back to that later. If this is a priority for you and you need help, let me know and I will try to get it working.


I changed the colors of the buttons! Woo!

Customize Theme

The only reason I'm mentioning this is because I didn't see it in the docs. I therefore assume there is no theming built into MediaCMS, I haven't found it or read anything about it. All I've figured out so far is how to change the images (favicon, logos, etc). I was also able to open all the CSS files in my editor IDE and change the main theme color in all files via search/replace. I'm not 100% sure on which CSS files do need to be changed but I'll figure it out later it should just take some poking around.

The files are located here, and I will update this with more info as I learn more:

Logos in the web source code: /MediaCMS/frontend/src/static/images/
Stylesheets: /MediaCMS/frontend/src/static/css/ &  /MediaCMS/static/css/


Volume definition

Moving media files to another (external) location

I don't think there's a great place in the Unraid filesystem for your site's media files. The cache will likely not be large enough, and you don't want your array spinning up constantly. At least I don't. Here's how I moved those files to an external NAS device.

First, create a directory on the remote device you wish to use. I assume here that your server can reach your storage (maybe using the Unassigned Devices plugin if you're on Unraid like me).

Second, in your docker-config, what I did was create a named volume with some specific driver options - you can learn more about these on the docker docs and the mount docs.

volumes:
 media_files:
   driver_opts:
     type: none
     o: bind
     device: /path/to/the/directory/you/just/made/

Then, in the docker-config for your web and celery_worker containers, you want to set the media_files directory to use the volume you just defined. This looks like media_files:/home/mediacms.io/mediacms/media_files/

That should be it. Now your media_files directory inside the MediaCMS directory will point to your external file location.


Couple other quick things

To aid with troubleshooting errors, MediaCMS stores log files in the /MediaCMS/logs/ directory, debug.log should be especially helpful if you are tracking down issues.

You might want to update the email templates located in /MediaCMS/templates/account/ - I'm not totally sure where the values used in there are coming from yet, though.

Go to the admin panel (log in as a superuser account -> profile button in the top right -> admin page) and change the only site listed in the sites section. Just update it to match your MediaCMS site's url. Warning if you delete and re-create this instead of just editing it, you will have to add the SITE_ID value to your local_settings.py and set it to the new ID of the new site record in the database (2?).


Okay thanks for following along with setting up your MediaCMS instance. I have a few more ideas to test out, including getting Hardware Acceleration working for video re-encodes, so stay tuned. Thanks again for reading, and feel free to comment below if you have anything to share or ask!