From 13b3b9aa7ade4200f53063fb30b0ed75add3ad50 Mon Sep 17 00:00:00 2001 From: Carlos Armando Marcano Vargas Date: Sat, 19 Nov 2022 16:30:13 -0400 Subject: [PATCH 1/6] Add Railway deployment process --- docs/hosting.md | 87 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 86 insertions(+), 1 deletion(-) diff --git a/docs/hosting.md b/docs/hosting.md index 305a25d9a..790700e91 100644 --- a/docs/hosting.md +++ b/docs/hosting.md @@ -2,4 +2,89 @@ The process of hosting a Robyn app on various cloud providers. -Coming Soon.... + +### Railway + +To deploy an app on Railway is necessary to have a Github account, because the apps are deploying from a Github repository. + +The repository we will be deploy is a simple app that display a "Hello World" message and serve a HTML file. + +Directory structure: + +``` +app folder/ + main.py + requirements.txt + index.html + +``` + +Prerequisites: + +- Github Account + +This is a template of the Robyn app we will be deploy. + +main.py +``` +from robyn import Robyn, static_file + + +app = Robyn(__file__) + + +@app.get("/hello") +async def h(request): + print(request) + return "Hello, world!" + +@app.get("/") +async def get_page(request): + return static_file("./index.html") + + +app.start(url="0.0.0.0", port=PORT) + +``` + +index.html + +``` +

Hello World, this is Robyn framework!

