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 Submission: ONLYOFFICE Document Server for Nextcloud #1288

Merged
merged 7 commits into from
Aug 6, 2024
Merged

App Submission: ONLYOFFICE Document Server for Nextcloud #1288

merged 7 commits into from
Aug 6, 2024

Conversation

a4004
Copy link
Contributor

@a4004 a4004 commented Jul 29, 2024

App Submission

ONLYOFFICE Document Server

256x256 SVG icon

Icon

Gallery images

1
2
3
4
5

I have tested my app on:

  • umbrelOS on a Raspberry Pi
  • umbrelOS on an Umbrel Home
  • umbrelOS on Linux VM

@a4004
Copy link
Contributor Author

a4004 commented Jul 29, 2024

Gallery source images:

Document
nextcloud-light
Spreadsheet
Presentation
Forms DOCXF

Copy link
Contributor

@nmfretz nmfretz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really awesome work on this @a4004. Your onlyoffice-nextcloud-web frontend is excellent, and instructions are super clear 👌

I've left some suggestions below, mostly around how we can simplify the environment variables/exports script.

manifestVersion: 1
id: onlyoffice-nextcloud
category: files
name: ONLYOFFICE Document Server
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like they call themselves ONLYOFFICE Docs: https://github.com/ONLYOFFICE/DocumentServer

I'm not familiar with ONLYOFFICE, so I'll defer to you here. But an added benefit to shortening the name is that it will show up without an ellipses on the homescreen:

image

vs

image

Comment on lines 11 to 14
environment:
- DOCS_ADDRESS=http://$DEFAULT_INTERFACE_IP:$DOCSERVER_PORT
- DOCS_INTERNAL_ADDRESS=http://$DEFAULT_INTERFACE_IP:$DOCSERVER_PORT
- NEXTCLOUD_INTERNAL_ADDRESS=http://$DOCKER_INTERFACE_IP:$APP_NEXTCLOUD_PORT
Copy link
Contributor

@nmfretz nmfretz Aug 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can simplify this a bit and avoid needing to run ip-related commands in the exports.sh. I'm not very familiar with the Nextcloud/ONLYOFFICE ecosystem, so please let me know if anything I suggest here doesn't make sense or has unintended consequences:

  1. DOCS_ADDRESS=http://$DEFAULT_INTERFACE_IP:$DOCSERVER_PORT
    I'm thinking that most users will be accessing Nextcloud via umbrel.local not their IP address, so if they are using their local IP address in the nextcloud/onlyoffice config they will get hit with cors errors when clicking on a document in Nextcloud from http://umbrel.local:8081 and it tries to make a request to $DEFAULT_INTERFACE_IP:5672.

Shall we change this to DOCS_ADDRESS=http://$DEVICE_DOMAIN_NAME:$DOCSERVER_PORT (which will be http://umbrel.local:5672) and then include instructions saying that if a user is accessing Nextcloud from a different hostname/ip, they should change make the appropriate change to ONLYOFFICE Docs address in their Nextcloud settings?

**Edit: sorry @a4004 I sent you down the wrong path by accidently including :$DOCSERVER_PORT after the container name below **

  1. DOCS_INTERNAL_ADDRESS=http://$DEFAULT_INTERFACE_IP:$DOCSERVER_PORT
    This is for internal requests to the documentserver container, so we can just use the container name here and Docker's internal DNS will resolve it to the correct IP address. So I think we can change this to DOCS_INTERNAL_ADDRESS=http://onlyoffice-nextcloud_documentserver_1.
    The user will then copy-paste http://onlyoffice-nextcloud_documentserver_1 into the ONLYOFFICE settings in Nextcloud.

  2. NEXTCLOUD_INTERNAL_ADDRESS=http://$DOCKER_INTERFACE_IP:$APP_NEXTCLOUD_PORT
    I think we can get away without the export.sh ip command here as well. We actually have access to the gateway IP for the umbrel docker network as an env var. Check it out: https://github.com/getumbrel/umbrel/blob/570acdabcab13ac237fba992f491d126fff30810/packages/umbreld/source/modules/apps/legacy-compat/app-script#L10
    So we should be able to use NEXTCLOUD_INTERNAL_ADDRESS=http://$GATEWAY_IP:$APP_NEXTCLOUD_PORT which will yield http://10.21.0.1:8081/ for the user to copy-paste into the ONLYOFFICE settings in Nextcloud.

So a user would end up with this:

