Coder Social home page Coder Social logo

mlaprise / react-serverless-gcp-terraform Goto Github PK

View Code? Open in Web Editor NEW

This project forked from matthewcylau/react-serverless-gcp-terraform

0.0 1.0 0.0 2.62 MB

Serverless full-stack React app on GCP

HCL 17.78% HTML 2.67% CSS 0.46% TypeScript 61.74% JavaScript 17.27% Shell 0.08%

react-serverless-gcp-terraform's Introduction

GCP Serverless React App

A reference project to deploy a static React app onto Google Cloud Storage, Cloud Build as the CI/CD tool, and Cloud Functions as serverless back-end, referencing this GCP documentation

App URL here

GCP Architecture

Pre-requisites

terraform -help # prints Terraform options

Domain set-up

  • Add the GCP credentials JSON client_email as an owner of the domain. See Cloud Storage documentation here

Configurations

  • Populate the variables in terraform.tfvars
project                = <GCP-PROJECT-ID>
bucket_name            = <STATIC-SITE-BUCKET-NAME>
cloud_source_repo_name = <CLOUD-SOURCE-REPOSITORY-NAME>
# and other variables

Deploy

gcloud auth application-default login # authenticate with GCP
cd deploy # change to deploy directory
terraform init # initialises Terraform
terraform apply # deploys GCP stack
terraform destroy # destroys GCP stack

Build/run app locally

  • Create a .env file with the following, and place at project root directory:
REACT_APP_API_BASE_URL=<CLOUDFUNCTION-TRIGGER-URL>
  • Run npm run start and visit aapp at http://localhost:3000

Domain configuration

  • Creat an A record and point it to the external static IP address. See reference GCP documentaion here

Connect to Cloud SQL

  • Connect to Cloud SQL to view database tables:
psql postgresql://postgresql-database-user:<DB-PASSWORD>@<CLOUD-SQL-IP>:5432/react-serverless-gcp-database

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

MIT

react-serverless-gcp-terraform's People

Contributors

matthewcylau avatar

Watchers

 avatar

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.