diff --git a/.github/workflows/buildService.yml b/.github/workflows/buildService.yml index 131f164..c9b270b 100644 --- a/.github/workflows/buildService.yml +++ b/.github/workflows/buildService.yml @@ -3,11 +3,11 @@ name: Build Service on: workflow_dispatch: pull_request: - paths-ignore: ['*.md'] - branches: ['main', 'master'] + paths-ignore: ["*.md"] + branches: ["main", "master"] push: - paths-ignore: ['*.md'] - branches: ['main', 'master'] + paths-ignore: ["*.md"] + branches: ["main", "master"] jobs: BuildPackage: diff --git a/.github/workflows/releaseService.yml b/.github/workflows/releaseService.yml index 434d517..f8b2358 100644 --- a/.github/workflows/releaseService.yml +++ b/.github/workflows/releaseService.yml @@ -3,7 +3,7 @@ name: Release Service on: push: tags: - - 'v*.*' + - "v*.*" jobs: ReleasePackage: diff --git a/Dockerfile b/Dockerfile index 32300ee..f61aae3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,14 +1,26 @@ -# syntax=docker/dockerfile:1 FROM node:20 as builder WORKDIR /app -COPY ./nostrudel /app/ +# Copy package files and install dependencies +COPY ./nostrudel/package*.json ./ +COPY ./nostrudel/yarn.lock ./ +RUN yarn install --frozen-lockfile --production=false + +# Copy application files +COPY ./nostrudel . + +# Build ENV VITE_COMMIT_HASH="" ENV VITE_APP_VERSION="Start9-OS" -RUN yarn install && yarn build +RUN yarn build FROM nginx:stable-alpine-slim + +RUN apk update && \ + apk add --no-cache yq && \ + rm -rf /var/cache/apk/* + EXPOSE 8080 COPY --from=builder /app/dist /usr/share/nginx/html diff --git a/docker_entrypoint.sh b/docker_entrypoint.sh index 22f175e..1070ee1 100755 --- a/docker_entrypoint.sh +++ b/docker_entrypoint.sh @@ -1,14 +1,34 @@ #!/bin/sh set -e -echo +cat /root/start9/config.yaml + +CACHE_RELAY_ENABLED=$(yq '.enable-cache-relay' /root/start9/config.yaml) +#CACHE_RELAY=$(yq '.cache-relay' /root/start9/config.yaml) +CACHE_RELAY=nostr.embassy:8080 + +PROXY_PASS_BLOCK="" +if [ -n "$CACHE_RELAY" ] && [ "$CACHE_RELAY_ENABLED" = "true" ]; then + echo "Cache relay set to $CACHE_RELAY" + sed -i 's/CACHE_RELAY_ENABLED = false/CACHE_RELAY_ENABLED = true/g' /usr/share/nginx/html/index.html + PROXY_PASS_BLOCK="$PROXY_PASS_BLOCK + location /local-relay { + proxy_pass http://$CACHE_RELAY/; + proxy_http_version 1.1; + proxy_set_header Upgrade \$http_upgrade; + proxy_set_header Connection "upgrade"; + } + " +else + echo "No cache relay set" +fi + echo "Starting noStrudel ..." -echo CONF_FILE="/etc/nginx/conf.d/default.conf" -NGINX_CONF='server { +NGINX_CONF="server { listen 80; - return 301 https://$host$request_uri; + return 301 https://\$host\$request_uri; } server { @@ -18,6 +38,9 @@ server { ssl_certificate_key /mnt/cert/main.key.pem; server_name localhost; + merge_slashes off; + + $PROXY_PASS_BLOCK root /usr/share/nginx/html; index index.html index.htm; @@ -53,15 +76,14 @@ server { text/xml; location / { - try_files $uri $uri/ /index.html; + try_files \$uri \$uri/ /index.html; } error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/share/nginx/html; } -} -' +}" echo "$NGINX_CONF" > $CONF_FILE _term() { diff --git a/instructions.md b/instructions.md index c48ea51..fb08afc 100644 --- a/instructions.md +++ b/instructions.md @@ -1,6 +1,9 @@ ## Using noStrudel -*Connecting to your own private relay is not supported yet* - - Click `launch UI` to access your personal noStrudel client - Create a new account or access an existing account by using a nip-07 browser extension or pasting in your private key. If creating a new account, be sure to securely back up the private key, preferably using Vaultwarden on your Start9 server + +## Using your local nostr relay (optional) + +If you have Nostr RS Relay installed you can enable the "Use local relay for caching" option to use it as a cache. +It must be set to "Public" mode. otherwise it will only cache your events diff --git a/manifest.yaml b/manifest.yaml index ce96b6f..e2eee4b 100644 --- a/manifest.yaml +++ b/manifest.yaml @@ -1,20 +1,20 @@ -# Example written in yaml (toml and json are also acceptable) +# Docs: https://docs.start9.com/0.3.5.x/developer-docs/specification/dependencies#advanced-configuration # The package identifier used by the OS. This must be unique amongst all other known packages id: nostrudel - # A human readable service title +# A human readable service title title: "noStrudel" # Service version - accepts up to four digits, where the last confirms to revisions necessary for StartOS - see documentation: https://github.com/Start9Labs/emver-rs. This value will change with each release of the service. -version: 0.38.1.0 +version: 0.38.2.1 # Release notes for the update - can be a string, paragraph or URL release-notes: -> - - Support for nsecbunker and the new OAuth flow - - Added simple "Launchpad" view (most stuff will be added in the future) - - Restore scroll position when returning to the timeline - - Show unavailable events in threads - - Organized all the "other stuff" in a tools page - - Added support to cache events in local relays instead of the browsers cache - - And a ton more, read them all in the https://github.com/hzrd149/nostrudel/blob/master/CHANGELOG.md#0380 changelog + - Support for nsecbunker and the new OAuth flow + - Added simple "Launchpad" view (most stuff will be added in the future) + - Restore scroll position when returning to the timeline + - Show unavailable events in threads + - Organized all the "other stuff" in a tools page + - Added support to cache events in local relays instead of the browsers cache + - And a ton more, read them all in the https://github.com/hzrd149/nostrudel/blob/master/CHANGELOG.md#0380 changelog # The type of license for the project. Include the LICENSE in the root of the project directory. A license is required for a Start9 package. license: mit @@ -80,7 +80,11 @@ health-checks: name: Web UI success-message: noStrudel is ready type: script -config: ~ +config: + get: + type: script + set: + type: script properties: ~ # type: script # This denotes any data, asset, or pointer volumes that should be connected when the "docker run" command is invoked @@ -100,7 +104,7 @@ interfaces: # A descriptive description of what the interface does description: A user interface that is expected to host noStrudel web app. tor-config: - # Port mappings are from the external port to the internal container port + # Port mappings are from the external port to the internal container port port-mapping: 80: "80" 443: "3443" @@ -115,7 +119,14 @@ interfaces: protocols: - tcp - http -dependencies: {} +dependencies: + nostr: + version: ">0.8.0" + critical: true + requirement: + type: "opt-in" + how: Can use the browser cache or local relay + description: Optionally used to cache events # Specifies how backups should be run for this service. The default StartOS provided option is to use the duplicity backup library on a system image (compat) backup: create: diff --git a/scripts/deps.ts b/scripts/deps.ts index 6519c00..5b191d3 100644 --- a/scripts/deps.ts +++ b/scripts/deps.ts @@ -1,2 +1,2 @@ export * from "https://deno.land/x/embassyd_sdk@v0.3.3.0.5/mod.ts"; -export * from "https://deno.land/x/embassyd_sdk@v0.3.3.0.5/util.ts"; \ No newline at end of file +export * from "https://deno.land/x/embassyd_sdk@v0.3.3.0.5/util.ts"; diff --git a/scripts/procedures/getConfig.ts b/scripts/procedures/getConfig.ts index 2948d64..06f5f2e 100644 --- a/scripts/procedures/getConfig.ts +++ b/scripts/procedures/getConfig.ts @@ -2,4 +2,20 @@ import { compat, types as T } from "../deps.ts"; -export const getConfig: T.ExpectedExports.getConfig = compat.getConfig({}); +export const getConfig: T.ExpectedExports.getConfig = compat.getConfig({ + "enable-cache-relay": { + name: "Use local relay for caching", + description: "Enables", + type: "boolean", + default: false, + }, + "cache-relay": { + name: "Cache Relay", + description: "A local relay to use for caching events", + type: "pointer", + subtype: "package", + "package-id": "nostr", + target: "lan-address", + interface: "websocket", + }, +}); diff --git a/scripts/procedures/healthChecks.ts b/scripts/procedures/healthChecks.ts index 02f729c..559120b 100644 --- a/scripts/procedures/healthChecks.ts +++ b/scripts/procedures/healthChecks.ts @@ -1,5 +1,5 @@ import { types as T, healthUtil } from "../deps.ts"; export const health: T.ExpectedExports.health = { - "web-ui": healthUtil.checkWebUrl("http://nostrudel.embassy:8080/index.html") -} + "web-ui": healthUtil.checkWebUrl("http://nostrudel.embassy:8080/index.html"), +}; diff --git a/scripts/procedures/main.ts b/scripts/procedures/main.ts index a426122..8b4e527 100644 --- a/scripts/procedures/main.ts +++ b/scripts/procedures/main.ts @@ -4,4 +4,4 @@ export const main = async (effects: T.Effects) => { // args defaulted to [] - not necessary to include if empty await effects.runDaemon({ command: "docker_entrypoint.sh", args: [] }).wait(); return util.ok; -} \ No newline at end of file +}; diff --git a/scripts/procedures/migrations.ts b/scripts/procedures/migrations.ts index 58ce914..6dd49bc 100644 --- a/scripts/procedures/migrations.ts +++ b/scripts/procedures/migrations.ts @@ -1,4 +1,4 @@ import { compat, types as T } from "../deps.ts"; -export const migration: T.ExpectedExports.migration = compat.migrations - .fromMapping({}, "0.38.1.0" ); +export const migration: T.ExpectedExports.migration = + compat.migrations.fromMapping({}, "0.38.2.1"); diff --git a/scripts/procedures/setConfig.ts b/scripts/procedures/setConfig.ts index 43d308f..ffd9d44 100644 --- a/scripts/procedures/setConfig.ts +++ b/scripts/procedures/setConfig.ts @@ -1,5 +1,3 @@ -// This is where any configuration rules related to the configuration would go. These ensure that the user can only create a valid config. - -import { compat, } from "../deps.ts"; +import { compat } from "../deps.ts"; export const setConfig = compat.setConfig;