<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Bharat</title>
    <description>The latest articles on DEV Community by Bharat (@bharatv).</description>
    <link>https://dev.to/bharatv</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F9626%2F75532145-95a6-423a-ba1f-7dc3d3144711.png</url>
      <title>DEV Community: Bharat</title>
      <link>https://dev.to/bharatv</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/bharatv"/>
    <language>en</language>
    <item>
      <title>Microservices in Go Lang with Postgres (Local, Docker to Render Public hosting)</title>
      <dc:creator>Bharat</dc:creator>
      <pubDate>Tue, 29 Aug 2023 19:37:18 +0000</pubDate>
      <link>https://dev.to/bharatv/microservices-in-go-lang-with-postgres-local-docker-to-render-public-hosting-2hoi</link>
      <guid>https://dev.to/bharatv/microservices-in-go-lang-with-postgres-local-docker-to-render-public-hosting-2hoi</guid>
      <description>&lt;p&gt;This project will summarize the steps to create a microservice using Golang and Postgresql.&lt;br&gt;
We will be using 4 different data models each implementing CRUD operations.&lt;br&gt;
The structure of the project will be like -&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;internal/database&lt;/code&gt; - This will contain the database connection and the schema and data files.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;internal/models&lt;/code&gt; - This will contain the data models.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;internal/db_errors&lt;/code&gt; - This will contain the error handling for the database.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;internal/server&lt;/code&gt; - This will contain the server and the main function.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Elaborated schema for the project using E-R diagram &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--qGJDpP4Q--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://github.com/bindian0509/microservices-with-golang/assets/346620/906249d8-7b74-4183-aa9d-8e53e94111fe" class="article-body-image-wrapper"&gt;&lt;img alt="E-R Diagram" src="https://res.cloudinary.com/practicaldev/image/fetch/s--qGJDpP4Q--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://github.com/bindian0509/microservices-with-golang/assets/346620/906249d8-7b74-4183-aa9d-8e53e94111fe" width="800" height="633"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The following are dependencies we will be using, along with the steps to run your project locally.&lt;/p&gt;

