Multicloud app that includes DePIN (Demo)

3 months ago 1

maintained by: @dkxero

Screenshot

An OpenCode and Claude AI vibe coded image gallery demo that can be deployed to Akash Network via dKloud's KloudDeploy platform. This application reads and writes images on STORJ via S3 compatible APIs. All functions are protected by Supabase Auth. The application is designed to be further optimized and protected by Cloudflare's CDN and DDOS protection. While for demo purposes, this code base does not utilize an actual database, in a production scenario, it should be and users can either choose to use Supabase or one of the hyperscaler alternatives.

This demo is to show how one can effortlessly leverage a HYBRID CLOUD INFRASTRUCTURE THAT INCLUDES DePIN to get the best performance/features while saving on cost compared to using a single hyperscaler exclusively.

Feel free to use this repo to test things out yourself.

Architecture

PRODUCTION READY SSL/HTTPS SETUP

  • Cloudflare DNS validation: More reliable than HTTP validation
  • No public HTTP access required: Works even if ports aren't accessible yet
  • Automatic Let's Encrypt certificate generation
  • Automatic certificate renewal
  • Real visitor IP detection through Cloudflare
  • Nginx reverse proxy with security headers
  • HTTP to HTTPS redirects
  • Rate limiting for API endpoints
  1. Clone this repo and cd into demo-storj
  2. cp .env-example .env
  3. Signup for an account at Cloudflare and transfer your domain's DNS to it
  4. Signup for an account at Storj and then create a project and bucket
  5. Signup for an account on Supabase and then create a new org and project
  6. In your Supabase project, go to Authentication > URL Configuration and add these redirect URLs:
    • https://yourdomain.com/auth/callback - For production
    • https://localhost/auth/callback - For testing before pushing image
    • http://localhost:3001/auth/callback - For Dev
  7. cp .env-example .env and fill in the .env file.
# Storj Configuration STORJ_ACCESS_KEY=your_storj_access_key_here STORJ_SECRET_KEY=your_storj_secret_key_here STORJ_BUCKET_NAME=your_bucket_name_here STORJ_ENDPOINT=https://gateway.storjshare.io # Supabase Configuration SUPABASE_URL=your_supabase_project_url_here SUPABASE_ANON_KEY=your_supabase_anon_key_here # Frontend Environment Variables (for React) REACT_APP_SUPABASE_URL=your_supabase_project_url_here REACT_APP_SUPABASE_ANON_KEY=your_supabase_anon_key_here REACT_APP_URL=https://localhost # SSL Configuration # (for production with SSL - Not required if not terminating TLS at container) ENABLE_SSL=true DOMAIN_NAME=yourdomain.com [email protected] # If set to false, the container will be built with self-signed cert and key LETSENCRYPT=false # Cloudflare Configuration (for DNS validation) CLOUDFLARE_API_TOKEN=your_cloudflare_api_token_here # Server Configuration PORT=3001 NODE_ENV=production

* For building and testing, leave ENABLE_SSL and LETSENCRYPT to use the defaults. You will get a chance to specify this in the real deployment later

  1. ./start.sh (Alternatively, if you want to skip the testing, you can just run ./build.sh and jump to step 10)

  2. Go to https://localhost to make sure the application is working properly (Self-signed Cert - Browser will complain)

  3. docker tag demo-storj_storj-gallery:latest <registry url of choice between GitLab, Github, and DockerHub + image name:version>

    • registry url version of the image example: https://registry.gitlab.com/dkxero/demo-storj/app:v0.01
  4. Push the container image built to registry: docker push <registry version of the image>

  5. Create LaunchPack on KloudDeploy (currently only available to dKloud Insiders). Be sure you put in all the variables in your .env into the environment variables in the LaunchPack and then adjust them for your production use case.

    * There are two types of Akash deployments you can define in your LaunchPack.

    ** For more information on creating a LaunchPack on KloudDeploy, check out our documentation

  6. Create Deployment on KloudDeploy (currently only available to dKloud Insiders)

    * For more information on creating a deployment on KloudDeploy, check out our documentation

    ** Alternatively, use github actions to auto deploy the container via KloudDeploy in a real life scenario using kdctl.

  7. Grab the IP from KloudDeploy and create an A record in Cloudflare DNS.

You are all set! You should now see this app running at https://yourdomain.com

To clean up your environment before you do a fresh build:

This script stops and removes the container and then removes the image built.

THIS IS SOFTWARE THAT HAS NOT BEEN PROPERLY TESTED FOR PRODUCTION USE. IT IS ONLY MEANT TO BE A DEMO.

This repo is sponsored by dKloud. dKloud and its community of volunteers in no way make any guarantees. Please use at your own risk!

To Learn more, please visit:

https://dkloud.io

Read Entire Article