Giter Club home page Giter Club logo

attestation-covid19-saison2-auto's Introduction

Générateur de certificat de déplacement en "1-click"

Try me online: https://attestationcovid.site/?address=15 rue d'Antibes&birthday=20/03/1882&city=Antibes&firstname=Rene&minutesoffset=5&lastname=Coty&placeofbirth=Le Havre&zipcode=06600&reason=sport_animaux

Purpose

Ce projet permet de générer une attestation de déplacement en "1-click" pour le confinement saison 2 lance en France le vendredi 30 Octobre 2020. En effet la version numérique du gouvernement (https://media.interieur.gouv.fr/deplacement-covid-19/) nécessite

  • Plus d'un click pour générer une attestation
  • Force a re-renter les informations a chaque utilisation sur certains navigateurs (see autocomplete set to false),

Ce projet a été élabore en partant de la base de code de la version numérique du gouvernement dont la version est disponible sur Github ici: https://github.com/LAB-MI/attestation-deplacement-derogatoire-q4-2020

Ce projet est deployé a cet URL sur Google Cloud Platform (cloud run): https://attestationcovid.site/

Usage

Concu comme un lien a bookmarker sur un dispositif mobile (telephone, tablette, etc), l'ouverture de ce lien declenchera le telechargement d'une nouvelle attestation enrichie des informations fournies dans le lien.

Cette exemple de lien (prealablement bookmarke) https://attestationcovid.site/?address=15 rue d'Antibes&birthday=20/03/1882&city=Antibes&firstname=Rene&minutesoffset=5&lastname=Coty&placeofbirth=Le Havre&zipcode=06600&reason=sport_animaux generera une attestation avec les informations suivantes:

  • 15 rue d'Antibes l'addresse de votre habitation
  • 20/03/1882 la date de votre aniversaire
  • Antibes la ville d'habitation
  • Rene votre prenom
  • 03/11/2020 a 13H18 la date de sortie generee a partir de l'heure actuelle en ajoutant un offset (positif pour une date future ou negatif pour une date passee)
  • Coty votre nom
  • Le Havre votre lieu de naissance
  • 06600 votre code postal
  • une case cochee la raison de votre sortie qui selon les choix gouvernementaux pourront etre: travail, achats, sante, famille, handicap, sport_animaux, convocation, missions, enfants

Appreciez votre sortie, sortez couvert et respectez les gestes barrières !

En général deux bookmarks suffisent car seule la raison change.

Je recommende d'utiliser sur Android Firefox qui permet de changer facilement l'URL et d'exporter un lien en application.

Développer

Installer le projet

git clone https://github.com/scoulomb/attestation-covid19-saison2-auto
cd attestation-covid19-saison2-auto
npm i
npm start

Générer et tester le code de production

Tester le code de production en local

Générer le code de production pour tester que le build fonctionne en entier

npm run build:dev

Tester le code de production en local

npx serve dist

Et visiter http://localhost:5000

Le code à déployer sera le contenu du dossier dist

Hosting and project deployment

Releasing

I propose to release the application as a Docker image:

To build and run do

sudo docker build . -t covid
sudo docker run -p 5000:5000 covid

It is delivered here on Dockerhub: https://hub.docker.com/repository/docker/scoulomb/cov19

Manual release

sudo docker build . -t  scoulomb/cov19
sudo docker login
# Login with your Docker ID to push and pull images from Docker Hub. If you don't have a Docker ID, head over to https://hub.docker.com to create one.
# Username: scoulomb
# Password: 
sudo docker push scoulomb/cov19:beta

or we can configure Dockerhub to build a new image at every push, this is what we have done. When configuring dockerhub pay attention to build main branch and not master (default name has changed in october 2020).

Deploy to production

Deploy with home server

For more details please read this article.

Deploy

  • Deploy the application directly on your server with npm command or via Docker, Compose or Kube.
  • Configure reverse NAT to map inbound port to port 5000

DNS

Configure DNS to point to dynamic DNS (CNAME)

we can als use Gandi redirection whcih work with port mapping.

Deploy in the Cloud

Deploy application in Google Cloud run

I choose to deploy in Google Cloud Run, see:

Here is how

sudo snap install google-cloud-sdk --classic
gcloud projects create scoulomb-covid19-saison2
# Create the project: https://console.cloud.google.com/billing/linkedaccount?project=scoulomb-covid19-saison2, attach billing info to it
gcloud config set project scoulomb-covid19-saison2

Unfortunately we can not use image in Dockerhub, we have to use gcr

For this do

gcloud builds submit --tag gcr.io/scoulomb-covid19-saison2/cov19

And finally deploy

gcloud run deploy --image gcr.io/scoulomb-covid19-saison2/cov19 --platform managed

It will give you a service link on which we can access the APP

https://cov19-uhdzrcl53a-ew.a.run.app

Note that -p 80:5000 was done, which is strangely working without any additional conf cf. https://cloud.google.com/run/docs/reference/container-contract

Configure DNS

Define a CNAME?
$ nslookup -type=A cov19-uhdzrcl53a-ew.a.run.app
Server:		127.0.0.53
Address:	127.0.0.53#53

Non-authoritative answer:
Name:	cov19-uhdzrcl53a-ew.a.run.app
Address: 216.239.36.53

covi.coulombel.site IN CNAME cov19-uhdzrcl53a-ew.a.run.app

This will not work. Because behind there is routing based on host HEADER (like OpenShift route or k8s Ingress, unlike a Service NodePort/lb)

For instance if we change the Host header we have acess to the application.

$ curl -L  --header "Host: cov19-uhdzrcl53a-ew.a.run.app" http://covi.coulombel.site -v
Mapping custom domain in cloud run

Actually we have to define a mapping between service and domain

This is explained here: https://cloud.google.com/run/docs/mapping-custom-domains?hl=fr It is performed in 3 steps

  • select service
  • select and validate domain-> it should be coulombel.site, no subdomain. it is performing this validation by Calling registrar manager (Gandi for instance) API to insert TXT record. TXT record enable google to validate we are owner of the domain. Or we can do it manually,
  • select subdomain just "covid19"

Then it says to update CNAME

 covid19 300 IN CNAME ghs.googlehosted.com.

Very important validation can be stuck I we forgot . at the end of record definition

We should not do covid19 300 IN CNAME ghs.googlehosted.com

This is great as it enables a CNAME redirection while it keeps the https secure.

If we map an apex domain and not a subdomain we have to map A and AAAA not a CNAME.

@ 300 IN A 216.239.32.21
@ 300 IN A 216.239.34.21
@ 300 IN A 216.239.36.21
@ 300 IN A 216.239.38.21
@ 300 IN AAAA 2001:4860:4802:32::15
@ 300 IN AAAA 2001:4860:4802:34::15
@ 300 IN AAAA 2001:4860:4802:36::15
@ 300 IN AAAA 2001:4860:4802:38::15

We had seen same issue here: https://github.com/scoulomb/github-page-helm-deployer/blob/master/appendix-github-page-and-dns.md#go It is because we can not have a CNAME as APEX level (zone level).

@ IN CNAME example.com 

In Gandi API (with dev console) we can see

description: "can't use '@' for CNAME records (param: {'rrset_type': u'CNAME', 'rrset_ttl': 1800, 'rrset_name': u'@', 'rrset_values': [u'yop.tets.it']})" }

This is needed for AdSense validation. Otherwise it is not needed.

Update and Continuous Delivery/Deployment

We will actually now setup continuous deployment from git on cloud run https://cloud.google.com/run/docs/continuous-deployment-with-cloud-build

Crédits

Ce projet a été réalisé à partir d'un fork du dépôt attestation deplacement derogatoire q4 2020 de lui meme realise à partir d'un fork du dépôt deplacement-covid-19 de lui-même réalisé à partir d'un fork du dépôt covid-19-certificate de Johann Pardanaud.

Les projets open source suivants ont été utilisés pour le développement de ce service :

attestation-covid19-saison2-auto's People

Contributors

emiliecbl avatar odjpromi avatar scoulomb avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Forkers

llva emiliecbl

attestation-covid19-saison2-auto's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.