irislib / iris-messenger

Decentralized messenger
https://iris.to
MIT License
719 stars 159 forks source link

Add Iris to Umbrel App Store #258

Open nevets963 opened 1 year ago

nevets963 commented 1 year ago

It would be great to see Iris in the Umbrel App Store and for folks to self-host their own Nostr client. Additionally as we just launched a private Nostr Relay (https://twitter.com/umbrel/status/1622591145481236480) that works over ws://, a self-hosted version of Iris running over HTTP would be able to connect to it (and other relays using wss://).

I see that a Dockerfile already exists, but would you accept a PR that adds a GitHub workflow to automatically build and push a Docker image to the Docker Hub? I've done these before where it's triggered when a new tag is created that marks a new version (e.g. v1.2.3), so this would also mean that new tags would need to be created as new versions of Snort go live.

mmalmi commented 1 year ago

It would be great to see Iris in the Umbrel App Store and for folks to self-host their own Nostr client. Additionally as we just launched a private Nostr Relay (https://twitter.com/umbrel/status/1622591145481236480) that works over ws://, a self-hosted version of Iris running over HTTP would be able to connect to it (and other relays using wss://).

Unfortunately, Iris might not work over http because it's using webcrypto. Browsers have these weird limitations. But we can see how it goes, and work around it, replacing webcrypto with js libs if needed.

I see that a Dockerfile already exists, but would you accept a PR that adds a GitHub workflow to automatically build and push a Docker image to the Docker Hub? I've done these before where it's triggered when a new tag is created that marks a new version (e.g. v1.2.3), so this would also mean that new tags would need to be created as new versions of Snort go live.

Yes!

I think Umbrel recommended some other base image than the one in Iris' Dockerfile, that might need to be changed. Also it's serving the yarn dev version — that's fine, but yarn build version might be slightly faster.

nevets963 commented 1 year ago

Ok nice, I'll send one as soon as I can. I just checked the base image and that's fine - we'll accept that. We can tweak the Dockerfile to run smoother if needed. Ideally, for a production build, we should build and then use eg Caddy as a web server to serve the content.

macterra commented 1 year ago

FWIW my self-hosted version of Iris (running from source) was able to successfully connect to my private Nostr Relay running in Umbrel. I'm looking forward to seeing Iris in the Umbrel App Store!

macterra commented 1 year ago

Following the advice from Umbrel App Framework I tried building a multi-architecture docker image for Iris using the command

docker buildx build --platform linux/arm64,linux/amd64 ...

The arm64 part built OK but it ran into an issue on the yarn step for amd64:

#0 414.9 error An unexpected error occurred: "https://registry.yarnpkg.com/@zxing/library/-/library-0.19.2.tgz: ESOCKETTIMEDOUT".
#0 414.9 info If you think this is a bug, please open a bug report with the information provided in "/iris-messenger/yarn-error.log".
#0 414.9 info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
------
Dockerfile:7
--------------------
   5 |     ENV NODE_OPTIONS=--openssl-legacy-provider
   6 |     
   7 | >>> RUN yarn
   8 |     RUN yarn build
   9 |     RUN cat package.json | jq '.scripts.serve="sirv build --host 0.0.0.0 --port 8080 --cors --single"' > package.json.new && mv -vf package.json.new package.json
--------------------
ERROR: failed to solve: process "/dev/.buildkit_qemu_emulator /bin/sh -c yarn" did not complete successfully: exit code: 1

Any ideas?

mmalmi commented 1 year ago

I just pushed a commit that removes the unused QRScanner (@zxing/library). Does that help?

macterra commented 1 year ago

Yes, it got past that error. Next error:

#0 520.6 [4/4] Building fresh packages...
#0 537.9 error /iris-messenger/node_modules/utf-8-validate: Command failed.
#0 537.9 Exit code: 1
#0 537.9 Command: node-gyp-build
#0 537.9 Arguments:
#0 537.9 Directory: /iris-messenger/node_modules/utf-8-validate
#0 537.9 Output:
#0 537.9 gyp info it worked if it ends with ok
#0 537.9 gyp info using node-gyp@9.3.1
#0 537.9 gyp info using node@19.7.0 | linux | arm64
#0 537.9 gyp ERR! find Python
#0 537.9 gyp ERR! find Python Python is not set from command line or npm configuration
#0 537.9 gyp ERR! find Python Python is not set from environment variable PYTHON
#0 537.9 gyp ERR! find Python checking if "python3" can be used
#0 537.9 gyp ERR! find Python - "python3" is not in PATH or produced an error
#0 537.9 gyp ERR! find Python checking if "python" can be used
#0 537.9 gyp ERR! find Python - "python" is not in PATH or produced an error
#0 537.9 gyp ERR! find Python
#0 537.9 gyp ERR! find Python **********************************************************
#0 537.9 gyp ERR! find Python You need to install the latest version of Python.
#0 537.9 gyp ERR! find Python Node-gyp should be able to find and use Python. If not,
#0 537.9 gyp ERR! find Python you can try one of the following options:
#0 537.9 gyp ERR! find Python - Use the switch --python="/path/to/pythonexecutable"
#0 537.9 gyp ERR! find Python   (accepted by both node-gyp and npm)
#0 537.9 gyp ERR! find Python - Set the environment variable PYTHON
#0 537.9 gyp ERR! find Python - Set the npm configuration variable python:
#0 537.9 gyp ERR! find Python   npm config set python "/path/to/pythonexecutable"
#0 537.9 gyp ERR! find Python For more information consult the documentation at:
#0 537.9 gyp ERR! find Python https://github.com/nodejs/node-gyp#installation
#0 537.9 gyp ERR! find Python **********************************************************
#0 537.9 gyp ERR! find Python
#0 537.9 gyp ERR! configure error
#0 537.9 gyp ERR! stack Error: Could not find any Python installation to use

I'm not sure why this would only error in the arm64 build, but I'm adding python to the installs in the Dockerfile

macterra commented 1 year ago

I got the arm64 build working, my docker image macterra/iris contains both architectures:

image

Small PR incoming to update the Dockerfile.

nmfretz commented 1 year ago

Hey, I'm tapping @nevets963 out and can help with packaging/testing this on the Umbrel side of things. Playing around with Iris now and it is awesome. Great work.

mmalmi commented 1 year ago

Hey, I'm tapping @nevets963 out and can help with packaging/testing this on the Umbrel side of things. Playing around with Iris now and it is awesome. Great work.

Thanks! That would be wonderful!

nmfretz commented 1 year ago

Sweet. Okay, I'll play around with this soon and then provide some instructions for getting this to the Umbrel App Store!

mmalmi commented 1 year ago

Thank you! production branch is the nice one that is on iris.to. Master branch is a bit laggy rn.

nmfretz commented 1 year ago

I just built an image and tried it out on Umbrel and it's working well when using a key manager extension! I think it is essentially there, we just need to handle this:

Unfortunately, Iris might not work over http because it's using webcrypto. Browsers have these weird limitations. But we can see how it goes, and work around it, replacing webcrypto with js libs if needed.

Correct me if I'm wrong in my understanding here: I think the app works completely fine over http when using a key manager extension like alby because the extension is handling any crypto functions related to signing events, hash functions, etc (this is my experience when testing). If a user logs in with a private key then crypto-related operations are handled by a crypto library that isn't supported over http, so the app won't work correctly under this scenario.

One potentially easy way you could get around this is by adding logic to Iris to detect http and disable the ability to login via pasting a private key.

I have opened a PR https://github.com/irislib/iris-messenger/pull/353 against the production branch that updates the Dockerfile to use a multi-stage build to make the final image smaller and to make subsequent builds faster. Hopefully it works for you guys. There's an image here you can check that is roughly 40% the size of the old image at 215 MB https://hub.docker.com/repository/docker/nmfretz/iris-messenger/tags?page=1&ordering=last_updated.

nmfretz commented 1 year ago

Here's the steps to getting Iris on Umbrel. I can help with every stage of this.

1) build and push an amd64 & arm64 multi-arch Docker image to the Docker registry. This would need to include a version tag so that it looks something like: irislib/iris-messenger:v0.6.0.

services: app_proxy: environment: APP_HOST: iris_web_1 APP_PORT: 8080

web: image: irislib/iris-messenger:your-version-here>@sha256:<multi-arch-digest-here user: "1000:1000" restart: on-failure stop_grace_period: 1m


- The `umbrel-app.yml` could look like this with any changes to wording that you want.
```yml
manifestVersion: 1
id: iris-messenger
category: Social
name: Iris
version: "<your-version-here>"
tagline: The app for better social networks
description: >-
  <A description here>
developer: Iris
website: <your website here>
dependencies: []
repo: https://github.com/irislib/iris-messenger
support: <telegram or discord, wherever people go for support>
port: <port to access the app. can be any number not already taken by another app>
gallery:
  - 1.jpg
  - 2.jpg
  - 3.jpg
path: ""
defaultUsername: ""
defaultPassword: ""
submitter: Iris
submission: https://github.com/getumbrel/umbrel-apps/pull/<your PR #>

3) Create gallery images and icon. See here for example: https://apps.umbrel.com/app/nostr-relay.

mmalmi commented 1 year ago

Thank you! PR for the Github workflow would be wonderful. We can do the rest. Will zap if you share your npub 🙂

nmfretz commented 1 year ago

Alrighty, here's PR https://github.com/irislib/iris-messenger/pull/354 to production for the GitHub Actions workflow to build and push a Docker image on tag. Hope it works for you!