Skip to content

Commit 7c62f0b

Browse files
committed
Updating our docs
1 parent 8bd97ae commit 7c62f0b

File tree

7 files changed

+442
-355
lines changed

7 files changed

+442
-355
lines changed

src/content/docs/getting-started/customize.mdx

Lines changed: 0 additions & 258 deletions
This file was deleted.
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
---
2+
title: Deploy your starter setup
3+
description: Deploy your local setup to showcase its benefits.
4+
sidebar:
5+
order: 3
6+
---
7+
8+
import { SlCloudDownload, SlPencil, SlRocket, SlCloudUpload } from "react-icons/sl";
9+
import { FcOk } from "react-icons/fc";
10+
11+
:::caution
12+
**This is a POC deployment guide!**
13+
14+
We are using public tooling in this guide to get something out on the internet so you can showcase your 1fe instance. If you're ready to set up a production environment with proper CDN infrastructure, CI/CD pipelines, and robust hosting, visit our [productionization guide](../../platform-guides/productionize).
15+
:::
16+
17+
Now that we have setup our local 1FE app and widget starter kit, it's time to deploy our setup to showcase its benefits. This will allow us to share our work with others and demonstrate the power of 1FE. We will do the following in this guide.
18+
<div className="prose">
19+
1. **Deploy our assets to a public CDN (JSDelivr).**
20+
2. **Deploy our 1FE app to a hosting service.**
21+
</div>
22+
23+
## <SlCloudUpload style={{ display: 'inline', marginRight: '0.5rem', verticalAlign: 'middle' }} /> Deploy our assets to a CDN
24+
25+
We have already learnt how to host assets locally in the previous guide. Let's deploy to them a CDN so our hosted 1fe instance can access them.
26+
27+
### Setup the github repository
28+
29+
[JSDelivr](https://www.jsdelivr.com/) works off of GitHub repositories and serves files based on Git tags. So the first step would be to create a repository for our forked cdn assets on github.com and to push our changes to that repository. We already did that as part of the guide to get out setup locally. If you haven't done that, do that now so our mock-cdn-assets are available on github.com for JSDelivr to pick up from.
30+
31+
#### Add the 1fe instance bundle to the CDN
32+
When working on getting our setup to work locally, we already uploaded bundles for widget-starter-kit/bathtub to the CDN. We need to upload the shell bundle.
33+
34+
Create a folder in forked mock-cdn-assets repository like so: `integration/shell/<pick-a-number>/js/`. Copy the bundle over your 1fe app. Bundle can be found at this location after build: `dist/public/js/bundle.js`.
35+
36+
### Create and Push Tags for JSDelivr
37+
38+
Let's now create a git tag for our assets.
39+
40+
<div className="prose">
41+
1. **Create and push a Git tag - this is crucial for JSDelivr caching:**
42+
43+
```bash
44+
cd mock-cdn-assets
45+
git add .
46+
git commit -m "Add widget assets for deployment"
47+
git tag v1.0.2
48+
git push origin main
49+
git push origin v1.0.2
50+
```
51+
52+
2. **Your assets are now publicly accessible via JSDelivr URLs:**
53+
54+
```
55+
# Widget Starter Kit Bundle
56+
https://cdn.jsdelivr.net/gh/<your-github-username>/mock-cdn-assets@v1.0.2/integration/widgets/@1fe/widget-starter-kit/<version>/js/1fe-bundle.js
57+
58+
# Bathtub Widget Bundle
59+
https://cdn.jsdelivr.net/gh/<your-github-username>/<repo-name>@v1.0.2/integration/widgets/@1fe/bathtub/<version>/js/1fe-bundle.js
60+
61+
# Live Configurations
62+
https://cdn.jsdelivr.net/gh/<your-github-username>/<repo-name>@v1.0.2/integration/configs/live.json
63+
```
64+
</div>
65+
:::tip
66+
**JSDelivr not reflecting your changes?** Try purging the cache at https://www.jsdelivr.com/tools/purge. Changes typically appear within a few minutes.
67+
:::
68+
69+
## Deploy our 1FE app to a hosting service
70+
71+
Now that we have our CDN setup, let's deploy our 1fe instance to a hosted service such that it's pointing to our CDN.
72+
73+
### Configure the 1fe instance
74+
<div className="prose">
75+
1. Point your 1FE instance to the new CDN assets for live configurations
76+
77+
```tsx title="src/config/ecosystem-configs.ts" {4,7,10}
78+
// ...
79+
export const configManagement: OneFEConfigManagement = {
80+
widgetVersions: {
81+
url: `https://cdn.jsdelivr.net/gh/<your-github-username>/<repo-name>@<tag>/integration/configs/widget-versions.json`,
82+
},
83+
libraryVersions: {
84+
url: `https://cdn.jsdelivr.net/gh/<your-github-username>/<repo-name>@<tag>/integration/configs/lib-versions.json`,
85+
},
86+
dynamicConfigs: {
87+
url: `https://cdn.jsdelivr.net/gh/<your-github-username>/<repo-name>@<tag>/integration/configs/live.json`,
88+
},
89+
refreshMs: 30 * 1000,
90+
};
91+
```
92+
93+
2. Point your 1FE instance to the new CDN assets for critical libraries.
94+
95+
```tsx title="src/config/ecosystem-configs.ts" {3,5,9,10}
96+
// ...
97+
const shellBundleUrl =
98+
isLocal || SERVER_BUILD_NUMBER === 'local' ? `http://localhost:3001/js/bundle.js` : `https://cdn.jsdelivr.net/gh/<your-github-username>/<repo-name>@<tag>/${ENVIRONMENT}/shell/${SERVER_BUILD_NUMBER}/js/bundle.js`;
99+
100+
const importMapOverrideUrl = isProduction ? `https://cdn.jsdelivr.net/gh/<your-github-username>/<repo-name>@<tag>/${ENVIRONMENT}/libs/@1fe/import-map-overrides/3.1.1/dist/import-map-overrides-api.js` : `https://cdn.jsdelivr.net/gh/<your-github-username>/<repo-name>@<tag>/${ENVIRONMENT}/libs/@1fe/import-map-overrides/3.1.1/dist/import-map-overrides.js`;
101+
102+
export const criticalLibUrls = {
103+
importMapOverride: importMapOverrideUrl,
104+
systemJS: `https://cdn.jsdelivr.net/gh/<your-github-username>/<repo-name>@<tag>/${ENVIRONMENT}/libs/systemjs/6.14.0/dist/system.min.js`,
105+
systemJSAmd: `https://cdn.jsdelivr.net/gh/<your-github-username>/<repo-name>@<tag>/${ENVIRONMENT}/libs/systemjs/6.14.0/dist/extras/amd.min.js`,
106+
shellBundleUrl,
107+
};
108+
```
109+
110+
3. Update the CSP policy.
111+
Update the CSP policies as defined in `src/csp-configs.ts` to allow jsdelivr domains(`https://cdn.jsdelivr.net`)
112+
</div>
113+
114+
### Deploy the 1fe instance

0 commit comments

Comments
 (0)