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

Permission denied when installing with docker #1005

Closed
tiritibambix opened this issue Apr 20, 2024 · 4 comments
Closed

Permission denied when installing with docker #1005

tiritibambix opened this issue Apr 20, 2024 · 4 comments
Assignees

Comments

@tiritibambix
Copy link

tiritibambix commented Apr 20, 2024

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:
      - /srv/dev-disk-by-uuid-7fe66601-5ca0-4c09-bc13-a015025fe53a/Files/MediaCMS/:/home/mediacms.io/mediacms/
    environment:
      ENABLE_UWSGI: 'no'
      ENABLE_NGINX: 'no'
      ENABLE_CELERY_SHORT: 'no'
      ENABLE_CELERY_LONG: 'no'
      ENABLE_CELERY_BEAT: 'no'
      ADMIN_USER: 'redacted'
      ADMIN_EMAIL: 'redacted'
      ADMIN_PASSWORD: 'redacted'
    command: "./deploy/docker/prestart.sh"
    restart: on-failure
    depends_on:
      redis:
        condition: service_healthy
      db:
        condition: service_healthy
  web:
    image: mediacms/mediacms:latest
    deploy:
      replicas: 1
    ports:
      - "8870:80"
    volumes:
      - /srv/dev-disk-by-uuid-7fe66601-5ca0-4c09-bc13-a015025fe53a/Files/MediaCMS/:/home/mediacms.io/mediacms/
    environment:
      ENABLE_CELERY_BEAT: 'no'
      ENABLE_CELERY_SHORT: 'no'
      ENABLE_CELERY_LONG: 'no'
      ENABLE_MIGRATIONS: 'no'
    depends_on:
      - migrations
  celery_beat:
    image: mediacms/mediacms:latest
    volumes:
      - /srv/dev-disk-by-uuid-7fe66601-5ca0-4c09-bc13-a015025fe53a/Files/MediaCMS/:/home/mediacms.io/mediacms/
    environment:
      ENABLE_UWSGI: 'no'
      ENABLE_NGINX: 'no'
      ENABLE_CELERY_SHORT: 'no'
      ENABLE_CELERY_LONG: 'no'
      ENABLE_MIGRATIONS: 'no'
    depends_on:
      - redis
  celery_worker:
    image: mediacms/mediacms:latest
    deploy:
      replicas: 1
    volumes:
      - /srv/dev-disk-by-uuid-7fe66601-5ca0-4c09-bc13-a015025fe53a/Files/MediaCMS/:/home/mediacms.io/mediacms/
    environment:
      ENABLE_UWSGI: 'no'
      ENABLE_NGINX: 'no'
      ENABLE_CELERY_BEAT: 'no'
      ENABLE_MIGRATIONS: 'no'
    depends_on:
      - migrations
  db:
    image: postgres:15.2-alpine
    volumes:
      - /srv/dev-disk-by-uuid-7fe66601-5ca0-4c09-bc13-a015025fe53a/Files/MediaCMS/postgres_data:/var/lib/postgresql/data/
    restart: always
    environment:
      POSTGRES_USER: mediacms
      POSTGRES_PASSWORD: mediacms
      POSTGRES_DB: mediacms
      PGUSER: mediacms #added this for clarity in the logs
      TZ: Europe/Paris
    healthcheck:
      test: ["CMD-SHELL", "pg_isready", "--host=db", "--dbname=$POSTGRES_DB", "--username=$POSTGRES_USER"]
      interval: 10s
      timeout: 5s
      retries: 5
  redis:
    image: "redis:alpine"
    restart: always
    healthcheck:
      test: ["CMD", "redis-cli","ping"]
      interval: 30s
      timeout: 10s
      retries: 3
  1. docker-compose up -d

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
Copy link
Author

tiritibambix commented Apr 21, 2024

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
Copy link
Author

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

@tiritibambix
Copy link
Author

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
Copy link
Author

tiritibambix commented Apr 21, 2024

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

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