1
0
mirror of https://gitlab.com/free_zed/free_zed.gitlab.io.git synced 2024-06-01 22:02:28 +00:00
free_zed.gitlab.io/content/grandpy-bot-zappa-flask-lambda-gitlab.md
Freezed f348579a90 🎨 Normalize usage of non breaking spaces
Remove ` ` by ` `, less painfull to read
2020-09-27 22:30:18 +02:00

69 lines
2.6 KiB
Markdown
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

Title: GrandPy Bot à la mode «serverless»
Date: 2019-03-16 23:34
Category: Réalisations
Status: published
Summary: Évolution du projet 7 réalisé durant le parcours OpenClassrooms avec: Zappa, AWS Lambda & Gitlab-CI/Pages.
Lang: fr
Slug: grandpy-bot-zappa-flask-lambda-gitlab
Tags: git, gitlab, devops, flask, dev, zappa, serverless, aws, ci, cd, aws-lambda, python,
Il s'agissait d'un [projet étudiant][oc] précédemment hébergé sur [Github][ocp7]. Je l'ai mis à jour pour jouer avec:
* [Zappa][zappa]
* [Flask][flask]
* [AWS Lambda][awslmbd]
* [Gitlab-ci][glci]
Un papy-robot qui parle de souvenirs géographiques et citant Wikipedia.
Échangez donc [quelques phrases][prod] avec lui (^_^)
Installez le vôtre !
--------------------
L'exécution a besoin de quelques variables d'environnement:
- `EMAIL_ADDRESS` (Nominatim API)
- `MAPBOX_API_KEY` (Mapbox API)
- `GOO_API_KEY` (not used [but needed][issue51])
### Localement:
Il fonctionne comme une simple application mono-page [flask][flask]:
- [forkez-le][fork]
- mettez en place un environement virtuel: `virtualenv .venv`
- installez les dépendances: `pip install -r requirements.txt`
- executez locallement: `python run.py`
### Sur Gitlab:
Créez un profil [AWS IAM][awsiam] sur **votre compte AWS** et ajoutez des variables d'environnement valides dans `https://gitlab.com/<namespace>/grandpy/settings/ci_cd`:
Repoussez le et le script d'intégration continue:
- déployera le code du _chat_ sur [AWS Lambda][awslmbd] avec l'aide magique de [Zappa][zappa]
- mettra à jour le [JavaScript][js] avec l'URL _AWS API Gateway_ pointant vers _Lambda_
- génèrera la page d'accueil HTML (avec un [script flask][genstat])
- déployera les fichiers statiques sur _gitlab-pages_ (HTML, images & CSS)
...et voilà, vous pouvez maintenant discuter avec _GrandPy_ sur `https://<namespace>.gitlab.io/grandpy/` (- ;
---
N'hésitez pas à me faire part de vos commentaires via les [tickets][issues].
[awsiam]: https://github.com/Miserlou/Zappa/blob/master/example/policy/deploy.json
[awslmbd]: https://console.aws.amazon.com/lambda/
[flask]: http://flask.pocoo.org/
[fork]: https://gitlab.com/free_zed/grandpy/forks/new
[genstat]: https://gitlab.com/free_zed/grandpy/blob/master/genstat.py
[glci]: https://gitlab.com/free_zed/grandpy/blob/master/.gitlab-ci.yml
[issue51]: https://gitlab.com/free_zed/grandpy/issues/
[issues]: https://gitlab.com/free_zed/grandpy/issues/new
[js]: https://gitlab.com/free_zed/grandpy/tree/master/static/js/ask.js
[oc]: {filename}/ocp7.md
[ocp7]: https://github.com/freezed/ocp7
[prod]: https://free_zed.gitlab.io/grandpy
[zappa]: https://github.com/Miserlou/Zappa/