<?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: Amarjit Yanglem</title>
    <description>The latest articles on DEV Community by Amarjit Yanglem (@amarjit).</description>
    <link>https://dev.to/amarjit</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%2F684371%2F25076b33-11b3-4405-b51b-9a70f7c3dfb3.png</url>
      <title>DEV Community: Amarjit Yanglem</title>
      <link>https://dev.to/amarjit</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/amarjit"/>
    <language>en</language>
    <item>
      <title>gRPC and Go: Building High-Performance Web Services</title>
      <dc:creator>Amarjit Yanglem</dc:creator>
      <pubDate>Mon, 30 Sep 2024 10:08:37 +0000</pubDate>
      <link>https://dev.to/amarjit/grpc-and-go-building-high-performance-web-services-5ea6</link>
      <guid>https://dev.to/amarjit/grpc-and-go-building-high-performance-web-services-5ea6</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;In the world of microservices and distributed systems, efficient communication between services is crucial. This is where gRPC, a high-performance RPC (Remote Procedure Call) framework developed by Google, comes into play. Combined with Go, a statically typed, compiled programming language designed for simplicity and efficiency, gRPC can help you build robust and scalable web services.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is gRPC?
&lt;/h2&gt;

&lt;p&gt;gRPC stands for &lt;strong&gt;g&lt;/strong&gt;oogle &lt;strong&gt;R&lt;/strong&gt;emote &lt;strong&gt;P&lt;/strong&gt;rocedure &lt;strong&gt;C&lt;/strong&gt;all. &lt;a href="https://grpc.io/docs/languages/go/basics/" rel="noopener noreferrer"&gt;It is an open-source framework that uses HTTP/2 for transport, Protocol Buffers as the interface description language, and provides features such as authentication, load balancing, and more&lt;/a&gt;. gRPC allows you to define your service methods and message types in a &lt;code&gt;.proto&lt;/code&gt; file, which can then be used to generate client and server code in multiple languages.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Use gRPC with Go?
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Performance&lt;/strong&gt;: gRPC uses HTTP/2, which allows for multiplexing multiple requests over a single connection, reducing latency and improving performance.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Code Generation&lt;/strong&gt;: With Protocol Buffers, you can define your service once and generate client and server code in Go, ensuring consistency and reducing boilerplate code.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Streaming&lt;/strong&gt;: gRPC supports client-side, server-side, and bidirectional streaming, making it ideal for real-time applications.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Interoperability&lt;/strong&gt;: gRPC services can be consumed by clients written in different languages, making it a versatile choice for polyglot environments.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Getting Started with gRPC in Go
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;### Prerequisites&lt;/p&gt;