&lt;p&gt;Link to my github repo for the code - &lt;a href="https://github.com/bindian0509/microservices-with-golang" rel="noopener noreferrer"&gt;https://github.com/bindian0509/microservices-with-golang&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Pre-requisites (for mac OS ventura)
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Install httpie (&lt;a href="https://httpie.org/" rel="noopener noreferrer"&gt;https://httpie.org/&lt;/a&gt;) for testing the API

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;brew install httpie&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Install docker (&lt;a href="https://docs.docker.com/docker-for-mac/install/" rel="noopener noreferrer"&gt;https://docs.docker.com/docker-for-mac/install/&lt;/a&gt;)

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;brew cask install docker&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;VScode with Go extension (&lt;a href="https://code.visualstudio.com/docs/languages/go" rel="noopener noreferrer"&gt;https://code.visualstudio.com/docs/languages/go&lt;/a&gt;)

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;brew cask install visual-studio-code&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Install golang (&lt;a href="https://golang.org/doc/install" rel="noopener noreferrer"&gt;https://golang.org/doc/install&lt;/a&gt;)

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;brew install go&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  Use getting started for creating Postgres container
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Create a dir in your home folder called &lt;code&gt;data-postgres-go&lt;/code&gt; under &lt;code&gt;docker-vols&lt;/code&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;mkdir -p ~/docker-vols/data-postgres-go&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Create a postgres container&lt;br&gt;
&lt;/p&gt;

&lt;pre class="highlight shell"&gt;&lt;code&gt;docker run &lt;span class="nt"&gt;-d&lt;/span&gt; &lt;span class="nt"&gt;--rm&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;--name&lt;/span&gt; local-pg &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;-e&lt;/span&gt; &lt;span class="nv"&gt;POSTGRES_PASSWORD&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;postgres &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;-p&lt;/span&gt; 5432:5432 &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;-e&lt;/span&gt; &lt;span class="nv"&gt;PGDATA&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/var/lib/postgresql/data/pgdata &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;-v&lt;/span&gt; /Users/&amp;lt;user-name&amp;gt;/docker-vols/data-postgres-go:/var/lib/postgresql/data &lt;span class="se"&gt;\&lt;/span&gt;
postgres
&lt;/code&gt;&lt;/pre&gt;




&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;Login via psql&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;docker exec -it local-pg psql -U postgres&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;Create database schema via schema.sql&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;psql -U postgres -f schema.sql&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;Insert data to the database via data.sql&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;psql -U postgres -f data.sql&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;h2&gt;
  
  
  Setting up the go project
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Create a directory called &lt;code&gt;microservices-with-golang&lt;/code&gt; in your home folder

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;mkdir -p ~/microservices-with-golang&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;cd ~/microservices-with-golang&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;Use go mod init to create a go module

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;go mod init github.com/&amp;lt;github-username&amp;gt;/microservices-with-golang&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;Use go mod tidy to download the dependencies

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;go mod tidy&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;To start the project run

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;go run main.go&lt;/code&gt;
voila you have your project up and running
&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;   ____    __
  / __/___/ /  ___
 / _// __/ _ &lt;span class="se"&gt;\/&lt;/span&gt; _ &lt;span class="se"&gt;\&lt;/span&gt;
/___/&lt;span class="se"&gt;\_&lt;/span&gt;_/_//_/&lt;span class="se"&gt;\_&lt;/span&gt;__/ v4.11.1
High performance, minimalist Go web framework
https://echo.labstack.com
____________________________________O/_______
                                    O&lt;span class="se"&gt;\&lt;/span&gt;
⇨ http server started on &lt;span class="o"&gt;[&lt;/span&gt;::]:8080
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Testing Microservices
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Checking the database connection and liveness probe
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;To start the server

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;go run main.go&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;To check everything is working fine

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;http :8080/readiness&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;http :8080/liveness&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;Expected output
&lt;/li&gt;

&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;    HTTP/1.1 200 OK
    Content-Length: 16
    Content-Type: application/json&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nv"&gt;charset&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;UTF-8
    Date: Tue, 22 Aug 2023 11:30:52 GMT

    &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="s2"&gt;"status"&lt;/span&gt;: &lt;span class="s2"&gt;"OK"&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Testing Get All customer API endpoint (GET)
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;To get all customers

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;http :8080/customers&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="o"&gt;[&lt;/span&gt;
    &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="s2"&gt;"address"&lt;/span&gt;: &lt;span class="s2"&gt;"556 Lakewood Park, Bismarck, ND 58505"&lt;/span&gt;,
        &lt;span class="s2"&gt;"customerId"&lt;/span&gt;: &lt;span class="s2"&gt;"e2579031-41f8-4c1b-851d-d05dd0327230"&lt;/span&gt;,
        &lt;span class="s2"&gt;"emailAddress"&lt;/span&gt;: &lt;span class="s2"&gt;"penatibus.et@lectusa.com"&lt;/span&gt;,
        &lt;span class="s2"&gt;"firstName"&lt;/span&gt;: &lt;span class="s2"&gt;"Cally"&lt;/span&gt;,
        &lt;span class="s2"&gt;"lastName"&lt;/span&gt;: &lt;span class="s2"&gt;"Reynolds"&lt;/span&gt;,
        &lt;span class="s2"&gt;"phoneNumber"&lt;/span&gt;: &lt;span class="s2"&gt;"(901) 166-8355"&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;,
    &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="s2"&gt;"address"&lt;/span&gt;: &lt;span class="s2"&gt;"4829 Badeau Parkway, Chattanooga, TN 37405"&lt;/span&gt;,
        &lt;span class="s2"&gt;"customerId"&lt;/span&gt;: &lt;span class="s2"&gt;"8db81915-7955-47ac-abf1-fa3a3f27e0a3"&lt;/span&gt;,
        &lt;span class="s2"&gt;"emailAddress"&lt;/span&gt;: &lt;span class="s2"&gt;"nibh@ultricesposuere.edu"&lt;/span&gt;,
        &lt;span class="s2"&gt;"firstName"&lt;/span&gt;: &lt;span class="s2"&gt;"Sydney"&lt;/span&gt;,
        &lt;span class="s2"&gt;"lastName"&lt;/span&gt;: &lt;span class="s2"&gt;"Bartlett"&lt;/span&gt;,
        &lt;span class="s2"&gt;"phoneNumber"&lt;/span&gt;: &lt;span class="s2"&gt;"(982) 231-7357"&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;,
    ...
&lt;span class="o"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;To get customer from emailAddress (search API) (GET)

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;http :8080/customers emailAddress=="magna.Phasellus@Phasellus.net"&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;HTTP/1.1 200 OK
Content-Length: 223
Content-Type: application/json&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nv"&gt;charset&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;UTF-8
Date: Tue, 22 Aug 2023 13:26:37 GMT

&lt;span class="o"&gt;[&lt;/span&gt;
    &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="s2"&gt;"address"&lt;/span&gt;: &lt;span class="s2"&gt;"602 Sommers Parkway, Norfolk, VA 23520"&lt;/span&gt;,
        &lt;span class="s2"&gt;"customerId"&lt;/span&gt;: &lt;span class="s2"&gt;"44f82d9d-b0a6-49b2-ac04-cb05b4cbf189"&lt;/span&gt;,
        &lt;span class="s2"&gt;"emailAddress"&lt;/span&gt;: &lt;span class="s2"&gt;"magna.Phasellus@Phasellus.net"&lt;/span&gt;,
        &lt;span class="s2"&gt;"firstName"&lt;/span&gt;: &lt;span class="s2"&gt;"Brock"&lt;/span&gt;,
        &lt;span class="s2"&gt;"lastName"&lt;/span&gt;: &lt;span class="s2"&gt;"Case"&lt;/span&gt;,
        &lt;span class="s2"&gt;"phoneNumber"&lt;/span&gt;: &lt;span class="s2"&gt;"(544) 534-1984"&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Testing create customer API endpoint (POST)
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;To create a new customer

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;http POST :8080/customers firstName=John lastName=Reese emailAddress="john@root.com" phoneNumber="515-555-1235" address="36 ChinaTown, Borivali East, Mumbi, MH, INDIA"&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;    HTTP/1.1 201 Created
    Content-Length: 210
    Content-Type: application/json&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nv"&gt;charset&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;UTF-8
    Date: Tue, 22 Aug 2023 18:28:38 GMT

    &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="s2"&gt;"address"&lt;/span&gt;: &lt;span class="s2"&gt;"36 ChinaTown, Borivali East, Mumbi, MH, INDIA"&lt;/span&gt;,
        &lt;span class="s2"&gt;"customerId"&lt;/span&gt;: &lt;span class="s2"&gt;"68fb0b27-1e9a-4ce8-81ac-f41cc1e3f5d6"&lt;/span&gt;,
        &lt;span class="s2"&gt;"emailAddress"&lt;/span&gt;: &lt;span class="s2"&gt;"john@root.com"&lt;/span&gt;,
        &lt;span class="s2"&gt;"firstName"&lt;/span&gt;: &lt;span class="s2"&gt;"John"&lt;/span&gt;,
        &lt;span class="s2"&gt;"lastName"&lt;/span&gt;: &lt;span class="s2"&gt;"Reese"&lt;/span&gt;,
        &lt;span class="s2"&gt;"phoneNumber"&lt;/span&gt;: &lt;span class="s2"&gt;"515-555-1235"&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Testing Get customer from Id API endpoint (GET)
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;To get customer with &lt;code&gt;customerId&lt;/code&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;http :8080/customers/8db81915-7955-47ac-abf1-fa3a3f27e0a3&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;    HTTP/1.1 200 OK
    Content-Length: 225
    Content-Type: application/json&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nv"&gt;charset&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;UTF-8
    Date: Wed, 23 Aug 2023 11:10:49 GMT

    &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="s2"&gt;"address"&lt;/span&gt;: &lt;span class="s2"&gt;"4829 Badeau Parkway, Chattanooga, TN 37405"&lt;/span&gt;,
        &lt;span class="s2"&gt;"customerId"&lt;/span&gt;: &lt;span class="s2"&gt;"8db81915-7955-47ac-abf1-fa3a3f27e0a3"&lt;/span&gt;,
        &lt;span class="s2"&gt;"emailAddress"&lt;/span&gt;: &lt;span class="s2"&gt;"nibh@ultricesposuere.edu"&lt;/span&gt;,
        &lt;span class="s2"&gt;"firstName"&lt;/span&gt;: &lt;span class="s2"&gt;"Sydney"&lt;/span&gt;,
        &lt;span class="s2"&gt;"lastName"&lt;/span&gt;: &lt;span class="s2"&gt;"Bartlett"&lt;/span&gt;,
        &lt;span class="s2"&gt;"phoneNumber"&lt;/span&gt;: &lt;span class="s2"&gt;"(982) 231-7357"&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Testing Update customer API endpoint (PUT)
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;To update customer with &lt;code&gt;customerId&lt;/code&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;http PUT :8080/customers/e2579031-41f8-4c1b-851d-d05dd0327230 address="556 Lakewood Park, Bismarck, ND 58505" customerId="e2579031-41f8-4c1b-851d-d05dd0327230" emailAddress="penatibus.et@lectusa.com" firstName="Ryan" lastName="Reynolds" phoneNumber="(901) 166-8355"&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;    HTTP/1.1 200 OK
    Content-Length: 218
    Content-Type: application/json&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nv"&gt;charset&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;UTF-8
    Date: Fri, 25 Aug 2023 19:04:49 GMT

    &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="s2"&gt;"address"&lt;/span&gt;: &lt;span class="s2"&gt;"556 Lakewood Park, Bismarck, ND 58505"&lt;/span&gt;,
        &lt;span class="s2"&gt;"customerId"&lt;/span&gt;: &lt;span class="s2"&gt;"e2579031-41f8-4c1b-851d-d05dd0327230"&lt;/span&gt;,
        &lt;span class="s2"&gt;"emailAddress"&lt;/span&gt;: &lt;span class="s2"&gt;"penatibus.et@lectusa.com"&lt;/span&gt;,
        &lt;span class="s2"&gt;"firstName"&lt;/span&gt;: &lt;span class="s2"&gt;"Ryan"&lt;/span&gt;,
        &lt;span class="s2"&gt;"lastName"&lt;/span&gt;: &lt;span class="s2"&gt;"Reynolds"&lt;/span&gt;,
        &lt;span class="s2"&gt;"phoneNumber"&lt;/span&gt;: &lt;span class="s2"&gt;"(901) 166-8355"&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Testing Delete customer API endpoint (DELETE)
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;To update customer with &lt;code&gt;customerId&lt;/code&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;http DELETE :8080/customers/8db81915-7955-47ac-abf1-fa3a3f27e0a3&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;    HTTP/1.1 205 Reset Content
    Content-Length: 0
    Date: Fri, 25 Aug 2023 19:31:23 GMT
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Running the same project with docker image (using Dockerfile)
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Step 1: Build the docker image for the application

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;docker build -t microservices-with-golang .&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;Step 2: Run the docker image

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;docker run -e env=docker --env-file db.docker.env --network host --name microservices-with-golang-app microservices-with-golang&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;Step 3: Since this container is not exposed to outside world we can login inside it and test the API

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;docker exec -it microservices-with-golang-app sh&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;http :8080/liveness&lt;/code&gt; (this will work fine since the docker file already has apk add httpie)&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;h2&gt;
  
  
  Production release of the application using &lt;a href="https://render.com/" rel="noopener noreferrer"&gt;Render.com&lt;/a&gt; free tiers
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Sign up for render.com using github or other options&lt;/li&gt;
&lt;li&gt;At first we need to spinup a database service (PostgreSQL)

&lt;ul&gt;
&lt;li&gt;Click on create a new database&lt;/li&gt;
&lt;li&gt;Select the free tier&lt;/li&gt;
&lt;li&gt;Select the region&lt;/li&gt;
&lt;li&gt;Select the database name&lt;/li&gt;
&lt;li&gt;Select the database password&lt;/li&gt;
&lt;li&gt;Click on create database&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;Use psql command option to be copied and dump the files to prod db via following commands

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;PGPASSWORD=&amp;lt;your-db-password&amp;gt; psql -h xxx-a.singapore-postgres.render.com -U &amp;lt;user_name&amp;gt; &amp;lt;db_name&amp;gt; &amp;lt; schema.sql&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;PGPASSWORD=&amp;lt;your-db-password&amp;gt; psql -h xxx-a.singapore-postgres.render.com -U &amp;lt;user_name&amp;gt; &amp;lt;db_name&amp;gt; &amp;lt; data.sql&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;Create a new web service

&lt;ul&gt;
&lt;li&gt;Select the github repo&lt;/li&gt;
&lt;li&gt;Select the branch&lt;/li&gt;
&lt;li&gt;Select the docker file path&lt;/li&gt;
&lt;li&gt;Select the port&lt;/li&gt;
&lt;li&gt;Select the environment variables

&lt;ul&gt;
&lt;li&gt;Refer to &lt;code&gt;db.env&lt;/code&gt; file for list of args&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;sslmode=require&lt;/code&gt; is for production db cluster&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;Select the free tier&lt;/li&gt;

&lt;li&gt;Click on create web service&lt;/li&gt;

&lt;/ul&gt;

&lt;/li&gt;

&lt;li&gt;Once the web service is created you can see the logs and the application running on the url provided by render.com

&lt;ul&gt;
&lt;li&gt;My cluster &lt;a href="https://microservices-with-golang.onrender.com/liveness" rel="noopener noreferrer"&gt;https://microservices-with-golang.onrender.com/liveness&lt;/a&gt; (liveness probe)&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

</description>
    </item>
  </channel>
</rss>