image

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nmfretz Is it not better to use something like http://nextcloud_web_1:8081? We are using container hostname reference on torrenting apps like Prowlarr, Radarr and Sonarr.

image

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's actually a good point.

I have tested both http://nextcloud_web_1/ and http://nextcloud_web_1:8081/ but it doesn't appear to work for some reason. Nextcloud is throwing an error Error when trying to connect (Error occurred in the document service: Error while downloading the document file to be converted.) (version 8.1.1.26).

Perhaps I'm doing something wrong here or it's not set up for this type of communication, not too sure but I agree with the idea of using container hostnames over IPs for sure.

Copy link
Contributor

@nmfretz nmfretz Aug 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@joaovictor-local @a4004, ya the issue here is that the Nextcloud app doesn't have the web container name as a trusted proxy in its config.php, so instead we are using an IP that it does trust (e.g., 10.21.0.1 or 172.17.0.1).

- NEXTCLOUD_TRUSTED_DOMAINS=${APP_DOMAIN}:${APP_NEXTCLOUD_PORT} ${APP_HIDDEN_SERVICE} ${DEVICE_HOSTNAME}:${APP_NEXTCLOUD_PORT} ${APP_NEXTCLOUD_LOCAL_IPS}

local_ips=$(hostname --all-ip-addresses 2> /dev/null) || local_ips=""
export APP_NEXTCLOUD_LOCAL_IPS="${local_ips}"

For this to work, the Nextcloud config.php would have to include nextcloud_web_1 under trusted_domains. Then in the field for Server address for internal requests from ONLYOFFICE Docs a user would use http://nextcloud_web_1, without a port specified since we want the default port 80 inside the web container (not 8081).

I do really like the simplicity of using container names @joaovictor-local, so we could consider the following:

  • Update the Nextcloud app to include nextcloud_web_1 in the config.php
  • Change the env var in ONLYOFFICE Docs to NEXTCLOUD_INTERNAL_ADDRESS=http://nextcloud_web_1
  • Include a note in the a4004/onlyoffice-nextcloud-web UI (or maybe just the app description) telling users to update Nextcloud if they haven't.

What do you guys think?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update: I have updated Nextcloud to allow connection via nextcloud_web_1 #1297

restart: on-failure
stop_grace_period: 1m
ports:
- 5672:80
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

might as well use - "${DOCSERVER_PORT}:80" from exports.sh

#!/usr/bin/env bash

export DOCSERVER_PORT=5672
export APP_DOCSERVER_PORT=3014
Copy link
Contributor

@nmfretz nmfretz Aug 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is export APP_DOCSERVER_PORT=3014 still needed, or can it be removed?

Comment on lines 6 to 7
export DEFAULT_INTERFACE_IP=$(ip addr show $(ip route | grep default | awk '{print $5}') | grep 'inet ' | awk '{print $2}' | cut -d/ -f1)
export DOCKER_INTERFACE_IP=$(ip addr show docker0 | grep 'inet ' | awk '{print $2}' | cut -d/ -f1)
Copy link
Contributor

@nmfretz nmfretz Aug 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we end up going with the simplifications here #1288 (comment), then we can remove these exports.

@a4004
Copy link
Contributor Author

a4004 commented Aug 1, 2024

Thanks for the suggestions @nmfretz! Happy with all of these:

I did some testing with the new configuration and there does seem to be an issue with using the container name for the ONLYOFFICE Docs address for internal requests from the server property.

onlyoffice-nextcloud_documentserver_1 correctly resolves on my machine howerver when the container IP is hit directly, it yields a HTTP/0.9 response that Nextcloud and Curl refuse to accept.

Hitting the docker0 or gateway IP (bridge device) works perfectly fine but using the the name or the container's actual IP from Docker doesn't work in my case.

So as a quick solution, we might be able to just use the $GATEWAY_IP for both the DOCS_INTERNAL_ADDRESS and NEXTCLOUD_INTERNAL_ADDRESS.

@a4004
Copy link
Contributor Author

a4004 commented Aug 1, 2024

To elaborate on the name change, it is a good idea and will improve the appearance of the app, but I also think some improvements can be made to the whole app in light of that.

I'm also consdering adding a startup screen, similar to how the Bitcoin Node and Lightning Node apps have it with a progress bar, so if a user clicks on the ONLYOFFICE Docs app, they will be redirected to the actual app within Nextcloud in a few seconds with the opportunity to cancel and view the setup instructions instead.

Ideally, there would be some configuration detection mechanism so it doesn't redirect upon the very first launch and only when it knows Nextcloud has been configured, but I think that's for a future update for now.

