All Projects → ZBejavu → gcloud-deploy-tutorial

ZBejavu / gcloud-deploy-tutorial

Licence: other
How to continuously deploy a Full Stack React +Node.js +MySql App to Google Cloud Compute Engine

Programming Languages

Makefile
30231 projects
Dockerfile
14818 projects

Projects that are alternatives of or similar to gcloud-deploy-tutorial

skein
A tool and library for easily deploying applications on Apache YARN
Stars: ✭ 128 (+573.68%)
Mutual labels:  deployment
AutoDeploy
AutoDeploy is a single configuration deployment library
Stars: ✭ 43 (+126.32%)
Mutual labels:  deployment
build-plugin-template
Template repository to create new Netlify Build plugins.
Stars: ✭ 26 (+36.84%)
Mutual labels:  deployment
fabalicious
is now deprecated and not supported anymore, use https://github.com/factorial-io/phabalicious instead
Stars: ✭ 14 (-26.32%)
Mutual labels:  deployment
django-quick-start
Deploy a Django app on Render
Stars: ✭ 17 (-10.53%)
Mutual labels:  deployment
mini-qml
Minimal Qt deployment for Linux, Windows, macOS and WebAssembly.
Stars: ✭ 44 (+131.58%)
Mutual labels:  deployment
porter
Multi-region blue-green Docker deployments and a whole lot more
Stars: ✭ 43 (+126.32%)
Mutual labels:  deployment
terraform-module-icp-deploy
This Terraform module can be used to deploy IBM Cloud Private on any supported infrastructure vendor. Tested on Ubuntu 16.04 and RHEL 7 on SoftLayer, VMware, AWS and Azure.
Stars: ✭ 13 (-31.58%)
Mutual labels:  deployment
draughtsman
An in-cluster agent that handles Helm based deployments
Stars: ✭ 31 (+63.16%)
Mutual labels:  deployment
wimpy.deploy
Ansible role to automate immutable infrastructure scheduling one docker container on one EC2 instance
Stars: ✭ 21 (+10.53%)
Mutual labels:  deployment
serverless-model-aws
Deploy any Machine Learning model serverless in AWS.
Stars: ✭ 19 (+0%)
Mutual labels:  deployment
docker-wordmove
Docker image to run Wordmove
Stars: ✭ 16 (-15.79%)
Mutual labels:  deployment
WOA-Deployer
WOA Deployer
Stars: ✭ 77 (+305.26%)
Mutual labels:  deployment
QLD
A graphical tool to make the deploying of Qt quick applications on linux platform faster
Stars: ✭ 18 (-5.26%)
Mutual labels:  deployment
gaffer-tools
Essential tools and utilities for Gaffer; including GUI, local accumulo cluster, python api
Stars: ✭ 43 (+126.32%)
Mutual labels:  deployment
jdeploy
Developer friendly desktop deployment tool
Stars: ✭ 282 (+1384.21%)
Mutual labels:  deployment
ci-docker-image
A Docker Image meant for use with CI/CD pipelines
Stars: ✭ 23 (+21.05%)
Mutual labels:  deployment
deployer-php-action
Deploy PHP projects using Deployer from Github Actions
Stars: ✭ 57 (+200%)
Mutual labels:  deployment
Docker-Templates
Docker configurations for TheHive, Cortex and 3rd party tools
Stars: ✭ 71 (+273.68%)
Mutual labels:  deployment
Deploy-machine-learning-model
Dockerize and deploy machine learning model as REST API using Flask
Stars: ✭ 61 (+221.05%)
Mutual labels:  deployment

Google Cloud Deploy Tutorial

Deploying a Fullstack React App + Express.js + MySQL

Automatically Deploy on every event (default is push) to the branch of your choice.

If you want to use Cloud Sql :

This Branch runs SQL inside the Compute Engine VM. for cloud SQL usage -> switch to cloud-sql branch

steps:

  1. Create a Google Cloud Project -> use your free trial and make sure the account has billing.
  2. Create a Service Account User :
    • Go to the I AM & ADMIN -> Service Accounts -> Create Service Account
    • Give it a name and Add the following Roles :
      1. Compute Admin
      2. Compute Instance Admin (v1)
      3. Service Account User
      4. Storage Admin

ENV_FILE-example

  1. Create a Key for the service account you've created -> Select in JSON format.
    1. Change filename to "key.json". Then use your terminal, cd into the folder where your key was downloaded.
    2. Encrypt the file ->
      • windows: certutil -encode key.json tmp.b64 && findstr /v /c:- tmp.b64 > key.b64
      • linux: base64 key.json > key.b64
      • macOs: base64 -i key.json -o key.b64
  2. Head over to your repository on github, go to Settings -> Secrets and ADD the following Secrets : (In this Format)

ENV_FILE-example

  • DB_HOST -> MySql Host name (of your choice)
  • DB_PASS -> MySql Password (of your choice)
  • DB_NAME -> MySql Database (of your choice)
  • DB_USER -> MySql User (of your choice)
  • GOOGLE_APPLICATION_CREDENTIALS -> Paste the contents of your key.b64 file
  • PROJECT_ID -> Your project id
  • SERVICE_ACCOUNT -> The full email that represents your service account
  • ENV_FILE -> If needed: PASTE the contents of your .env file ( All additional secrets your project needs )
  • Do not override database variables in ENV_FILE.

ENV_FILE-example

Enable Compute Engine API + Container Registry For Your Project

open your project in vscode, in your root directory run ->
git clone https://github.com/ZBejavu/gcloud-deploy-tutorial.git

Adaptations :

  • Copy -> into your project root folder :
    • .github folder with its contents
    • Dockerfile, docker-compose, Makefile, .dockerignore
  • Create a script in your Server Package.json file as described in the Dockerfile.
  • Configure Your Sequelize Config as Shown in the examples/config folder
  • MAKE SURE your server Serves the Build files as Shown in the examples/server/app.js
  • Specify in Docker-Deploy.yml :
    1. The Deploy Branch (deploy will happen when you push to that branch)
    2. Name your Instance (GCE_INSTANCE Variable)
    3. Enter your SERVER_PORT
  • If you Added ENV_FILE -
    • Unmark Steps In Docker-Compose.yml That are titled 'Enable when using ENV_FILE'
    • Add the line --env-file=.env \ in Makefile as Specified (line 67)
  • Delete the 'gcloud-deploy-tutorial' directory when you've finished setting up.

** The Dockerfile and workflow were both made for client folder named 'client' and server folder named 'server'
** Change folder names if necessary, update Port number in the Dockerfile, compose file and Workflow file if needed.
** Friendly tip : Make sure all migration table names are consistent.

Check To see Your Containerised app works :

  • In your client folder:
    • npm ci --only=production
    • CI=false INLINE_RUNTIME_CHUNK=false npm run build
  • In your root folder:
    • docker-compose build && docker-compose up

Commit + Push to github, Watch Your Workflow in Actions tab

*** (push changes to MASTER / the branch you want the deploy to happen at )
Visit Compue Engine -> VM Instances to view your app when workflow finished succesfully
visit the external-ip:yourportnumber to view your application

Resources:

https://www.youtube.com/watch?v=OXE2a8dqIAI&t=2637s - Great Video, Understanding the Docker-Deploy.yml file, Makefile

https://cloud.google.com/sdk/gcloud/reference/compute/instances/create - Instance create documentation

https://github.com/google-github-actions/setup-gcloud - gcloud @action documentation

https://www.youtube.com/watch?v=0B2raYYH2fE&t=232s - Quick docker-compose explanation

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].