You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/content/11/en/part11.md
+3Lines changed: 3 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,4 +12,7 @@ Doing all the above manually is a pain and doesn’t scale well for a larger tea
12
12
13
13
This module was crafted by the Engineering Team at Smartly.io. At Smartly.io, we automate every step of social advertising to unlock greater performance and creativity. We make every day of advertising easy, effective, and enjoyable for more than 650 brands worldwide, including eBay, Uber, and Zalando. We are one of the early adopters of GitHub Actions in wide-scale production use. Contributors: [Anna Osipova](https://www.linkedin.com/in/a-osipova/), [Anton Rautio](https://www.linkedin.com/in/anton-rautio-768190145/), [Mircea Halmagiu](https://www.linkedin.com/in/mhalmagiu/), [Tomi Hiltunen](https://www.linkedin.com/in/tomihiltunen/).
14
14
15
+
<i>Part updated 26th March 2023</i>
16
+
- <i>Added instructions for [https://render.com/](https://render.com/) hosting platform</i>
Copy file name to clipboardExpand all lines: src/content/11/en/part11c.md
+100-4Lines changed: 100 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -62,7 +62,7 @@ Next we will have two sets of exercises for automazing the deployment with GitHu
62
62
63
63
Before going to the below exercises, you should setup your application in [Fly.io](https://fly.io/) hosting service like the one we did in [part 3](/en/part3/deploying_app_to_internet#application-to-the-internet).
64
64
65
-
If you rather want to use Heroku, there is an [alternative set of exercises](/en/part11/deployment/#exercises-11-10-11-12-heroku)for that.
65
+
If you rather want to use other hosting options, there is an alternative set of exercises for [Render](http://localhost:8000/en/part11/deployment#exercises-11-10-11-12-render) and for [Heroku](/en/part11/deployment#exercises-11-10-11-12-heroku).
66
66
67
67
In contrast to part 3 now we <i>do not deploy the code</i> to Fly.io ourselves (with the command <i>flyctl deploy</i>), we let the GitHub Actions workflow do that for us!
So finally in the 5th deployment (version v4) I got the configuration right and that ended in a succeeding release.
196
196
197
-
Besides the rudimentary TCP health check, it is extremely beneficial to have also some "application level" health checks ensuring that the app for real is in functional state. One possibility for this is a HTTP-level check defined in section [
198
-
services.http_checks](https://fly.io/docs/reference/configuration/#services-tcp_checks) that can be used to ensure that the app is responding to the HTTP requests.
197
+
Besides the rudimentary TCP health check, it is extremely beneficial to have also some "application level" health checks ensuring that the app for real is in functional state. One possibility for this is a HTTP-level check defined in section [services.http_checks](https://fly.io/docs/reference/configuration/#services-tcp_checks) that can be used to ensure that the app is responding to the HTTP requests.
199
198
200
199
Add a simple endpoint for doing an application health check to the backend. You may e.g. copy this code:
201
200
@@ -327,11 +326,108 @@ Our script based health check is hardly meaningful in real life since it does es
327
326
328
327
<divclass="tasks">
329
328
329
+
### Exercises 11.10-11.12. (Render)
330
+
331
+
If you rather want to use other hosting options, there is an alternative set of exercises for [Fly.io](/en/part11/deployment/#exercises-11-10-11-12-fly-io) and for [Heroku](/en/part11/deployment#exercises-11-10-11-12-heroku).
332
+
333
+
#### 11.10 Deploying your application to Render
334
+
335
+
Set up your application in [Render](render.com). The setup is now not quite as straightforward as in [part 3](/en/part3/deploying_app_to_internet#application-to-the-internet). You have to carefully think about what should go to these settings:
336
+
337
+

338
+
339
+
If you need to run several commands in the build or start command, you may use a simple shell script for that.
340
+
341
+
Create eg. a file <i>build_step.sh</i> with the following content:
342
+
343
+
```bash
344
+
#!/bin/bash
345
+
346
+
echo"Build script"
347
+
348
+
# add the commands here
349
+
```
350
+
351
+
Give it execution permissions (Google or see e.g. [this](https://www.guru99.com/file-permissions.html) to find out how) and ensure that you can run it from the command line:
352
+
353
+
```bash
354
+
$ ./build_step.sh
355
+
Build script
356
+
```
357
+
358
+
You also need to open the <i>Advanced settings</i> and turn the auto-deploy off since we want to controll the deployment in the GitHub Actions:
359
+
360
+

361
+
362
+
Ensure now that you get the app up and running. Use the <i>Manual deploy</i>.
363
+
364
+
Most likely things will fail at the start, so remember to keep the <i>Logs</i> open all the time.
365
+
366
+
#### 11.11 Automatic deployments
367
+
368
+
Go now to GitHub Actions [marketplace](https://github.com/marketplace) and search for action for our purposes. You might search with <i>render deploy</i>. There are several actions to choose from. You can pick any. Quite often the best choice is the one with the most stars. It is also a good idea to look if the action is actively maintained (time of the last release) and does it have many open issues or pull requests.
369
+
370
+
Set up the action to your workflow and ensure that every commit that pass all the checks results in a new deployment. Note that you need Render API key and the app service id for the deployment. See [here](https://render.com/docs/api) how the API key is generated. You can get the service id from the URL of the Render dashboard of your app. The end of the URL (starting with _srv-_) is the id:
The deployment takes some time. See the events tab of the Render dashboard to see when the new deployment is ready:
377
+
378
+

379
+
380
+
It might be a good idea to have a dummy endpoint in the app that makes it possible to do some code changes and to ensure that the deployed version has really changed:
381
+
382
+
```js
383
+
app.get('/version', (req, res) => {
384
+
res.send('1') // change this string to ensure a new version deployed
385
+
})
386
+
```
387
+
388
+
#### 11.12 Health check
389
+
390
+
All tests pass and the new version of the app gets automatically deployed to Render so everything seems to be in order. But does the app really work? Besides the checks done in the deployment pipeline, it is extremely beneficial to have also some "application level" health checks ensuring that the app for real is in a functional state.
391
+
392
+
Add a simple endpoint for doing an application health check to the backend. You may e.g. copy this code:
393
+
394
+
```js
395
+
app.get('/health', (req, res) => {
396
+
res.send('ok')
397
+
})
398
+
```
399
+
400
+
Commit the code and push it to GitHub. Ensure that you can access the health check endpoint of your app.
401
+
402
+
Configure now a <i>Health Check Path</i> to your app. The configuration is done in the settings tab of the Render dashboard.
403
+
404
+
Make a change in your code, push it to GitHub, and ensure that the deployment succeeds.
405
+
406
+
Note that you can see the log of deployment by clicking the most recent deployment in the events tab.
407
+
408
+
When you are set up with the health check, simulate a broken deployment by changing the code as follows:
409
+
410
+
```js
411
+
app.get('/health', (req, res) => {
412
+
throw'error...'
413
+
// eslint-disable-next-line no-unreachable
414
+
res.send('ok')
415
+
})
416
+
```
417
+
418
+
Push the code to GitHub and ensure that a broken version does not get deployed and the previous version of the app keeps running.
419
+
420
+
Before moving on, fix your deployment and ensure that the application works again as intended.
421
+
422
+
</div>
423
+
424
+
<divclass="tasks">
425
+
330
426
### Exercises 11.10-11.12. (Heroku)
331
427
332
428
Before going to the below exercises, you should setup your application in [Heroku](heroku.com) hosting service like the one we did in [part 3](/en/part3/deploying_app_to_internet#application-to-the-internet).
333
429
334
-
If you rather want to use Fly.io for hosting, there is an [alternative set of exercises](/en/part11/deployment/#exercises-11-10-11-12-fly-io) for that.
430
+
If you rather want to use other hosting options, there is an alternative set of exercises for [Fly.io](/en/part11/deployment/#exercises-11-10-11-12-fly-io)and for [Render](/en/part11/deployment#exercises-11-10-11-12-render).
335
431
336
432
In contrast to part 3 now we <i>do not push the code</i> to Heroku ourselves, we let the Github Actions workflow do that for us!
0 commit comments