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.74k stars 507 forks source link

Permission denied when installing with docker #1005

Closed tiritibambix closed 5 months ago

tiritibambix commented 5 months ago

Describe the issue Can't install with docker

To Reproduce Steps to reproduce the issue: I use OMV so the path is long and complicated

  1. cd /srv/dev-disk-by-uuid-7fe66601-5ca0-4c09-bc13-a015025fe53a/Files/
  2. git clone https://github.com/mediacms-io/mediacms
  3. cd mediacms
  4. nano docker-compose.yml
    
    version: "3"

services: migrations: image: mediacms/mediacms:latest volumes:

Expected behavior Should work

Environment (please complete the following information): OMV Latest Version 6.9.15-2 (Shaitan) Processor Intel(R) Core(TM) i5-4460 CPU @ 3.20GHz Kernel Linux 6.1.0-0.deb11.17-amd64

Additional context Database logs

Thanks for your help

tiritibambix commented 5 months ago

Okay so I left it running overnight and celery_beat and migrations containers are down but MediaCMS is working. Is this supposed to happen ? Can I remove those 2 containers if they're needed only for initial setup ?

I'm still getting these errors though:

2024-04-21 10:45:19.723 CEST [42] FATAL:  role "root" does not exist
2024-04-21 10:45:25.076 CEST [46] FATAL:  no pg_hba.conf entry for host "172.30.0.4", user "mediacms", database "mediacms", no encryption
2024-04-21 10:45:29.837 CEST [53] FATAL:  role "root" does not exist

Now, like others, I got an error 500 when trying to login, but I'll comment in another similar issue for this.

tiritibambix commented 5 months ago

Still can't login, and db returns a lot of issues

tiritibambix commented 5 months ago

Apparently, when trying to use bind volumes outside docker like I wish I could do (see my docker-compose), mediacms changes permissions to postgres_data to 700, despite forcing 755 prior to deployment.

tiritibambix commented 5 months ago

Oooookay, sooooooo... After pulling my hair for almost 24h, I stumbled upon this post and this post and I finally got it spinning with bind mounts.


cd /srv/path/Files
git clone https://github.com/mediacms-io/mediacms
cd /srv/path/Files/mediacms
mkdir postgres_data \
&& chmod -R 755 postgres_data
nano docker-compose.yaml
version: "3"

services:
  redis:
    image: "redis:alpine"
    restart: always
    healthcheck:
      test: ["CMD", "redis-cli","ping"]
      interval: 30s
      timeout: 10s
      retries: 3

  migrations:
    image: mediacms/mediacms:latest
    volumes:
      - /srv/path/Files/mediacms/deploy:/home/mediacms.io/mediacms/deploy
      - /srv/path/Files/mediacms/logs:/home/mediacms.io/mediacms/logs
      - /srv/path/Files/mediacms/media_files:/home/mediacms.io/mediacms/media_files
      - /srv/path/Files/mediacms/cms/settings.py:/home/mediacms.io/mediacms/cms/settings.py
    environment:
      ENABLE_UWSGI: 'no'
      ENABLE_NGINX: 'no'
      ENABLE_CELERY_SHORT: 'no'
      ENABLE_CELERY_LONG: 'no'
      ENABLE_CELERY_BEAT: 'no'
      ADMIN_USER: 'admin'
      ADMIN_EMAIL: 'admin@localhost'
      ADMIN_PASSWORD: 'complicatedpassword'
    restart: on-failure
    depends_on:
      redis:
        condition: service_healthy
  web:
    image: mediacms/mediacms:latest
    deploy:
      replicas: 1
    ports:
      - "8870:80" #whatever:80
    volumes:
      - /srv/path/Files/mediacms/deploy:/home/mediacms.io/mediacms/deploy
      - /srv/path/Files/mediacms/logs:/home/mediacms.io/mediacms/logs
      - /srv/path/Files/mediacms/media_files:/home/mediacms.io/mediacms/media_files
      - /srv/path/Files/mediacms/cms/settings.py:/home/mediacms.io/mediacms/cms/settings.py
    environment:
#      ENABLE_UWSGI: 'no' #keep commented
      ENABLE_CELERY_BEAT: 'no'
      ENABLE_CELERY_SHORT: 'no'
      ENABLE_CELERY_LONG: 'no'
      ENABLE_MIGRATIONS: 'no'

  db:
    image: postgres:15.2-alpine
    volumes:
      - /srv/path/Files/mediacms/postgres_data:/var/lib/postgresql/data/
    restart: always
    environment:
      POSTGRES_USER: mediacms
      POSTGRES_PASSWORD: mediacms
      POSTGRES_DB: mediacms
      TZ: Europe/Paris
    healthcheck:
      test: ["CMD-SHELL", "pg_isready", "--host=db", "--dbname=$POSTGRES_DB", "--username=$POSTGRES_USER"]
      interval: 30s
      timeout: 10s
      retries: 5

  celery_beat:
    image: mediacms/mediacms:latest
    volumes:
      - /srv/path/Files/mediacms/deploy:/home/mediacms.io/mediacms/deploy
      - /srv/path/Files/mediacms/logs:/home/mediacms.io/mediacms/logs
      - /srv/path/Files/mediacms/media_files:/home/mediacms.io/mediacms/media_files
      - /srv/path/Files/mediacms/cms/settings.py:/home/mediacms.io/mediacms/cms/settings.py
    environment:
      ENABLE_UWSGI: 'no'
      ENABLE_NGINX: 'no'
      ENABLE_CELERY_SHORT: 'no'
      ENABLE_CELERY_LONG: 'no'
      ENABLE_MIGRATIONS: 'no'

  celery_worker:
    image: mediacms/mediacms:latest
    deploy:
      replicas: 1
    volumes:
      - /srv/path/Files/mediacms/deploy:/home/mediacms.io/mediacms/deploy
      - /srv/path/Files/mediacms/logs:/home/mediacms.io/mediacms/logs
      - /srv/path/Files/mediacms/media_files:/home/mediacms.io/mediacms/media_files
      - /srv/path/Files/mediacms/cms/settings.py:/home/mediacms.io/mediacms/cms/settings.py
    environment:
      ENABLE_UWSGI: 'no'
      ENABLE_NGINX: 'no'
      ENABLE_CELERY_BEAT: 'no'
      ENABLE_MIGRATIONS: 'no'
    depends_on:
      - migrations
docker-compose up -d

CSS will probably be missing because reasons, so bash into web container

docker exec -it mediacms_web_1 /bin/bash

Then

python manage.py collectstatic

No need to reboot