&lt;p&gt;Before you start, ensure you have the following installed:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  Go (any of the two latest major releases)&lt;/li&gt;
&lt;li&gt;  Protocol Buffer Compiler (&lt;code&gt;protoc&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;  Go plugins for the Protocol Buffer Compiler&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You can install the Go plugins using the following commands:&lt;br&gt;
&lt;/p&gt;

&lt;pre class="highlight plaintext"&gt;&lt;code&gt;go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest
&lt;/code&gt;&lt;/pre&gt;



&lt;p&gt;Update your &lt;code&gt;PATH&lt;/code&gt; so that the &lt;code&gt;protoc&lt;/code&gt; compiler can find the plugins:&lt;br&gt;
&lt;/p&gt;

&lt;pre class="highlight plaintext"&gt;&lt;code&gt;export PATH="$PATH:$(go env GOPATH)/bin"
&lt;/code&gt;&lt;/pre&gt;



&lt;p&gt;Confirm that &lt;code&gt;protoc&lt;/code&gt; is installed and configured in your system by opening a terminal and typing:&lt;br&gt;
&lt;/p&gt;

&lt;pre class="highlight plaintext"&gt;&lt;code&gt;protoc --version
&lt;/code&gt;&lt;/pre&gt;



&lt;p&gt;You should see an output similar to this&lt;br&gt;
&lt;/p&gt;

&lt;pre class="highlight plaintext"&gt;&lt;code&gt;C:\Users\Guest&amp;gt;protoc --version
~ libprotoc 27.3
&lt;/code&gt;&lt;/pre&gt;



&lt;p&gt;If it doesn't recognize the &lt;code&gt;protoc&lt;/code&gt; command, then you can use &lt;code&gt;Chocolatey&lt;/code&gt; for windows to install the protocol buffers:&lt;br&gt;
&lt;/p&gt;

&lt;pre class="highlight plaintext"&gt;&lt;code&gt;choco install protoc
&lt;/code&gt;&lt;/pre&gt;



&lt;p&gt;If this isn't the case, where you don't have chocolatey installed or you're on a different OS, you can go through the official installation documentation &lt;a href="https://grpc.io/docs/protoc-installation/" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Defining the Service
&lt;/h3&gt;

&lt;p&gt;Create a &lt;code&gt;.proto&lt;/code&gt; file to define your gRPC service. For example:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;helloworld.proto&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;pre class="highlight plaintext"&gt;&lt;code&gt;syntax = "proto3";
package helloworld;

message HelloRequest {
    string name = 1;
}
message HelloResponse {
    string message = 1;
}

service Greeter {
    rpc SayHello (HelloRequest) returns (HelloResponse) {}
}
&lt;/code&gt;&lt;/pre&gt;



&lt;h3&gt;
  
  
  Generating Code
&lt;/h3&gt;

&lt;p&gt;Generate the Go code from your &lt;code&gt;.proto&lt;/code&gt; file:&lt;br&gt;
&lt;/p&gt;

&lt;pre class="highlight plaintext"&gt;&lt;code&gt;protoc --go_out=. --go-grpc_out=. helloworld.proto
&lt;/code&gt;&lt;/pre&gt;



&lt;h3&gt;
  
  
  Implementing the Server
&lt;/h3&gt;

&lt;p&gt;Create a server in Go:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;server.go&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package main

import (
    "context"
    "log"
    "net"

    "google.golang.org/grpc"
    pb "path/to/your/proto"
)

type server struct {
    pb.GreeterServer
}

func main() {
    lis, err := net.Listen("tcp", ":8080")
    if err != nil {
        log.Fatalf("failed to listen: %v", err)
    }

    log.Printf("Server started at %v", lis.Addr())

    grpcServer := grpc.NewServer()
    pb.RegisterGreeterServer(grpcServer, &amp;amp;server{})
    if err := grpcServer.Serve(lis); err != nil {
        log.Fatalf("failed to serve: %v", err)
    }
}

// SayHello name should be the same RPC name as defined in your proto file
func (s *server) SayHello(ctx context.Context, in *pb.HelloRequest) (*pb.HelloResponse, error) {
    return &amp;amp;pb.HelloResponse{Message: "Hello " + in.Name}, nil
}
&lt;/code&gt;&lt;/pre&gt;



&lt;h3&gt;
  
  
  Creating the Client
&lt;/h3&gt;

&lt;p&gt;Create a client in Go:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;client.go&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package main

import (
    "context"
    "log"
    "os"
    "time"

    "google.golang.org/grpc"
    pb "path/to/your/proto"
)

func main() {
    conn, err := grpc.NewClient("localhost:8080", grpc.WithTransportCredentials(insecure.NewCredentials()))
    if err != nil {
        log.Fatalf("did not connect: %v", err)
    }
    defer conn.Close()
    client := pb.NewGreeterClient(conn)

    name := "John Doe"
    if len(os.Args) &amp;gt; 1 {
        name = os.Args[1]
    }

    callSayHello( client, name )
}

func callSayHello(client pb.GrpcServiceClient, name string) {
    ctx, cancel := context.WithTimeout(context.Background(), time.Second)
    defer cancel()

    res, err := client.SayHello(ctx, &amp;amp;pb.HelloRequest{Name: name})
    if err != nil {
        log.Fatalf("Failed to called: %v", err)
    }
    log.Printf("%v", res)
}
&lt;/code&gt;&lt;/pre&gt;




&lt;/li&gt;

&lt;/ul&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;gRPC and Go together provide a powerful combination for building high-performance, scalable web services. By leveraging the strengths of both, you can create efficient and reliable applications that are easy to maintain and extend.&lt;/p&gt;

&lt;p&gt;Link to demo repo: &lt;a href="https://github.com/Aamjit/go-and-grpc" rel="noopener noreferrer"&gt;Github.com&lt;/a&gt;&lt;/p&gt;

</description>
      <category>go</category>
      <category>grpc</category>
      <category>microservices</category>
      <category>rpc</category>
    </item>
    <item>
      <title>Deploy your SAP CAP application to any Hosting site</title>
      <dc:creator>Amarjit Yanglem</dc:creator>
      <pubDate>Thu, 01 Aug 2024 09:30:50 +0000</pubDate>
      <link>https://dev.to/amarjit/deploy-your-sap-cap-application-to-any-hosting-site-4l4h</link>
      <guid>https://dev.to/amarjit/deploy-your-sap-cap-application-to-any-hosting-site-4l4h</guid>
      <description>&lt;p&gt;Greetings Readers,&lt;/p&gt;

&lt;p&gt;Today, I'm gonna share on how to deploy an SAP CAP project to any hosting platform by making use of Docker Images.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Readme: Currently I do not have a working solution for deploying it directly without a Docker image, I run into issues while deploying using node. My suggestion is to go with a Docker image, unless you're deploying it to BTP Cockpit.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Intro to CAPM(Cloud Application Programming Model)
&lt;/h2&gt;

&lt;p&gt;In short, CAP is a framework with a bunch of languages, tools and runtimes, it is mostly used for building Enterprise-grade applications and services&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F335bvnnjwvsui2whqjcw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F335bvnnjwvsui2whqjcw.png" alt="CAPM" width="535" height="290"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It is a mixed of SAP Techs and other open source tools like node, and even spring from Java, it allows you to set up your own favorite development environment.&lt;/p&gt;

&lt;p&gt;On top of all this is the main component, the CDS(Core Data Services) which is where we define and serve all our Data models, and manage the views.&lt;/p&gt;

&lt;p&gt;Also let us not forget the Service SDKs for Node or Java which allows us for our favorite language to interact with the CDS environment.&lt;/p&gt;

&lt;h2&gt;
  
  
  How we started
&lt;/h2&gt;

&lt;p&gt;Lets take a step back and find out on how I ended up here with this blogpost.&lt;/p&gt;

&lt;p&gt;It started out as a simple process of learning how to develop CAP App with NodeJS. As usual, how we all go through, I started with their &lt;a href="https://cap.cloud.sap/docs/about/#overview" rel="noopener noreferrer"&gt;official documentation&lt;/a&gt; and read about the most the stuffs like the guides, setup, tools, the SDKs, etc..&lt;/p&gt;

&lt;p&gt;So, after a while, I wanted to start a project, so again, I went through their jumpstart documentation, and continued with learning. I did all the stuffs as documented using sample data. Again, I will not go through the whole process but you can kind of figure out. And BOOM!!! DONE,, I had a sample working project, now I want a way to actually host it online and deploy the webservice.&lt;/p&gt;

&lt;p&gt;I actually had a hosting platform in-mind - &lt;a href="http://render.com" rel="noopener noreferrer"&gt;render.com&lt;/a&gt;, but you can choose other platforms if you already have an account like AWS, Azure, etc.. you can choose which one you like, that's not the important part.&lt;/p&gt;

&lt;p&gt;The important part is how?? How can we deploy our service online??&lt;/p&gt;

&lt;p&gt;You're gonna use this platform to build your project and deploy it online. It sounds easy but a lot of things could go wrong and the host could fail to build your project or deploy it. Let's check out what are some of the things that could go wrong and solve it.&lt;/p&gt;

&lt;h2&gt;
  
  
  First try-(Just raw deploy it)
&lt;/h2&gt;

&lt;p&gt;Let us say you already have sourcing like &lt;a href="http://Github.com" rel="noopener noreferrer"&gt;Github.com&lt;/a&gt; and you have pushed your changes to you repo, next you go to your favorite hosting platform, you create an app/webservice, you link your repo to the hosting app, you deploy it, and done!! CLOSE IT!! ALT+F4!!&lt;/p&gt;

&lt;p&gt;Easy, Right??&lt;/p&gt;

&lt;p&gt;But wait, did it deploy?? Did you check the logs??&lt;/p&gt;

&lt;p&gt;The answer propably is - &lt;em&gt;NO!&lt;/em&gt;. This is what I call "&lt;em&gt;Not being cautious&lt;/em&gt;".&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;The error message probably while deploying would be:&lt;br&gt;
&lt;/p&gt;
&lt;/blockquote&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;==&amp;gt; Running 'npm run start'
&amp;gt; CAP-Node-js@1.0.0 start
&amp;gt; cds serve
sh: 1: cds: not found
==&amp;gt; Exited with status 127
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;There is a reason why it failed, if you realize, in order for our app to start, we run the command &lt;code&gt;cds serve&lt;/code&gt; for production or &lt;code&gt;cds watch&lt;/code&gt; for development, if you weren't aware about this, and you use &lt;code&gt;npm run dev&lt;/code&gt; or &lt;code&gt;npm run start&lt;/code&gt;, that's okay, these are bound to execute &lt;code&gt;cds serve/watch&lt;/code&gt;, which is configured in your &lt;code&gt;package.json&lt;/code&gt; file.&lt;/p&gt;

&lt;p&gt;That means, we're expecting CDS to run our project and serve it, except that there is no CDS in production. Why??&lt;/p&gt;

&lt;p&gt;Once we deploy our app online, our app is actually being run from a virtual system which your cloud provider is using to host your app, and that means that there is a 100% chance that CDS is not installed there.&lt;br&gt;
That is why it couldn't understand CDS command, cause it's not there in the environment system...&lt;/p&gt;

&lt;p&gt;In my case also, I installed the &lt;code&gt;cds-dk&lt;/code&gt; at a global level and couldn't figure out why &lt;code&gt;cds&lt;/code&gt; was not recognized once I deployed and it failed. In short, its a skill issue.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;My suggestion is to use the Second method noted below.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h2&gt;
  
  
  Second Try-(Containerization)
&lt;/h2&gt;

&lt;p&gt;After the first try, I went ahead to try with Docker containers, which was something new to me.&lt;/p&gt;

&lt;p&gt;Let me introduce Docker, the magical toolbox you wish you had when dealing with software applications. It simplifies the entire process of building, running, managing, and distributing applications.&lt;/p&gt;

&lt;p&gt;2 things you need to be aware: Image &amp;amp; Containers.&lt;/p&gt;

&lt;p&gt;Shortest description: Image is your recipe &amp;amp; Container is your prepared dish.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;So, I went for Docker, installed it.&lt;/li&gt;
&lt;li&gt;Installed Devcontainer extension, in vsCode.&lt;/li&gt;
&lt;li&gt;Played around a bit(around 2 days).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I did find a great tutorial in &lt;a href="https://www.youtube.com/playlist?list=PL6RpkC85SLQBHPdfHQ0Ry2TMdsT-muECx" rel="noopener noreferrer"&gt;youtube&lt;/a&gt; for CAP with Node, that's where I discovered, we can use Docker to deploy a CAP app on any system with Docker.&lt;/p&gt;

&lt;p&gt;This requires a bit of Setup which we will go through:&lt;/p&gt;
&lt;h3&gt;
  
  
  Installing Docker
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;We need to install Docker Desktop from the &lt;a href="https://www.docker.com/" rel="noopener noreferrer"&gt;official site&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;We will then configure the &lt;em&gt;Dockerfile&lt;/em&gt; in our CAP project as follows&lt;/li&gt;
&lt;li&gt;We will configure it in our root directory.&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;
  
  
  Dockerfile
&lt;/h4&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# syntax=docker/dockerfile:1

# setting up our operating system
ARG VARIANT="20"
FROM mcr.microsoft.com/vscode/devcontainers/javascript-node:0-${VARIANT}

# Install some generally useful tools particularly for development in devcontainer
RUN apt-get update \
    &amp;amp;&amp;amp; apt-get -y install --no-install-recommends \
    curl git sqlite3 entr source-highlight

# set user node
USER node

# installation of CDS-DK globally inside the container
# You can choose to ignore this command if you are configuring cds-dk within you dependencies
ARG CAPVER="latest"
RUN npm install -g @sap/cds-dk@$CAPVER

# not necessary
# vi mode everywhere and nicer prompt KTHXBAI
RUN cat &amp;lt;&amp;lt;EOBASHRC &amp;gt;&amp;gt; /home/node/.bashrc
export EDITOR=vi
set -o vi
bind -x '"\C-l": clear'
EOBASHRC

RUN echo 'export PS1=${PS1/\$ /\\\\n$ }' &amp;gt;&amp;gt; /home/node/.bashrc

# Go to our directory where we will store our codes
WORKDIR /home/node

# Copy your SAP CAP project files(current path of Dockerfile) into the container path "./home/node/"
COPY . /home/node/

# # # Install dependencies (needed)
# it will neglect the packages for devDependencies
RUN npm install --omit=dev

# Start your CAP application
CMD ["npm", "start"]

# Important for exposing our service
EXPOSE 4004
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h4&gt;
  
  
  .devcontainer.json
&lt;/h4&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
{
    "name": "Our CAP Project",
    "build": {
        "dockerfile": "Dockerfile",
        "args": {
            "VARIANT": "20"
        }
    },
    "customizations": {
        "vscode": {
            "extensions": [
                "sapse.vscode-cds",
                "dbaeumer.vscode-eslint",
                "humao.rest-client",
                "qwtel.sqlite-viewer",
                "mechatroner.rainbow-csv"
            ]
        }
    },
    "forwardPorts": [4004],
    "remoteUser": "node"
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;And lastly, an important file&lt;/p&gt;
&lt;h4&gt;
  
  
  .dockerignore
&lt;/h4&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.vscode
node_modules
package-lock.json
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Why &lt;code&gt;.dockerignore&lt;/code&gt; ?? We only need the necessary files and folders.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;We basically do not need &lt;code&gt;node_modules&lt;/code&gt; as we will be running &lt;code&gt;RUN npm install --omit=dev&lt;/code&gt; from the &lt;code&gt;Dockerfile&lt;/code&gt; and it will automatically generate the modules folder.&lt;/li&gt;
&lt;li&gt;We also don't need &lt;code&gt;package-lock.json&lt;/code&gt; for the same reason.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;.vscode&lt;/code&gt; is only specific to vscode workspace, so remove it while importing.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;.devcontainer&lt;/code&gt; if you have, in your project, remove it, in my case my docker configurations were initially stored there, but I had moved it in root path, you can do the same.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The next thing is to build the image, go to your project root directory where &lt;code&gt;Dockerfile&lt;/code&gt; is present and open a terminal from your local machine:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# example: docker build -t &amp;lt;YOUR_IMAGE_NAME&amp;gt; .
$ docker build -t cap-server .
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once you hit that, docker will build you image from the Dockerfile, which would look something like this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxgc8diwzxfv1ye4vnru1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxgc8diwzxfv1ye4vnru1.png" alt="Docker build log" width="800" height="277"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once that is done, you can then run the following docker cmd&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker run -t cap-server
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It would look something like this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpd6ohggxlryryf15k2kg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpd6ohggxlryryf15k2kg.png" alt="Docker run log" width="730" height="492"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  error: no database connection error
&lt;/h2&gt;

&lt;p&gt;There might be cases where you find that your service is running and when you try to access a route for viewing the data, you get a "no database connection" error, observe and keep in mind that the area which I highlighted above, might/might not appear in your case.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What can you do??&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Go to your &lt;code&gt;package.json&lt;/code&gt; and check if the &lt;code&gt;@cap-js/sqlite&lt;/code&gt; package is installed under dependencies or &lt;code&gt;devDependencies&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;This error usually comes if you had configured the mentioned package installed under &lt;code&gt;devDependencies&lt;/code&gt;, you need to move it under the dependencies object. A simple npm cmd to do that is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install --save-prod @cap-js/sqlite
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This should fix that problem, &lt;/p&gt;

&lt;p&gt;Build the docker and run it again, to check it.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;If all is well, this will should work correctly.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Finally
&lt;/h2&gt;

&lt;p&gt;You can finally save you changes, commit and push to your remote repo.&lt;br&gt;
Re-run the build process on your hosting platform, and keep and eye on the log. Again, if all is well, it should successfully build the app and deploy it.&lt;/p&gt;

&lt;p&gt;There is no guarantee that it will always work perfectly for every person, there are always factors that depend on it. If you run into any issues, there is always a community which you can depend upon. Be sure to check out your issue or post a new one in the &lt;a href="https://community.sap.com/" rel="noopener noreferrer"&gt;SAP Community&lt;/a&gt; or other developers community.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Disclaimer: This post is not auto-generated using AI of any sort. So, this post could contain false information which I missed, or was unaware of, Please let me know if such happens.&lt;/p&gt;
&lt;/blockquote&gt;

</description>
      <category>sap</category>
      <category>cap</category>
      <category>node</category>
      <category>cds</category>
    </item>
    <item>
      <title>Integrate conda in VS code</title>
      <dc:creator>Amarjit Yanglem</dc:creator>
      <pubDate>Tue, 23 Nov 2021 12:08:02 +0000</pubDate>
      <link>https://dev.to/amarjit/integrate-conda-in-vs-code-3hkm</link>
      <guid>https://dev.to/amarjit/integrate-conda-in-vs-code-3hkm</guid>
      <description>&lt;p&gt;First thing is first, make sure you have Python, VS code, Anaconda installed in you system.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Check for the Python version. Run &lt;code&gt;python -V&lt;/code&gt; and find out if it is installed or not.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Do a quick installation of Python extension in VS code.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Go to the Extensions Tab and search for Python&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ff8uihedut8hcbwma0yg1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ff8uihedut8hcbwma0yg1.png" alt="Python extension in VS code" width="800" height="426"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We now need to set the Python interpreter. The thing about Python interpreters are, for different environment that we create, we can set a different interpreter for that particular environment and sometimes this leads to a lot of confusions for beginners. You might install a version of Python and when running inside an environment it uses another version. This could also cause errors when you use a feature available in one version but not in the other.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;We will set up the Python Interpreter first&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Setting up Python Interpreter&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So we have a few ways of setting up Python Interpreter, you can find it in this &lt;a href="https://code.visualstudio.com/docs/python/python-tutorial" rel="noopener noreferrer"&gt;VS code Documentation&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Open the command palette with the shortcut &lt;code&gt;ctrl + shift + P&lt;/code&gt;, inside the input filed type in &lt;code&gt;Python: Select Interpreter&lt;/code&gt; and hit enter. You should see a few or a list of available Interpreters that you have configured as default or have used in other environments.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fuusyo8r27exhoffqo6ma.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fuusyo8r27exhoffqo6ma.png" alt="Python Interpreter lists" width="502" height="260"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As you can see here, we have a list of Interpreters with different versions used. In your system, it may differ and you can choose one you need for your current project.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Another way is clicking on the &lt;code&gt;Select Python Interpreter&lt;/code&gt; icon with the warning sign on the &lt;strong&gt;Bottom Left Corner&lt;/strong&gt; of the windows.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Furodxab1fzv03o5i3a9t.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Furodxab1fzv03o5i3a9t.png" alt="Select Python Interpreter" width="288" height="86"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Another way is manually setting Python executable path in you setting.
To do that, open settings with the shortcut "ctrl + ," and select the &lt;code&gt;Workspace Tab&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Foletmqgri22ltl5k1ofo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Foletmqgri22ltl5k1ofo.png" alt="Workspace Tab" width="800" height="465"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Type in "Python" in the search bar and you should see an option below where you can configure the settings.json file, click on it.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvagkn1p3bn7scb3pizjs.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvagkn1p3bn7scb3pizjs.png" alt="settings.json" width="800" height="477"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;There add the path to the interpreter as follows&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"python.pythonPath": "&amp;lt;path-to-your-interpreter&amp;gt;\\python.exe"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; Adding the above path without selecting the workspace, VS code sets the path to users settings which is default. The workspace allows you to use the interpreter only within your current workspace.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Activating Conda environment&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Navigate inside your Conda installed files directory, there navigate agin in the scripts directory, there you will find an &lt;code&gt;activate.bat&lt;/code&gt; file&lt;/p&gt;

&lt;p&gt;path for &lt;code&gt;activate.bat&lt;/code&gt; file should look something like this&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;C:\\&amp;lt;path-to-conda-installation&amp;gt;\\Scripts\\activate.bat
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The command to start the anaconda prompt in terminal should look something like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;C:\\&amp;lt;path-to-conda-installation&amp;gt;\\Scripts\\activate.bat C:\\&amp;lt;path-to-conda-installation&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will activate the default environment for conda, we can also change the environment&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;conda activate &amp;lt;your-env-name&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We need to change our workspace setting in VS, so that we can run conda commands whenever we start a terminal&lt;/p&gt;

&lt;p&gt;Go to settings [ctrl + ,] then select &lt;strong&gt;workspace section&lt;/strong&gt; . In the search box paste this&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;terminal.integrated.profile.windows
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fs8je18zykm86xq5jv430.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fs8je18zykm86xq5jv430.png" alt="Image description" width="800" height="289"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Go to &lt;code&gt;edit in setting.json&lt;/code&gt; and add the following&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
    "python.pythonPath": "C:\\Users\\user\\Anaconda3\\envs\\django_env\\python.exe",

    "python.terminal.activateEnvironment": true,

    "terminal.integrated.defaultProfile.windows": "Command Prompt"
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now go back to setting and with same search text, go to the &lt;strong&gt;user section&lt;/strong&gt;, Click for &lt;code&gt;edit in settings.json&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdxwo4ouwonnf8h81skqx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdxwo4ouwonnf8h81skqx.png" alt="Image description" width="800" height="535"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Add the below code once it opens the json file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"python.condaPath": "C:\\Users\\user\\anaconda3\\Scripts\\conda.exe",
"terminal.integrated.defaultProfile.windows": "Command Prompt"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This ensures that VS code will default use &lt;code&gt;command prompt&lt;/code&gt; to run conda.exe` terminal whenever we start terminal in the particular workspace.&lt;/p&gt;

&lt;p&gt;That's all, for configuring VS code to intergrate with &lt;code&gt;conda&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Happy Coding.&lt;/p&gt;

</description>
      <category>python</category>
      <category>anaconda</category>
      <category>webdev</category>
      <category>django</category>
    </item>
  </channel>
</rss>
