2.3 Hasura local development

Now, Finally I have in the phase of run Hasura in my local computer by installing Hasura local development.

First of all, I want to clear that at prior I was doing setup local development in Ubuntu but because of the problem specified below I have used on Windows 32 bit system. So, here I have explained local development process and problems for both Ubuntu as well as Windows.

Visit below link to get instruction on how to install Hasura local development. Source: github.com/hasura

2.1 Setup dev environment is the prerequisite for start the installation of local development.

As Linux is recommended for installing local development, I have installed Ubuntu 16.04.

Steps to follow:

  1. Install Virtualbox. To know more about Virtualbox and its usage.
  2. Install hasuractl by execute following command on terminal:
curl -Lo hasuractl https://storage.googleapis.com/hasuractl/v0.1.2/linux-amd64/hasuractl && chmod +x hasuractl && sudo mv hasuractl /usr/local/bin/

3.After complete above tasks, You have to create account on beta.hasura.io

4.Execute below command on terminal

hasuractl login

5.Enter the Credentials.

6.Afrer successfully login you have to execute below command. This command will download approx. 1–1.5Gb data so keep patience and wait.

hasuractl local start

This command will download and install minikube. Oooopps!!! it throws an error.

It says ‘ This computer doesn’t have VT-X/AMD-v enabled’ I have to enable it from BIOS but my laptop’s BIOS does not contain anything like virtualization or VT-X.

Error while execute hasuractl local start

You can refer the problem from github With reference no. #305 which I was reported. I am thankful to Hasura Intern @AbhishekBhattacharya for help me. But I cannot resolve the problem because my laptop does not have support for Virtualization Technology.

As, Virtualization cannot enabled in my laptop I have to find alternative for Local development and it was deploy project on Hasura infrastructure by beta.hasura.io.

Steps carried out for using Hasura infrastructute on beta.hasura.io

1.Create an account on beta.hasura.io.
2. Click on create a project.
3. Choose a 7 day preview project hosted by Hasura (Which can extend by Hasura for its Interns).
4. Login to your Hasura console , using the credentials.
5. Go to ‘Advanced settings’ > Authorized SSH keys> paste your systems public ssh key there (creating-ssh-keys).

Which I did, as Follows :-

I had to take my systems public ssh key and Add it into the Authorised SSH keys of hasura in the Advanced Settings console of my hasura project console. To check whether my system already has a public ssh key
A) opened the windows cmd prompt
B) and run cd %userprofile%/.ssh , which gave message "No such file or directory", i.e. there aren't any existing keys
C)So I had to generate one by running this command ssh-keygen -t rsa, as a result a file id_rsa.pub containing the newly generated public ssh key was created in my root folder at location C:\Users\Jatin\.ssh\id_rsa.pub. I copied this single line but quite long, ssh key from there and entered it into the Advanced setting’s Authorised SSH key text area .
6. Made your project live, as follows:

A) Go to Add a custom service, in hasura project console.
 B) Created an Endpoint named ‘app’.
 C)While doing that make sure to check the enabled ‘Git Push’
 D)set container port 8080
 E) Allowed role ‘user’ ( if make it admin).
 F) Finally clicked ‘create’ button.

7. As a result of this an empty remote project ssh://hasura@app.shoddily49.hasura.app.io/~/git/app/ got created in GitHub. Now I had to sync with this remote github project from my computer.

8. cloned the hasura’s quickstart-docker-git , git repository in my project directory E:/Politics to import an Git repository which had a DOCKERFILE in it and also server as an example/sample nodejs-express project to begin/start my work i.e. my backend coding, by running this command

E:\Politics> git clone URL of hasura/quickstart-docker-git repository <enter>(got the URL by clicking clone/download button on this repo’s git page) . This git repo is avaiable at https://github.com/hasura/quickatart-git .

clone git-push-template repository

i) changed the current working directory to my project directory

i.e. E:/Politics/quickstart-docker-git/nodejs-express> and initialise this local directory as a Git directory by run

E:/Politics/quickstart-docker-git/nodejs-express> git init <enter>

This initialised empty Git repository in

E:/Politics/quickstart-docker-git/nodejs-express/.git/

ii) Added all the files of nodejs-express in this new local Git repository by running

E:/Politics/quickstart-docker-git/nodejs-express> git add . <enter>

NOTE : the dot ‘.’ After add in the above command is very essential to add ALL the files.

iii) Add the remote (my webapp’s git ) repository in this local git repository by running

E:/Politics/quickstart-docker-git/nodejs-express> git remote add hasura ssh://hasura@app.shoddily49.hasura.app.io/~/git/app/<enter>

(NOTE: This also creates an alias ‘hasura’ for the git repository of my ssh://hasura@app.shoddily49.hasura.app.io/~/git/app/

Completing the setup of Hasura infrastructure

iv) Finally to send our server.js file from my working directory nodejs-express , we run the following command which builds, containerises and deploys this code in the server container

E:/Politics/quickstart-docker-git/nodejs-express> git push hasura master <enter>

With this my Politics app goes live !!

Problem which was I face in this phase:

I have faced an error while executing ‘git push hasura master’.

An error solved by running ‘git commit -m “initial commit”’ and then execute ‘git push hasura master’ which was suggested by @shark(Mr. Arpit Kushwaha) an Enginner at Hasura.

I am thankful to one of the Hasura intern Dhruv Modi for his blog which is really help me to go through the whole process.

Please give suggestions to improve the blog.