Skip to content

Commit 8356015

Browse files
Merge pull request #17 from docusign/sushruth/deploy-1fe-docs
feat: 1fe NodeJS app deploy docs
2 parents 29aa04e + fa0b198 commit 8356015

File tree

2 files changed

+114
-49
lines changed

2 files changed

+114
-49
lines changed

src/components/animated-text.astro

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import AnimatedTextComponent from './AnimatedText.tsx';
44
---
55
<div>
6-
<span class="text-roller">
6+
<span class="text-roller" role="presentation">
77
[ ONE way to <AnimatedTextComponent client:load="react" /> ]
88
</span>
99
</div>
@@ -21,4 +21,4 @@ import AnimatedTextComponent from './AnimatedText.tsx';
2121
padding: 4rem 0;
2222
}
2323
}
24-
</style>
24+
</style>

src/content/docs/getting-started/deploy-poc.mdx

Lines changed: 112 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -5,74 +5,53 @@ sidebar:
55
order: 3
66
---
77

8-
import { SlCloudDownload, SlPencil, SlRocket, SlCloudUpload } from "react-icons/sl";
8+
import {
9+
SlCloudDownload,
10+
SlPencil,
11+
SlRocket,
12+
SlCloudUpload,
13+
} from "react-icons/sl";
914
import { FcOk } from "react-icons/fc";
15+
import { Card } from "@astrojs/starlight/components";
1016

1117
:::caution
12-
**This is a POC deployment guide!**
18+
**This is a POC deployment guide!**
1319

1420
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).
1521
:::
1622

