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

App issue: [Nextcloud] Improve template, add path to choose installation folder #1100

Open
Emilien-Lambert opened this issue May 2, 2024 · 2 comments

Comments

@Emilien-Lambert
Copy link
Contributor

Hello, I'd like to propose an enhancement to Nextcloud's One Click App template, to add the ability to set folder path to use for nextcloud installation.

I tried to make this enhancement myself by adding the $$cap_appname-data variable at install time. But for some reason, the path is not taken into account and caprover uses the default path as in this image.

image

However, I did add this to the template:

        - id: $$cap_appname-data
          label: Path to store data
          defaultValue: /mnt/myFolder/
          description: Path where the data will be stored on the host machine. (e.g. /mnt/data, /home/user/data)
          validRegex: '/.{1,}/'

There must be a syntax error, if someone experienced in One Click App templates would like to give me some advice, that would be nice.

I asked the question on caprover's Slack but didn't get an answer and saw in the documentation that it was possible to open an issue here. I hope this is allowed and that I'm in the right place.

Best regards

Here is the complete template:

captainVersion: 4
services:
    $$cap_appname-db:
        documentation: Taken from https://hub.docker.com/_/mariadb
        image: mariadb:$$cap_mariadb_version
        volumes:
            - $$cap_appname-db-data:/var/lib/mysql
        restart: always
        environment:
            MYSQL_ROOT_PASSWORD: $$cap_db_pass
            MYSQL_DATABASE: nextcloud
            MYSQL_USER: $$cap_db_user
            MYSQL_PASSWORD: $$cap_db_pass
        caproverExtra:
            notExposeAsWebApp: 'true'
    $$cap_appname-redis:
        documentation: Taken from https://github.com/nextcloud/docker/blob/master/.examples/docker-compose/with-nginx-proxy/mariadb-cron-redis/apache/docker-compose.yml
        image: redis:$$cap_redis_version
        restart: always
        volumes:
            - $$cap_appname-redis-data:/data
        caproverExtra:
            notExposeAsWebApp: 'true'
    $$cap_appname:
        depends_on:
            - $$cap_appname-db
            - $$cap_appname-redis
        documentation: Taken from https://hub.docker.com/_/nextcloud
        image: nextcloud:$$cap_nextcloud_version
        volumes:
            - $$cap_appname-data:/var/www/html
        restart: always
        environment:
            OVERWRITEPROTOCOL: $$cap_http_https_cors
            MYSQL_DATABASE: nextcloud
            MYSQL_USER: $$cap_db_user
            MYSQL_PASSWORD: $$cap_db_pass
            MYSQL_HOST: srv-captain--$$cap_appname-db
            REDIS_HOST: srv-captain--$$cap_appname-redis
            NEXTCLOUD_ADMIN_USER: $$cap_admin_user
            NEXTCLOUD_ADMIN_PASSWORD: $$cap_admin_pass
            NEXTCLOUD_TRUSTED_DOMAINS: $$cap_appname.$$cap_root_domain $$cap_hostnames
    $$cap_appname-cron:
        depends_on:
            - $$cap_appname-db
            - $$cap_appname-redis
            - $$cap_appname
        documentation: https://github.com/nextcloud/docker/blob/master/.examples/docker-compose/with-nginx-proxy/mariadb-cron-redis/apache/docker-compose.yml
        restart: always
        volumes:
            - $$cap_appname-data:/var/www/html
        caproverExtra:
            dockerfileLines:
                - FROM nextcloud:$$cap_nextcloud_version
                - 'ENTRYPOINT [ "/cron.sh" ] '
            notExposeAsWebApp: 'true'