@a4004
Copy link
Contributor Author

a4004 commented Aug 1, 2024

Tested it on my instance and all looks good now. Should be ready to go.

@nmfretz
Copy link
Contributor

nmfretz commented Aug 5, 2024

Thanks @a4004!

Tested it on my instance and all looks good now. Should be ready to go.

Looks like you may have accidentally pushed the changes to a different branch https://github.com/a4004/umbrel-apps/commit/3daa6b91fcbb5b2c147f159e3b5ce2b7c40fd03b

onlyoffice-nextcloud_documentserver_1 correctly resolves on my machine howerver when the container IP is hit directly, it yields a HTTP/0.9 response that Nextcloud and Curl refuse to accept.

Just noting for our records that onlyoffice-nextcloud_documentserver_1 does indeed work as long as port 80 is hit (and not 8081 which is for the app proxy).

I'm also consdering adding a startup screen, similar to how the Bitcoin Node and Lightning Node apps have it with a progress bar, so if a user clicks on the ONLYOFFICE Docs app, they will be redirected to the actual app within Nextcloud in a few seconds with the opportunity to cancel and view the setup instructions instead.

This is a cool idea, but honestly I think there's a lot of benefit to having this app just stay on the instructions page because:

  1. Opening the app in Nextcloud just means viewing the admin settings for onlyoffice (is that right?).
  2. The onlyoffice integration in nexcloud is just used automatically when clicking on files. You don't actually go to some main onlyoffice homescreen.
  3. If a user needs to troubleshoot connection issues they can just open your onlyoffice-nextcloud app to see instructions.

That being said, this is your app, so it's totally up to you!

Also, @joaovictor-local @a4004 I've responded here with a suggestion on how we could use the nextcloud web container name: #1288 (comment)

Copy link

github-actions bot commented Aug 6, 2024

🎉   Linting finished with no errors or warnings   🎉

Thank you for your submission! This is an automated linter that checks for common issues in pull requests to the Umbrel App Store.

Please review the linting results below and make any necessary changes to your submission.

Linting Results

Severity File Description
ℹ️ onlyoffice-nextcloud/docker-compose.yml External port mapping "${DOCSERVER_PORT}:80":
Port mappings may be unnecessary for the app to function correctly. Docker's internal DNS resolves container names to IP addresses within the same network. External access to the web interface is handled by the app_proxy container. Port mappings are only needed if external access is required to a port not proxied by the app_proxy, or if an app needs to expose multiple ports for its functionality (e.g., DHCP, DNS, P2P, etc.).
ℹ️ onlyoffice-nextcloud/docker-compose.yml Potentially using unsafe user in service "web":
The default container user "root" can lead to security vulnerabilities. If you are using the root user, please try to specify a different user (e.g. "1000:1000") in the compose file or try to set the UID/PUID and GID/PGID environment variables to 1000.
ℹ️ onlyoffice-nextcloud/docker-compose.yml Potentially using unsafe user in service "documentserver":
The default container user "root" can lead to security vulnerabilities. If you are using the root user, please try to specify a different user (e.g. "1000:1000") in the compose file or try to set the UID/PUID and GID/PGID environment variables to 1000.

Legend

Symbol Description
Error: This must be resolved before this PR can be merged.
⚠️ Warning: This is highly encouraged to be resolved, but is not strictly mandatory.
ℹ️ Info: This is just for your information.

@nmfretz
Copy link
Contributor

nmfretz commented Aug 6, 2024

Thanks for pushing the changes @a4004. Absolutely fantastic work on this app! Going live to the app store 🎉.

FYI, I have done the following to finalize:

  • Changed NEXTCLOUD_INTERNAL_ADDRESS to use the nextcloud web container name and Docker dns (i.e., http://nextcloud_web_1). To make sure this works with the Nextcloud app on umbrelOS I have updated Nextcloud to include nextcloud_web_1 as a trusted domain for both new installs and pre-29.0.4 apps that update Update Nextcloud to v29.0.4 #1297
  • updated the tagline and app description to make it clear that this is for Nextcloud integration.
image

@nmfretz nmfretz merged commit b5da684 into getumbrel:master Aug 6, 2024
1 check passed
@anthony-robin
Copy link

Thank you very much for making ONLYOFFICE available to Umbrel and, furthermore, associated to NextCloud ❤️ 🎉

This PR closes #1086

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

Successfully merging this pull request may close these issues.

4 participants