+ +``` + + +The Railway documentation says the following about exposion an app: + +> The easiest way to get up and running is to have your application listen on 0.0.0.0:$PORT, where PORT is a Railway-provided environment variable. + +So, is necessary to pass `url` as `0.0.0.0` to `app.start()` as argument. + +Too deploy this app on Railway, we need to go to the [Railway page](https://railway.app/) and create an account. + +Press the "Login" button and select to login with a Github account. + +![image](https://user-images.githubusercontent.com/70811425/202867604-10a09f87-ecb9-4a42-ae90-1359223049bc.png) + +Then, we press the "New Project" button and select "Deploy from GitHub repo". + +![image](https://user-images.githubusercontent.com/70811425/202867653-7477cb10-2b2c-47ae-986a-b584f463cd13.png) + + +And we select the repo to deploy. + +Now, we click on our project's card. + +Select "Variables" and press the "New Variable" button to set the environments variables. + +![image](https://user-images.githubusercontent.com/70811425/202869462-8cb9c052-4083-4696-9bb3-9fe7a7637c35.png) + +Then, we go to Setting and click on "Generate Domain". + +We would see the domain generate bellow "Domains". + +![image](https://user-images.githubusercontent.com/70811425/202869664-31687da8-0194-45f0-a460-470c41ea2ef6.png) + + +We can go to /hello and confirm that the message "Hello World" is displayed. From 59f04cd79378661aec3f941116b171600377c831 Mon Sep 17 00:00:00 2001 From: Carlos Armando Marcano Vargas Date: Sat, 19 Nov 2022 16:38:54 -0400 Subject: [PATCH 2/6] Trim images --- docs/hosting.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/hosting.md b/docs/hosting.md index 790700e91..c7fe5c5c2 100644 --- a/docs/hosting.md +++ b/docs/hosting.md @@ -69,7 +69,7 @@ Press the "Login" button and select to login with a Github account. Then, we press the "New Project" button and select "Deploy from GitHub repo". -![image](https://user-images.githubusercontent.com/70811425/202867653-7477cb10-2b2c-47ae-986a-b584f463cd13.png) +![image](https://user-images.githubusercontent.com/70811425/202870632-4d3f46dc-1aa9-4603-9b0f-344ed87ec9d0.png) And we select the repo to deploy. @@ -78,13 +78,13 @@ Now, we click on our project's card. Select "Variables" and press the "New Variable" button to set the environments variables. -![image](https://user-images.githubusercontent.com/70811425/202869462-8cb9c052-4083-4696-9bb3-9fe7a7637c35.png) +![image](https://user-images.githubusercontent.com/70811425/202870681-5c069475-a5d1-4069-8582-c5b549d27aad.png) Then, we go to Setting and click on "Generate Domain". We would see the domain generate bellow "Domains". -![image](https://user-images.githubusercontent.com/70811425/202869664-31687da8-0194-45f0-a460-470c41ea2ef6.png) +![image](https://user-images.githubusercontent.com/70811425/202870735-6b955752-c5a6-48d5-acbc-1a4ea6fd7574.png) We can go to /hello and confirm that the message "Hello World" is displayed. From 5db89e8231e99c622a1b18dfc2ed3d5a600fb95c Mon Sep 17 00:00:00 2001 From: Carlos Armando Marcano Vargas Date: Sat, 19 Nov 2022 16:47:10 -0400 Subject: [PATCH 3/6] Add image showing "Deploy Now" button --- docs/hosting.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/hosting.md b/docs/hosting.md index c7fe5c5c2..a1c4afbf6 100644 --- a/docs/hosting.md +++ b/docs/hosting.md @@ -71,8 +71,10 @@ Then, we press the "New Project" button and select "Deploy from GitHub repo". ![image](https://user-images.githubusercontent.com/70811425/202870632-4d3f46dc-1aa9-4603-9b0f-344ed87ec9d0.png) +And we select the repo we want to deploy. And click "Deploy Now". +![image](https://user-images.githubusercontent.com/70811425/202870837-16884fef-8900-4ab3-9794-0fb53c3ffd2e.png) -And we select the repo to deploy. +![image](https://user-images.githubusercontent.com/70811425/202871003-f79a1cef-9a5f-4166-be4f-527c60ec6c79.png) Now, we click on our project's card. @@ -87,4 +89,4 @@ We would see the domain generate bellow "Domains". ![image](https://user-images.githubusercontent.com/70811425/202870735-6b955752-c5a6-48d5-acbc-1a4ea6fd7574.png) -We can go to /hello and confirm that the message "Hello World" is displayed. +We can go to /hello and confirm that the message "Hello World" is displayed. From d8cae802043434395d5d87f753c2b81faa3f5327 Mon Sep 17 00:00:00 2001 From: Carlos Armando Marcano Vargas Date: Mon, 21 Nov 2022 15:26:21 -0400 Subject: [PATCH 4/6] Apply suggestions --- docs/hosting.md | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/docs/hosting.md b/docs/hosting.md index a1c4afbf6..d430f5079 100644 --- a/docs/hosting.md +++ b/docs/hosting.md @@ -5,9 +5,11 @@ The process of hosting a Robyn app on various cloud providers. ### Railway -To deploy an app on Railway is necessary to have a Github account, because the apps are deploying from a Github repository. +We will be deploying the app on [Railway](https://railway.app/). -The repository we will be deploy is a simple app that display a "Hello World" message and serve a HTML file. +A GitHub account is needed as a mandatory pre-requisite. + +We will be deploying a sample "Hello World", which will be demonstrating a simple `GET` route and serving an HTML file. Directory structure: @@ -19,14 +21,11 @@ app folder/ ``` -Prerequisites: - -- Github Account - This is a template of the Robyn app we will be deploy. main.py -``` + +```python from robyn import Robyn, static_file @@ -47,21 +46,22 @@ app.start(url="0.0.0.0", port=PORT) ``` + index.html -``` +```html

Hello World, this is Robyn framework!

``` - +### Exposing Ports The Railway documentation says the following about exposion an app: > The easiest way to get up and running is to have your application listen on 0.0.0.0:$PORT, where PORT is a Railway-provided environment variable. So, is necessary to pass `url` as `0.0.0.0` to `app.start()` as argument. -Too deploy this app on Railway, we need to go to the [Railway page](https://railway.app/) and create an account. +To deploy this app on Railway, we need to create a Railway account. We can do so by going on the [Railway HomePage](https://railway.app/). Press the "Login" button and select to login with a Github account. @@ -82,11 +82,11 @@ Select "Variables" and press the "New Variable" button to set the environments v ![image](https://user-images.githubusercontent.com/70811425/202870681-5c069475-a5d1-4069-8582-c5b549d27aad.png) -Then, we go to Setting and click on "Generate Domain". +Then, we go to the "Settings" tab and click on "Generate Domain." -We would see the domain generate bellow "Domains". +We can generate a temporary domain under the "Domains" tab. ![image](https://user-images.githubusercontent.com/70811425/202870735-6b955752-c5a6-48d5-acbc-1a4ea6fd7574.png) -We can go to /hello and confirm that the message "Hello World" is displayed. +We can go to our domain `/hello` and confirm that the message "Hello World" is displayed. From ce628c61b1f27b76ff6d9b51756183c537cd9b9c Mon Sep 17 00:00:00 2001 From: Carlos Armando Marcano Vargas Date: Mon, 21 Nov 2022 15:41:24 -0400 Subject: [PATCH 5/6] Add issue with building process --- docs/hosting.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/hosting.md b/docs/hosting.md index d430f5079..6f746aac7 100644 --- a/docs/hosting.md +++ b/docs/hosting.md @@ -23,6 +23,8 @@ app folder/ This is a template of the Robyn app we will be deploy. +We have to write the code in `main.py` instead `app.py`. If there is no `main.py` file the building process will fail. But that is a thing with Railway, you have to have a main.py to start any app. + main.py ```python From 39ce5f2b10afe524e81d8a79d67fb7b7ec4ff393 Mon Sep 17 00:00:00 2001 From: Sanskar Jethi Date: Mon, 21 Nov 2022 22:16:12 +0000 Subject: [PATCH 6/6] Update docs/hosting.md --- docs/hosting.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/hosting.md b/docs/hosting.md index 6f746aac7..286134328 100644 --- a/docs/hosting.md +++ b/docs/hosting.md @@ -65,7 +65,7 @@ So, is necessary to pass `url` as `0.0.0.0` to `app.start()` as argument. To deploy this app on Railway, we need to create a Railway account. We can do so by going on the [Railway HomePage](https://railway.app/). -Press the "Login" button and select to login with a Github account. +Press the "Login" button and select "login with a GitHub account." ![image](https://user-images.githubusercontent.com/70811425/202867604-10a09f87-ecb9-4a42-ae90-1359223049bc.png)