Before You Begin
This 10-minute tutorial shows you how to create a basic Go application and how to deploy it to Oracle Application Container Cloud Service.
Background
Oracle Application Container Cloud Service lets you deploy Go, Java Platform, Standard Edition (Java SE), Node.js, PHP, Python, Ruby, and Enterprise Edition (Java EE) applications to the Oracle Cloud.
What Do You Need?
An Oracle Cloud account with access to Oracle Application Container Cloud Service
Create a Go Application
- Create the
go-service
project directory in your local system. - In the
go-service
directory, create therest-service.go
file and add the following content:package main import ("github.com/ant0ine/go-json-rest/rest" "log" "net/http" "os") func main() { api := rest.NewApi() api.Use(rest.DefaultDevStack...) api.SetApp(rest.AppSimple(func(w rest.ResponseWriter, r *rest.Request) { w.WriteJson(map[string]string{"Body": "Hello World!"}) })) log.Fatal(http.ListenAndServe(":"+os.Getenv("PORT"), api.MakeHandler())) }
Prepare the Application to Cloud Deployment
- In the
go-service
directory, create thestart.sh
script file and add the following content:go get github.com/ant0ine/go-json-rest/rest go run rest-service.go
Note: If you're using Windows to create this file, then make sure you convert line endings (EOL) to Unix format.
- In the same directory, create the
manifest.json
file and add the following content:{ "runtime": { "majorVersion": "1.8.3" }, "command": "sh ./start.sh", "notes": "Go Application Sample" }
- Create a
.zip
file with the contents of thego-service
directory.
Deploy Your Application to Oracle Application Container Cloud Service
- Open the Oracle Application Container Cloud Service console.
- In the Applications list view, click Create Application and select Go.
- In the Application section, enter a name for your application and click Browse.
- On the File Upload dialog box, select the
.zip
file you created in the previous section and click Open. - Keep the default values in the Instances and Memory fields and click Create.
- Wait until the application is created. The URL is enabled when the creation is completed.
- Click the URL of your application.
Want to Learn More?
Connect Go to Oracle Database Cloud Service