Oracle Developers
Published in

Oracle Developers

Quickie: deploy a Go web app on Oracle Cloud

Here is a (really quick!) quick start to get going with a dead simple Golang web app (with the Beego framework) on Oracle Application Container Cloud

You can also check out a previous blog using Golang on Oracle Application Container Cloud with Event Hub (Kafka) and MySQL cloud

the nitty gritty…

Here is the code on Github

To be honest, there is hardly anything to speak of as far as the code is concerned.. All we do is create a new Beego project using bee tool and run it — all the heavy lifting is done in a start up script!

start.sh

go get github.com/astaxie/beego
echo "got beego"
go get github.com/beego/bee
echo "bee tool installed"
bee new accsbeego
echo "new project bootstrapped!"
cd src/accsbeego
sed -i -e ‘s/8080/$PORT/g’ conf/app.conf
echo "updated conf to pick up PORT from container"
bee run
  • beego and bee tool dependencies are pulled
  • bootstrap a new beego project (using bee new)
  • modify the (auto generated) app.conf file to replace 8080 with $PORT (with the sed command)
appname = accsbeego
httpport = $PORT //defaulted to 8080 before modification
runmode = dev

deployment.json

{
"memory": "1G",
"instances": 1,
"environment": {
"GOPATH”: "$GOPATH:$APP_HOME",
"PATH": "$PATH:$GOPATH/bin"
}
}

We make sure that

  • we point GOPATH to the location which App Container Cloud uses to store the artifacts i.e. refrenced by the APP_HOME environment variable
  • we tweak the PATH to include the previously installed bee tool
  • .. and the topology — in this case its 1 instance with 1 GB memory

manifest.json

We just invoke our startup script and specify the Golang version (1.8.3 in this case)

{
"runtime": {
"majorVersion": "1.8.3"
},
"command": "sh start.sh",
"notes": "ACCS Beego quickstart"
}

Deploy to cloud

Before you begin…

Zip file — the deployment artifact

With Oracle Application Container Cloud, you have multiple options in terms of deploying your applications. This blog will demonstrate the console as well as PSM CLI (which is a powerful command line interface for managing Oracle Cloud services)

other deployment options include REST API, Oracle Developer Cloud

Use the console

Navigate to the main page in Oracle Application Container Cloud and click Create Application to get started

Landing page

Choose the runtime — Go

Go runtime

Provide details

  • app name
  • upload archive (zip) file and deployment.json
App details

Click Create

Create to start

Use PaaS Service Manager CLI

Download and setup PSM CLI on your machine (using psm setup) — details here

deploy the applicationpsm accs push -n ACCSGoBeegoSample -r golang -e dockerhub -s hourly -d deployment.json -p accs-beego.zip

Note that

  • we reference the zip file (using -p) and the deployment descriptors (-d)
  • include the runtime name (-r golang) and the fact that its sourced from Docker Hub (with -e dockerhub)

That’s it — the app creation should get initiated !

Golang web app on Oracle Application Container Cloud

.. and you can see it’s details once the deployment completes

Successfully deployed

Check out your application

Click on the application URL and it should lead you to the app home page

Ok that wasn’t ground breaking, but look at the bright side — you now have a Golang web app running on Oracle Application Container Cloud!

Don’t forget to…

  • check out the tutorials for Oracle Application Container Cloud — there is something for every runtime!
  • other blogs on Application Container Cloud

Cheers!

The views expressed in this post are my own and do not necessarily reflect the views of Oracle.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Abhishek Gupta

Abhishek Gupta

2K Followers

Principal Developer Advocate at AWS | I ❤️ Databases, Go, Kubernetes