As a software developer or a software development team, the most important thing for you is building quality software, shipping it and getting feedback from your customers.
Usually the teams have to rely on DevOps engineers or on the DevOps expertise of their developers to build their platform which is extremely time consuming, frustrating, and expensive.
Utopiops (utopiops.com) is a zero DevOps platform that aims to solve the problem uniquely by giving you a complete ecosystem that supports your entire platform from build, deployment and hosting of your applications to monitoring the platform, incident reports and integrations with issue tracking systems, all without any DevOps experience.
Utopiops also supports Fully-managed and Managed applications/services. The Fully-managed applications are hosted on Utopiops cloud platform, while Managed applications are hosted on your own cloud accounts.
In his post I show you how to host your applications using Fully-managed applications on Utopiops. For this tutorial, we use the hobby plan that Utopiops is providing by default to every account and doesn't require a credit card.
To do so, I have implemented a simple go API with gin framework along with a two stage Dockerfile.
Let's start with initializing the module with go mod init <module name>
command:
go mod init go-gin-utopiops-example
Next, we implement a very basic API in our main.go
file:
package main
import (
"os"
"github.com/gin-gonic/gin"
)
func main() {
port := os.Getenv("PORT")
if port == "" {
port = "8080"
}
r := gin.Default()
r.GET("/ping", func(c *gin.Context) {
c.JSON(200, gin.H{
"message": "pong",
})
})
// A publicly open (no authorization) endpoint to verify the health of the application
// Here it always returns 200, but in real cases it should properly indicate if the application is actually healthy or not
r.GET("/health", func(c *gin.Context) {
c.String(200, "Healthy")
})
r.Run(":" + port)
}
Our API has two GET endpoints:
-
/ping
which simply responds with a json data -
/health
which is later used as the health check endpoint of our application
And this is my Dockerfile:
FROM golang:1.16-alpine AS build
WORKDIR /app
COPY go.mod ./
COPY go.sum ./
RUN go mod download
COPY . .
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o example .
FROM alpine:3.9.5
RUN apk --no-cache add ca-certificates
WORKDIR /root/
COPY --from=build /app/example .
CMD [ "./example" ]
I also always have .dockerignore
file in my repositories so I avoid bloating my docker images with unnecessary or unwanted files.
You can find all these files in the repository here.
Before we begin the deployment you need to create an account on Utopiops if you already haven't done that before, by registering and verifying your email.
Now we create a dockerized
application
Then we choose the repository we have stored our code:
I'm using Github for this example, but you can also use Gitlab and Bitbucket too.
Finally just git your application a name, set the git branch, the port your application is listening on, and an endpoint that can be used as health check. Remember that health-check path is just any endpoint that returns a 2xx response to an unauthorized HTTP GET request.
We also set the PORT as an environment variable.
Right away the built-in CICD on Utopiops is set up and starts building and deploying your application.
You can see the build logs live as they happen:
And in a just few seconds your application is available (for this example it took 3 seconds to be precise)
Notice that by default HTTPS is provided for you application, just the certificate takes a few minutes to be effective, but guess what! We're working on it to reduce that to few seconds as well.
Worth mentioning, any time you make a change to your target branch, the new version of your application is built and deployed right away.
Final note
We're a very young startup with huge goals in our mind. You can be part of the first users who get to know about our features and our journey.
Please join our family by joining our discord channel, and following us on Twitter, and using our service. We have a generous hobby plan!
Please leave a comment if you have any questions or even want to see a private demo!
Top comments (0)