Skip to content

Commit

Permalink
Merge pull request #36 from Trustroots/add-nostroots-server-repo
Browse files Browse the repository at this point in the history
Add nostroots server repo
  • Loading branch information
shuesken authored Sep 27, 2024
2 parents 27b4923 + 5cef0b0 commit 8ccaafd
Show file tree
Hide file tree
Showing 16 changed files with 1,130 additions and 0 deletions.
82 changes: 82 additions & 0 deletions .github/build-and-push-server-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
name: Build (and push) server image

# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

on:
schedule:
- cron: "41 16 * * *"
push:
branches: ["main"]
# Publish semver tags as releases.
tags: ["v*.*.*"]
pull_request:
branches: ["main"]

env:
# Use docker.io for Docker Hub if empty
REGISTRY: ghcr.io
# github.repository as <account>/<repo>
IMAGE_NAME: ${{ github.repository }}

jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
# This is used to complete the identity challenge
# with sigstore/fulcio when running outside of PRs.
id-token: write

steps:
- name: Checkout repository
uses: actions/checkout@v4

# Install the cosign tool except on PR
# https://github.com/sigstore/cosign-installer
- name: Install cosign
if: github.event_name != 'pull_request'
uses: sigstore/cosign-installer@59acb6260d9c0ba8f4a2f9d9b48431a222b68e20 #v3.5.0
with:
cosign-release: "v2.2.4"

# Set up BuildKit Docker container builder to be able to build
# multi-platform images and export cache
# https://github.com/docker/setup-buildx-action
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3.0.0

# Login against a Docker registry except on PR
# https://github.com/docker/login-action
- name: Log into registry ${{ env.REGISTRY }}
if: github.event_name != 'pull_request'
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

# Extract metadata (tags, labels) for Docker
# https://github.com/docker/metadata-action
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@96383f45573cb7f253c731d3b3ab81c87ef81934 # v5.0.0
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

# Build and push Docker image with Buildx (don't push on PR)
# https://github.com/docker/build-push-action
- name: Build and push Docker image
id: build-and-push
uses: docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09 # v5.0.0
with:
context: nrserver
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
1 change: 1 addition & 0 deletions nrserver/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.env
3 changes: 3 additions & 0 deletions nrserver/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"deno.enable": true
}
16 changes: 16 additions & 0 deletions nrserver/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
FROM denoland/deno:1.45.5

WORKDIR /app

# Prefer not to run as root.
USER deno

# Cache the dependencies as a layer (the following two steps are re-run only when deps.ts is modified).
# Ideally cache deps.ts will download and compile _all_ external files used in main.ts.
COPY deps.ts .
RUN deno cache deps.ts

# These steps will be re-run upon each file change in your working directory:
COPY . .

CMD ["task", "run"]
1 change: 1 addition & 0 deletions nrserver/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# nostroots-server
33 changes: 33 additions & 0 deletions nrserver/common/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
export const PRIVATE_KEY_STORAGE_KEY = "__nostrPrivateKey" as const;
export const RELAYS_STORAGE_KEY = "__nostrRelays" as const;
export const PLUS_CODE_TAG_KEY = "l" as const;
export const LABEL_NAMESPACE_TAG = "L";
export const OPEN_LOCATION_CODE_NAMESPACE_TAG = "open-location-code";
export const MAP_NOTE_KIND = 397;
export const MAP_NOTE_REPOST_KIND = 30398;
export const DEFAULT_RELAYS = [
"wss://relay.damus.io",
"wss://relay.primal.net",
"wss://nostr.manasiwibi.com",
"wss://nos.lol",
];
export const DEV_RELAYS = DEFAULT_RELAYS;
export const PANEL_CONTAINER_ID = "panelID";
export const BADGE_CONTAINER_ID = "badge";
export const CONTENT_MINIMUM_LENGTH = 3;
export const CONTENT_MAXIMUM_LENGTH = 300;
export const EARLIEST_FILTER_SINCE = 1716736622;

export const MINIMUM_TRUSTROOTS_USERNAME_LENGTH = 3;

export const WAIT_FOR_KIND_ZERO_TIMEOUT_SECONDS = 5;

export const DEV_PUBKEY =
"80789235a71a388074abfa5c482e270456d2357425266270f82071cf2b1de74a" as const;

export const HITCHMAPS_AUTHOR_PUBLIC_KEY =
"53055ee011e96a00a705b38253b9cbc6614ccbd37df4dad42ec69bbe608c4209" as const;

export const DELAY_AFTER_PROCESSING_EVENT_MS = 10;

export const SUBSCRIPTIONS_MAX_AGE_IN_MINUTES = 60;
6 changes: 6 additions & 0 deletions nrserver/deno.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"tasks": {
"run": "deno run --allow-net --allow-env main.ts",
"cache": "deno cache --lock deno.lock deps.ts"
}
}
Loading

0 comments on commit 8ccaafd

Please sign in to comment.