caproverOneClickApp:
    variables:
        - id: $$cap_nextcloud_version
          label: NextCloud Version
          defaultValue: 28.0.5
          description: >-
              Check out their Docker page for the valid tags https://hub.docker.com/_/nextcloud?tab=tags
              Do not use fpm versions.
          validRegex: /^((?!fpm)\S)+$/
        - id: $$cap_appname-data
          label: Path to store data
          defaultValue: /mnt/myFolder/
          description: Path where the data will be stored on the host machine. (e.g. /mnt/data, /home/user/data)
          validRegex: '/.{1,}/'
        - id: $$cap_redis_version
          label: Redis Version
          defaultValue: 7.2.4
          description: Check out their Docker page for the valid tags https://hub.docker.com/_/redis?tab=tags
          validRegex: /^([^\s^\/])+$/
        - id: $$cap_mariadb_version
          label: MariaDB (database) version
          defaultValue: 11.2.3
          description: Check out their Docker page for the valid tags https://hub.docker.com/_/mariadb?tab=tags
          validRegex: /^([^\s^\/])+$/
        - id: $$cap_db_user
          label: database user
          defaultValue: nextcloud
          description: Username for the database using mysql.
          validRegex: /^([a-zA-Z0-9])+$/
        - id: $$cap_db_pass
          label: database password
          defaultValue: $$cap_gen_random_hex(32)
          description: Password for the database user and root using mysql.
          validRegex: /.{1,}/
        - id: $$cap_admin_user
          label: admin name
          defaultValue: admin
          description: Name of the Nextcloud admin user.
          validRegex: /^([a-zA-Z0-9\@\.])+$/
        - id: $$cap_admin_pass
          label: admin password
          defaultValue: $$cap_gen_random_hex(10)
          description: Password for the Nextcloud admin user.
          validRegex: /.{8,}/
        - id: $$cap_http_https_cors
          label: Protocol of proxy
          defaultValue: https
          description: Choose either http or https. cors configuration to login are set by the docker image, if you do not set this same as your proxy configuration, login will fail
          validRegex: /^http[s]?$/
        - id: $$cap_hostnames
          label: hostnames
          description: Add all your additional hostnames where nextcloud will be exposed separated by space char. After first run, this variables are not reloaded by nextcloud and you will have to change the configuration according to the nextcloud's documentation.
    instructions:
        start: A safe home for all your data. Access & share your files, calendars, contacts, mail & more from any device, on your terms. http://Nextcloud.com
        end: >-
            NextCloud is deployed and will be available on few minutes as $$cap_appname.

            If you set the cors sections to https, please enable https on your app. If you do not activate it you will have an error.


            For better performances and compliance, click on "edit default nginx configuration" button then
            below `proxy_set_header X-Forwarded-Proto $scheme;`
            add `add_header Strict-Transport-Security "max-age=15552000; includeSubDomains" always;`  into the nginx configuration.

            For DAV add after `/.well-known/captain-identifier` section 

            `location /.well-known/carddav {return 301 $scheme://$host/remote.php/dav;}`

            `location /.well-known/caldav {return 301 $scheme://$host/remote.php/dav;}`

            You can see HSTS parts of the nextcloud security documentation [https://docs.nextcloud.com/server/21/admin_manual/installation/harden_server.html](https://docs.nextcloud.com/server/21/admin_manual/installation/harden_server.html) for further informations


            You can also scan your nextcloud instance on [https://scan.nextcloud.com/](https://scan.nextcloud.com/)
    displayName: Nextcloud
    isOfficial: true
    description: Nextcloud is a suite of client-server software for creating and using file hosting services
    documentation: Taken from https://hub.docker.com/_/nextcloud
@githubsaturn
Copy link
Collaborator

The main reason that it doesn't work is that cap_appname first gets replaced.
Try renaming $$cap_appname-data to $$cap_data_volume . It might work.

But there might be other limitations in the flow that might limit the usage of a path. You'll know once you try above. Let me know once you find out!

@Emilien-Lambert
Copy link
Contributor Author

@githubsaturn Thanks for the tips indeed, that was indeed the problem for the volume :) 👍

Yes, as you say, there are other issues to be resolved for this to work. After renaming the variable to $$cap_data_volume, the Nextcloud application fails to start up correctly.

I'm currently experimenting with a customized volume. I'll keep you informed of progress here.

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