Skip to content

Latest commit

 

History

History
110 lines (72 loc) · 3.76 KB

InstallAndGo.md

File metadata and controls

110 lines (72 loc) · 3.76 KB

installAndGo

Let's see how to get started with goCamelCase!

If you do not have Go installed, this is a good place to start.
You can set $GOROOT as an environment variable to your $HOME/go path, as:

$ export GOROOT=$HOME/go
$ echo GOROOT

When you are all set to Go, lets download the github repo. Type the following commands in bash.

$ cd $GOROOT/src/
$ go get github.com/mugdhabondre/goCamelCase
$ cd github.com/mugdhabondre/goCamelCase

This will install the repo at $GOROOT/src/github.com/mugdhabondre/goCamelCase on your computer.

Setting up Oxford Dictionary API credentials

The application requires Oxford Dictionaries API credentials. You can create an account on Oxford Dictionaries website.
Create a new file ./credentials.json in the current directory and paste these credentials - app_id and app_key in json format. A sample can be found here

Lets build it

The repository contains a build script. Run it in bash as follows to build all the src files:

$ ./build.sh

This will create a new build folder and executable ./build/camelcaseapp.

Deploy

Lets deploy the service on localhost. Run the following command in bash:

$ build/camelcaseapp
Server started .....
Listen serve for port...  3006

By default the http server listens at port number 3006.
You can go to http://localhost:3006 to view the homepage of the application.

localDeployHome

Lets try requesting for camelCase on a string. Enter the following url:
http://localhost:3006/camelcase/gameofthrones

You will see an output like:

localDeployCamelCase

Deploy in Docker

Now lets try to deploy our solution in a container, so that we can deploy the container on Azure.

Create a docker hub account if you dont have one. My username on docker hub is mugdhab and gocamelcase is the image that I want to build.
A Dockerfile is included in this repo which creates an image from Alpine Linux.
Build a container image as follows and try to run it locally:

$ env GOOS="linux" GOARCH="amd64" ./build.sh
$ docker build -t mugdhab/gocamelcase .
$ docker run -p 5005:80 --env PORT=80 mugdhab/gocamelcase:latest 

You can access the application at http://localhost:5005/ .

dockerDeployCamelCase

Lets publish the image. on docker hub:

$ docker login
$ docker push mugdhab/gocamelcase:latest

Now we can access this image in the docker hub repo and use it for our Azure app!

Deploy in Azure

I followed this article to deploy this application in Azure.

# to Azure Portal and open cloud shell button to open a cloud PowerShell.

Type the following commands to create the application:

$ az group create --name AzureGoRG --location "South Central US"
$ az appservice plan create --name AzureGoSP --resource-group AzureGoRG --sku S1 --is-linux
$ az webapp create --resource-group AzureGoRG --plan AzureGoSP  --name camelcasegenerator --deployment-container-image-name mugdhab/gocamelcase:latest

The application will be visible under AppServices Blade:

azureApp

Now the application will be available @ https://camelcasegenerator.azurewebsites.net/. Yay!

azureDeployHome

azureDeployCamelCase