How to fix permissions issues when using volumes to persists the data?

I am using the image nextcloud:production-fpm-alpine.
I tried to fix the permissions via a chown command to fix them but I am not sure how to launch the app correctly after that. I use the tail command to be sure that the container will not stop but…
If I use /entrypoint.sh instead, it will say that parameters are missing.
Here is my Dockerfile :

version: '3.8'

volumes:
  db:
  nextcloud:

services:
  db:
    image: postgres:alpine
    restart: always
    volumes:
      - db:/var/lib/mysql
    environment:
      - POSTGRES_DB_FILE=/run/secrets/postgres_db
      - POSTGRES_USER_FILE=/run/secrets/postgres_user
      - POSTGRES_PASSWORD_FILE=/run/secrets/postgres_password
    secrets:
      - postgres_db
      - postgres_user
      - postgres_password
    ports:
      - "5433:5432"

  app:
    image: nextcloud:production-fpm-alpine
    restart: always
    volumes:
      - nextcloud:/var/www/html
      - ./project/apps:/var/www/html/custom_apps
      - ./project/config:/var/www/html/config
      - ./project/data:/var/www/html/data

    depends_on:
      - db
    environment:
      - POSTGRES_HOST=db
      - POSTGRES_DB_FILE=/run/secrets/postgres_db
      - POSTGRES_USER_FILE=/run/secrets/postgres_user
      - POSTGRES_PASSWORD_FILE=/run/secrets/postgres_password
      - NEXTCLOUD_ADMIN_PASSWORD_FILE=/run/secrets/nextcloud_admin_password
      - NEXTCLOUD_ADMIN_USER_FILE=/run/secrets/nextcloud_admin_user
      - NEXTCLOUD_TRUSTED_DOMAINS=dev.cloud.otra.tech
    secrets:
      - nextcloud_admin_password
      - nextcloud_admin_user
      - postgres_db
      - postgres_password
      - postgres_user
    command: sh -c 'chown -R www-data:www-data /var/www/html && tail -f /dev/null'
  web:
    build: ./nginx
    image: nginx:stable-alpine-lp
    restart: always
    ports:
      - "8080:80"
      - "444:443"
    depends_on:
      - app
    volumes:
      - nextcloud:/var/www/html:ro
      - ./nginx/nginx.conf:/etc/nginx/nginx.conf:ro
      - ./nginx/certs:/etc/nginx/certs:ro

secrets:
  nextcloud_admin_password:
    file: ./secrets/nextcloud_admin_password.txt
  nextcloud_admin_user:
    file: ./secrets/nextcloud_admin_user.txt
  postgres_db:
    file: ./secrets/postgres_db.txt
  postgres_password:
    file: ./secrets/postgres_password.txt
  postgres_user:
    file: ./secrets/postgres_user.txt

How can I modify the command: parameter to make it work?

Now I removed my command; line to show the error in order to add precisions to my post but … I do not see the permissions issues but have a message saying that I am trying to reinstall NextCloud (false, I just want to make persistent my volumes).
So I cleaned the stopped containers, unused volumes etc…
And now I have a 502 bad request… :weary:

I now use a more recent version of NextCloud, the version 23.0.5.1. (was using Nextcloud 21.x.x.x).
Now I have :

PostgreSQL username and/or password not valid
2022-05-26T12:58:39.004423067Z → You need to enter details of an existing account.

I have updated Nginx too and now I have :

[emerg] 1#1: unexpected end of parameter, expecting “;” in command line

It seems I will always have a bug.

I had replaced daemon by daemon off; in

FROM nginx:stable-alpine
ENTRYPOINT ["/docker-entrypoint.sh"]
EXPOSE 80 443
STOPSIGNAL SIGQUIT
CMD ["nginx","-g","daemon off;"]

and now I have…again problem with the database installation :weary:

Hmm the database issue was just due to not removing the volumes. I do a clean up via PHPStorm but that wasn’t enough. I should put again the permissions fix in the command key now :thinking: .