Deploy to Deno Deploy

June 23, 2024 ยท View on GitHub

Prerequisites

  • nodejs
  • npm
  • deno
  • deployctl
  • Deno deploy KV access!

Deploy

Hint: If you are really lazy we provide precompiled deploy packages in the branch deno-deploy-data

  1. Build the app with and frontend, we provide a makefile for this. Just run make deploy and it will automatically create a deployable bundle. If you don't have make installed, you can also build the deploy package yourself see build manual.
  2. Create a new empty project on deno.com/deploy and copy the project id.
  3. Get your deploy token inside the deno webui and run this command inside your deploy folder: deployctl deploy --token <token> --project=<project name> ./deploy/deploy.ts"

Build manual

  1. Install frontend dependencies, open app/frontend and run npm install
  2. Build frontend, run npm run build
  3. Create a deploy folder mkdir deploy
  4. Copy the backend into a new folder cp -r ./app/backend/* deploy
  5. Copy the frontend build into the backend folder cp -r ./app/frontend/build ./deploy/static-site

Set the following environment variables in the webui

NameDescriptionDefault
PORTPort to listen8787
VAPID_KEYVapid key for the app, see generateundefined
SUBAdmin email in format "mailto:aa@bbb.ccc"undefined
CORSEnable cors, if your frontend is served on a different domainfalse
SENDKEYKey to send notificationsundefined
LOGINKEYKey to login to the uiundefined

Generate Vapid key

deno run --allow-net --allow-read --allow-write --unstable ./deploy/main.ts generate

or if you do not want to checkout this repository you can use the following command:

deno run -A --unstable --import-map https://raw.githubusercontent.com/K0IN/Notify/deno-port/app/backend/deno.json https://raw.githubusercontent.com/K0IN/Notify/deno-port/app/backend/main.ts generate