kuda

command module
v1.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 19, 2020 License: MIT Imports: 13 Imported by: 0

README

Kuda Web Server

Open Issues Open Pull Request Unit Test Result

Fast and concurrent in-memory web server. It compress static files with gzip, put them into RAM, and serve them as a normal web server. So Dev/Ops don't have to worry about storage speed, just focus on networking matter.

The best use case is serving Single Page Application (SPA) like React, Vue, and Angular.

Special thanks to fasthttp and contributors for making kuda possible 🤘

Download

See release timeline

How to use

USAGE:
    kuda [arguments] <public_root_directory>

ARGUMENTS:
    --port=...     : TCP Port to be listened (default: "8080")
    --origins=...  : Which domains to be allowed by CORS policy (default: "")
    --port-tls=... : Use this to listen for HTTPS requests (default: "")
    --domain=...   : Required to redirect from http to https (default: "localhost")
    --cert=...     : SSL certificate file, required if "--port-tls" specified
    --key=...      : SSL secret key file, required if "--port-tls" specified

Usage Example

Let's say you're now in a directory with kuda executable and my-app as your react app project.

cd my-app
npm run build
cd ..

./kuda my-app/build --port=8000 --origins=localhost:9000

After executed, it will put everything inside my-app/build into RAM and serve at port 8000. Beside of that, we're assuming the API backend runs on port 9000. Thus, we have to add it as allowed origins with --origins=... flag to prevent CORS Origin problem.

How about SSL?

Now we have same directory as above with cert.pem and secret.key inside of it.

./kuda my-app/build --port=8000 --origins=localhost:9000 --port-tls=8090 --domain=localhost --cert=cert.pem --key=secret.key

The localhost:8000 is considered using HTTP protocol. So every connection coming to that port will be redirected to https://localhost:8090.

Serving Production App

In production environment, assuming you have www.my-domain.com web URL and api.my-domain.com for API URL:

sudo ./kuda my-app/build --port=80 --origins=api.my-domain.com --port-tls=443 --domain=www.my-domain.com --cert=/etc/ssl/certs/my-domain.pem --key=/etc/ssl/private/my-domain.key

With Docker

Mostly, we deploy web app with docker and kubernetes (for orchestration). In order to do that, use this commands.

docker pull kuda:latest
docker run --name kuda-demo --volume my-compiled-webapp:/srv -p 8080:8080 --rm kuda:latest

Where my-compiled-webapp is your directory with compiled app inside. NEVER EVER point project root directory as public directory, otherwise your machine will run out of memory very shortly!

With Docker Compose

I would recommend you to use Docker Compose instead of plain Docker for sake of maintainability. This is an example of docker-compose.yml:

version: "3"

services:
  kuda:
    image: kuda:latest
    volumes:
      - ./my-compiled-webapp:/srv
    environment:
      KUDA_PUBLIC_DIR: "/srv"
      KUDA_DOMAIN: "localhost"
      KUDA_PORT: "8080"
      KUDA_ORIGINS: ""
      KUDA_PORT_TLS: ""
      KUDA_CERT: ""
      KUDA_KEY: ""
    ports:
      - 8080:8080

Benchmark

I have no enough resource to benchmark Kuda Web Server myself. If you did benchmark and comparation with kuda, please let us know via issue section.

Contribution

Anyone can contribute on this project. We welcome you to Pull Request or Open an Issue. To working on source code, you will require:

  • Linux or Mac preferred (Use WSL if you are Windows 10 user or Cygwin for older Windows)
  • Golang
  • Makefile
  • NPM (for demo)
  • Docker + Docker Compose (optional)
Makefile Commands

There are things you can do with makefile on this project:

  • make -- Compile for all platforms and store them inside "build" directory
  • make test -- Run this everytime you want to pull request
  • make clean -- Removes all compiled files to reduce storage usage
  • make demo -- Run demonstration, go to http://localhost:8080 on browser while running this command
Security Report

To keep other users' security, please send email to athaariqa@gmail.com instead. Do not open issue for security report.

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL