Skip to content

Instantly share code, notes, and snippets.

@michaellee8
Last active November 29, 2017 09:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save michaellee8/ba88489cd9c3b482858d3b3f39defa3a to your computer and use it in GitHub Desktop.
Save michaellee8/ba88489cd9c3b482858d3b3f39defa3a to your computer and use it in GitHub Desktop.
Revisioner SBA deployment instructions

Before reading this documents, you should be acknowledged that the deployment process should only be done by people that have sufficient knowledge in the Information and Communication Technology. Stupidly deploying this program in an unproper way can results in breaking your computer or even more. You are also told that the author of this deployment guide cannot be hold liable for any contents in this guide and the corresponding app as well, use it at your own risk!

Contacts

If you find difficulties in deploying this application or you want to view the working demo, feel free to contact me via email ckmichael8@gmail.com. My github username is michaellee8.

Note:

  1. You will proably need sudo access or admistrator access to perform the below actions.
  2. Running the app server requires internet connection that can at least connect to the npm repo and google firebase, and the server have to be accessible from internet with proper internet setting like firewalls so that the firebase auth server have the ability to communicate with it. The access rules should at least allows traffic at port 8080 for server communication with firebase. If you want to access the client app outside the server device, you should also allow port 3000
  3. Setting up firebase for usage of this app requires your credit card information, but the amount of usage for testing purpose will not exceed the free usage limits. If you use this app in a non-testing scale, it may exceed the free usage limits and you might be charged.
  4. To protect yourself from bills, do not publically announce usage of this app.
  5. After your testing, you should delete the Firebase project to make sure that no accidentical charges will be applied.
  6. Running some of the commands need admin access, you will need to run a cmd terminal as a adminstrator if you are using Windows, or append sudo before your command if you are using Linux, e.g. sudo npm xxx

1. Firebase configuration

  1. Navigate to https://console.firebase.google.com/?pli=1
  2. Create a project with name michaellee8-sba-revisioner, you may want to record the project id for later identification.
  3. In the lower-bottom corner, click UPGRADE and select BLAZE plan. Perform all the instructions as required by google including registering your credit card

2. Installation of required software

  1. Make sure you have enough disk space in your computer before you do anything. Empty space of about 10GBs can be enough.
  2. Install the "Current" version of nodejs at https://nodejs.org/en/, which will have both npm and nodejs installed into your computer.
  3. Install the newest version of MySQL from https://dev.mysql.com/downloads/mysql/, your root account should have password ggg-revisioner.
  4. In your command-line interface (CLI), run npm --global install firebase-tools to install the firebase toolkit provided by google.
  5. npm install -g serve to install the program for serving webpage.

3. Installation of server program

  1. Start the terminal and navigate to the provided folder called revisioner-sba.
  2. cd revisioner-graphql to change to current working directory to the server project.
  3. npm install to install the required dependencies.
  4. Navigate to your Firebase project setup previously, which should be named michaellee8-sba-revisioner in the Firebase Project Console.
  5. Next to the Overview located at the top-right corner of the screen, there is a "gear" button, click it to go to the setting page.
  6. Go to the "Service Accounts" tab and then click "Firebase Admin SDK".
  7. Click "Generate New Private Key" and then click "Generate Key".
  8. Move the downloaded file to /path/to/project/michaellee8-sba-revisioner/revisioner-graphql/src, it should be named serviceAccountKey.json. Replace it if it already exists.
  9. In line 8 of /path/to/project/michaellee8-sba-revisioner/revisioner-graphql/src/firebaseAuth.js, change https://revisioner-3c321.firebaseio.com into the databaseURL in the "Admin SDK configuration snippet".
  10. npm run initDb to initiate the SQL database.
  11. npm start to start the server.
  12. Navigate to IP-OR-URL.OF.SERVER:8080/graphql and check out the graphiql editor. It should shows up if the program is functioning correctly.

4. Deployment of Firebase Cloud Functions

  1. cd ../revisioner to navigate to /path/to/project/michaellee8-sba-revisioner/revisioner
  2. firebase login --no-localhost to login into firebase.
  3. firebase use YOUR-FIREBASE-PROJECT-NAME to link your project with firebase.
  4. firebase init functions to configure the fucntions. Do not override or replace any current content. Choose the project you created in 1.2 if you are asked.
  5. Change https://michaellee8-nuclide-server.appspot.com/graphql in line 3 of /path/to/project/michaellee8-sba-revisioner/revisioner/functions/index.js into https://IP-OR-URL.OF.SERVER:8080/graphql, which is similar to the one in 3.12.
  6. firebase deploy --only functions to deploy the functions.

5. Configuring and Running the webapp

  1. Make sure your current working directory is /path/to/project/michaellee8-sba-revisioner/revisioner.
  2. Navigate to your Firebase project setup previously, which should be named michaellee8-sba-revisioner in the Firebase Project Console.
  3. In the "Overview" page, Click "Add Firebase to your webapp".
  4. Copy the part of code snipet of e.g. {apiKey:"xxx",authDomain:"xxx",xxx:xxx,messagingSenderId:"xxx"} to your clipboard.
  5. Replace {apiKey: "xxx", authDomain: "xxx", databaseURL: "xxx", projectId: "xxx", storageBucket: "xxx", messagingSenderId: "xxx"} /path/to/project/michaellee8-sba-revisioner/revisioner/src/base.js, which should be located in line 3 to 10.
  6. npm build to build the client webapp.
  7. Wait until it the terminal says the program is compiled (transpliled if you need a more formal term) .
  8. If you are deploying with in the current computer and have access to localhost, fireup the browser and go to localhost:3000, otherwise go to IP-OR-URL.OF.SERVER:3000

6. Deleting the Firebase project after testing

  1. Navigate to your Firebase project setup previously, which should be named michaellee8-sba-revisioner in the Firebase Project Console.
  2. Next to the Overview located at the top-right corner of the screen, there is a "gear" button, click it to go to the setting page.
  3. Click the "General" Tab.
  4. Scroll to the bottom of page.
  5. Do what as told to delete the project to stop being charged.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment