From 1e53db2861bad30d0d4f379691e8cc17c7112a28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wilson=20J=C3=BAnior?= Date: Tue, 3 Dec 2024 10:29:23 -0300 Subject: [PATCH] Add first version of guide of React.js applications --- mkdocs.yml | 1 + src/user_guides/deploy_react_apps.md | 38 ++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 src/user_guides/deploy_react_apps.md diff --git a/mkdocs.yml b/mkdocs.yml index fd6bf0c..f59b3e3 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -54,6 +54,7 @@ nav: - GO apps: ./user_guides/deploy_go_apps.md - Python apps: ./user_guides/deploy_python_apps.md - Node.js apps: ./user_guides/deploy_nodejs_apps.md + - React.js apps: ./user_guides/deploy_react_apps.md - Admin guides: - Managing clusters: ./admin_guides/managing_clusters.md diff --git a/src/user_guides/deploy_react_apps.md b/src/user_guides/deploy_react_apps.md new file mode 100644 index 0000000..ab9bd68 --- /dev/null +++ b/src/user_guides/deploy_react_apps.md @@ -0,0 +1,38 @@ +# Deploy React.js Applications + + +## Overview + +The major advantage of React applications is that are just static files to serve to a browser, react.js has its build process that generates .js, .css, and index.html files ready to deploy, cause of this concept we divide the process into three phases: Creating the app, build and deploy + + +## Creating the app + +To create an app, you use the command app create: + +``` bash +$ tsuru app create static +``` + +## Build + +Let's create an app using a well-known guide: https://github.com/facebook/create-react-app + + +After creating, let's generate a build directory using the following: + +``` bash +$ npm run build +``` + + +## Deploy + +Well, now we have the build directory with all static files, the next step is to add two files to the build directory: tsuru.yml and nginx.conf, both are suggestions that work for most react apps: + +``` bash +$ cd build +$ wget https://raw.githubusercontent.com/tsuru/platforms/refs/heads/master/examples/static-reactjs/nginx.conf +$ wget https://github.com/tsuru/platforms/blob/master/examples/static-reactjs/tsuru.yml +$ tsuru app deploy -a . +``` \ No newline at end of file