1723
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
2424

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
25+
<div className="prose">
2826

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.
27+
1. **Deploy our assets to a public CDN (JSDelivr).**
3028

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.
29+
2. **Deploy our 1FE app to a hosting service.**
3330

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`.
31+
</div>
3532

36-
### Create and Push Tags for JSDelivr
33+
### Setup the required github repositories
3734

38-
Let's now create a git tag for our assets.
35+
You need two github repositories:
3936

4037
<div className="prose">
41-
1. **Create and push a Git tag - this is crucial for JSDelivr caching:**
4238

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-
```
39+
1. One for the `mock-cdn-assets` that will hold our assets - [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.
5140

52-
2. **Your assets are now publicly accessible via JSDelivr URLs:**
41+
2. One for your 1FE instance that will be used to deploy your 1FE app.
5342

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
43+
</div>
5744

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
45+
## <SlCloudUpload style={{ display: 'inline', marginRight: '0.5rem', verticalAlign: 'middle' }} /> Deploy our assets to a CDN
6046

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-
:::
47+
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. For this process, we will need to
6848

69-
## Deploy our 1FE app to a hosting service
49+
### Configure the 1fe instance first
7050

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.
51+
For this section, lets assume that you are going to use a git tag for your CDN assets like `v1.0.2`. You can pick any tag you like, but make sure to use the same tag in the next steps. We will use `<tag>` to refer to this tag in the rest of this guide. Based on this information (and with some more steps that you will take later), you need to make the following changes to your 1FE instance files.
7252

73-
### Configure the 1fe instance
7453
<div className="prose">
75-
1. Point your 1FE instance to the new CDN assets for live configurations
54+
1. Point your 1FE instance to the new CDN assets for live configurations. These files will be checked in in the next step but we prepare the 1fe instance for it now.
7655

7756
```tsx title="src/config/ecosystem-configs.ts" {4,7,10}
7857
// ...
@@ -95,9 +74,13 @@ export const configManagement: OneFEConfigManagement = {
9574
```tsx title="src/config/ecosystem-configs.ts" {3,5,9,10}
9675
// ...
9776
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`;
77+
isLocal || SERVER_BUILD_NUMBER === "local"
78+
? `http://localhost:3001/js/bundle.js`
79+
: `https://cdn.jsdelivr.net/gh/<your-github-username>/<repo-name>@<tag>/${ENVIRONMENT}/shell/${SERVER_BUILD_NUMBER}/js/bundle.js`;
9980

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`;
81+
const importMapOverrideUrl = isProduction
82+
? `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`
83+
: `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`;
10184

10285
export const criticalLibUrls = {
10386
importMapOverride: importMapOverrideUrl,
@@ -108,7 +91,89 @@ export const criticalLibUrls = {
10891
```
10992

11093
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`)
94+
Update the CSP policies as defined in `src/csp-configs.ts` to allow jsdelivr domains(`https://cdn.jsdelivr.net`)
95+
96+
4. Now check this into your 1FE instance repository. That can help with deploying your 1fe instance later.
97+
11298
</div>
11399

114-
### Deploy the 1fe instance
100+
### Add the 1fe instance bundle to the CDN
101+
102+
When working on getting our setup to work locally, we already uploaded bundles for `widget-starter-kit` and `playground` to the CDN. We need to upload the shell bundle.
103+
104+
You need to pick a random number to act as a build number for your 1fe instance. This will be used to create a unique folder in the CDN for your 1fe instance. Lets call it `<build-number>`.
105+
106+
<div className="prose">
107+
108+
1. Build the 1fe instance again using `yarn build`
109+
110+
2. Copy the bundle over to your `mock-cdn-assets` repository like so:
111+
112+
</div>
113+
114+
```bash
115+
mkdir -p mock-cdn-assets/integration/shell/<build-number>/
116+
cp -r <test-app-name>/dist/public/ mock-cdn-assets/integration/shell/<build-number>/
117+
```
118+
119+
### Create and Push Tags for JSDelivr
120+
121+
Let's now add all the changes you have made to your CDN assets repository and create a the git tag for them. This is crucial for JSDelivr to cache the assets and serve them correctly.
122+
123+
<div className="prose">
124+
1. **Create and push a Git tag:**
125+
126+
```bash
127+
cd mock-cdn-assets
128+
git remote
129+
git add .
130+
git tag v1.0.2 # Use your chosen tag here
131+
git push origin main
132+
git push origin v1.0.2 # Push the tag to GitHub
133+
```
134+
135+
2. **Your assets are now publicly accessible via JSDelivr URLs:**
136+
137+
```
138+
# Widget Starter Kit Bundle
139+
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
140+
141+
# Bathtub Widget Bundle
142+
https://cdn.jsdelivr.net/gh/<your-github-username>/<repo-name>@v1.0.2/integration/widgets/@1fe/bathtub/<version>/js/1fe-bundle.js
143+
144+
# Live Configurations
145+
https://cdn.jsdelivr.net/gh/<your-github-username>/<repo-name>@v1.0.2/integration/configs/live.json
146+
```
147+
148+
</div>
149+
:::tip
150+
**JSDelivr not reflecting your changes?** Try purging the cache at https://www.jsdelivr.com/tools/purge. Changes typically appear within a few minutes.
151+
:::
152+
153+
## Deploy our 1FE app to a hosting service
154+
155+
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.
156+
157+
### Deploy the 1fe instance
158+
159+
Your 1fe instance is now ready to be deployed to a server. You can choose any hosting service of your choice that is capable of serving a nodejs express app. Below are some services you can use and their documentation links to help you deploy your 1fe instance.
160+
161+
| Service | Documentation |
162+
| ---------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------- |
163+
| [Render](https://render.com/) | https://render.com/docs/deploy-node-express-app |
164+
| [Heroku](https://www.heroku.com/) | https://devcenter.heroku.com/articles/deploying-nodejs#deploy-your-application-to-heroku |
165+
| [Railway](https://railway.app/) | https://docs.railway.com/guides/express |
166+
| [Azure](https://azure.microsoft.com/en-us/services/app-service/) | https://learn.microsoft.com/en-us/azure/app-service/quickstart-nodejs?tabs=linux&pivots=development-environment-cli |
167+
| [AWS](https://aws.amazon.com/) | https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/nodejs-quickstart.html#nodejs-quickstart-deploy |
168+
| [Google cloud](https://cloud.google.com/) | https://cloud.google.com/appengine/docs/standard/nodejs/building-app/deploying-web-service |
169+
170+
As a quick start, you can also use the links below with your 1fe instance repository URL to deploy it to either Render or Heroku.
171+
172+
| Service | Deployment Link |
173+
| ------- | ------------------------------------------------------------ |
174+
| Render | `https://render.com/deploy?repo=<your-1fe-repo-url>` |
175+
| Heroku | `https://www.heroku.com/deploy?template=<your-1fe-repo-url>` |
176+
177+
After you have deployed your 1fe instance, you will be able to access it at the URL provided by your hosting service!
178+
179+
🎉 Congratulations! You have successfully deployed your 1FE instance and its assets to a public CDN. You can now share this URL with others to showcase the benefits of using 1FE.

0 commit comments

Comments
 (0)