Hanzo

Hosting static files in a CDN

Deploy Hanzo IAM frontend static assets to a CDN using a storage provider.

Frontend assets (e.g. .js and .css) live in web/build/static/. Upload them to a CDN via a Hanzo IAM storage provider; a script in the repo automates this.

:::note Build the frontend first. See Server installation if needed. :::

Preparation

Create a storage provider in the Hanzo IAM UI (e.g. Aliyun OSS).

:::caution Set the Domain field to a URL ending with /.

storage_domian :::

Usage

The script is at deployment/deploy_test.go. Set the provider in GetProvider(); the ID format is <owner>/<name>.

func TestDeployStaticFiles(t *testing.T) {
    provider := object.GetProvider("admin/provider_storage_aliyun_oss")
    deployStaticFiles(provider)
}

Then run:

```bash
cd deployment
go test

On success you should see:

```bash
PASS
ok      github.com/iam/iam/deployment   2.951s

## How it works

The script:

1. Uploads files under `css/` and `js/` to the storage provider (your CDN).
2. Rewrites `.css` and `.js` URLs in `web/build/index.html` to point to the CDN.

Serve `index.html` from the Hanzo IAM backend as usual; the browser will load the static assets from the CDN using the URLs in `index.html`.

How is this guide?

Last updated on

On this page