Angular2 frontend Spring Boot backend on Google cloud platform - java

I have an Angular2 front-end and a Java Spring Boot back-end with my REST endpoints.
Now I want to deploy this app to Google cloud platform, but I want to keep my projects separate.
All I've read is about deploying one single application, but I want to keep my front-end and back-end separate.
How can I deploy my separate projects to Google cloud platform and have them communicate here as well?
Thanks for your help!

The easiest way to do this in GCP would be to host the frontend in Cloud Storage and set up your backend in Google Compute Engine (GCE) or App Engine.
Frontend
Cloud Storage provides static hosting capabilities. You can upload your frontend files to a Cloud Storage bucket and configure your domain to serve content from that bucket. Here is a tutorial for setting a bucket up for static hosting.
Once your backend REST endpoints are set up, the frontend app can easily communicate with them using Angular's AJAX capabilities.
Backend
If you prefer direct access to the machine your server runs on, you can upload the backend code to a GCE instance and run the server there. Otherwise, I would recommend deploying the server using App Engine, which will manage the instances for you.
One point you might be interested in is configuring permssions for your backend endpoints. If you want to restrict access to those endpoints and only allow your frontend to communicate with them, try out the Google VPC firewall features.
Good luck!

Related

Deploying springboot app and ui separately

Currently, I have a springboot jar file with a bunch of rest and apis including calls for login deployed on ec2. I also have a separate code base for my ui i.e with js,html,css. What is the best way to deploy this on aws and keep it separate from the backend.
This can be done in many ways. But will share a simple way.
Deploy your spring boot app in one aws instance.
Deploy the other front end app on the other aws instance.
This is a kind of two tier application where the server and client app are hosted in different instance. You can restrict the access of your rest api to be accessed only by the instance where you host front end app. For trial you can use heroku account. E.g.
Github: https://github.com/krishna28/springbootapi
Also check https://github.com/krishna28/etodo

spring boot web app for authentication/autorization using AWS Cognito Java API

AWS Cognito primarly meant for Serverless user authentication from Mobile or Web application (Javascript).
The primary concern is that, we need to do client implementation for each of the client like Android, IOS and Javascript.
Instead of that can we have spring boot server which will expose a login/signup/action rest endpoint for all the above clients where the spring boot will authenticate/signup with Congnito on behalf of the clients and send the access_token response back to the client. This way, Conginto integration will be done only in one place which is the Spring boot application.
Can we go ahead with this approach? Does AWS SDK supports Java for cognito access from Server?
Here's an article which shows an example of implementing a Spring boot application that is able to authenticate the user against Amazon Cognito using OAuth 2.0 authorization code grant and JSON Web Tokens.
This github repo contains the example code in Kotlin
Probably, this is in some ways, similar to your usecase.

How to deploy Spring framework backend and Angular 2 frontend application in any online server?

Please correct if the way I am doing is wrong.
In my web application I am not using jsp pages for developing user interface. Instead I am using html, css and Angular 2 and front-end project structure is separated from back-end.
Although I am able to develop a simple project using Angular CLI which is served by SpringMVC back-end. Front-end is using port 4200 and backend is running on port 8080. I have managed to take and serve request from Angular 2 to SpringMVC. In local mode these are working perfectly, now I want to make them host on a live server.
How to publish SpringMVC back-end and Angular 2 front-end separately but running on same domain? I am not using SpringBoot also front-end and back-end are in separate folders. I do not want to combine both in same project structure and generate a war file and deploy.
What is the best practice for developing SpringMVC back-end and Angular-2 back-end and deploying them in online server?
What I've found works best is running nginx as a static file server and a forward proxy for the spring app.
usually I use the angular-cli proxy to make /api/ go to http://localhost:8080
that means that calls to http://localhost:3000/api/** get passed to http://localhost:8080/api/. And since you are on the same domain we can simply call /api/

Deploying the google translation api in my java server locally and not invoking web service.

I want to deploy the google translation api in my java server locally. Is there any option where we can get the translation result either from any jar or something else instead of invoking the web service. Since, data which i need to translate is secure and it cannot be exposed. Could you please provide me the information on deploying the same on application server and not invoking web services.
Google Translation API works great with web service call, but i need something which can be done locally not via web service.
Or is there any other API which i can use for the same.
There is no jar that you can install and run it locally. You have to call Google Web Services.

Publish WebService for public access

So, i have some experience developing Java WebServices.
The problem is, all i do is deploy them to localhost.
My question is:
How can we deploy a WebService to a server other than localhost?
How can i search the web and find the WSDL description for my WebService so that i, or anybody else around the world, can call its services?
If i have it in localhost, nobody else but me on my computer can acess it right?...
Thank you for your time
I don't think you'd want to make an application running in your development environment accessible to anybody else around the world for a variety of reasons. Others on your local network could access your local host via its network hostname, but this isn't users around the world.
Let's discuss your two questions individually:
How can we deploy a WebService to a server other than localhost?
You'll want to establish a server environment that is available (on) as much as possible. If you want to keep using Apache Tomcat, you could sign up with a variety of service providers that host Apache Tomcat applications - there are many who offer tiered pricing based on number and size of pre-configured virtual servers (CPU, memory, disk space, and/or monthly data transfer of the application). You could even sign up with a cloud service provider such as Google Cloud, Amazon Web Services, or Microsoft Azure. All provide the tools to build, provision, and manage virtual server(s) which you would then deploy Tomcat and web service application into. Here's a detailed tutorial on setting up a Tomcat virtual server on Azure. You'd then need to manage those server(s), watch them to see how much they're utilized (which will impact how much they cost you per month, by the way).
If server management isn't what you're looking for - you could also explore "serverless" options such as Google AppEngine or AWS Elastic Beanstalk. In this model, you just upload your WAR file and the hosting service manages things like how many servers are needed to handle all the application SOAP requests your users around the world are making. You'll need to read the specifications for each, as you technically aren't providing Tomcat itself - in Google's example, you're actually running in their own proprietary container, so your app may need some changes depending on what it does.
Depending on what hosting or cloud service provider you select, your "how to deploy" steps vary wildly. On the bright side, all offer tutorials on how to specifically deploy applications into them "their way."
How can i search the web and find the WSDL description for my WebService so that i, or anybody else around the world, can call its services?
Once you've settled on a hosting or cloud services provider and have deployed your application, you'll have a URL to reach it, but you'll need to work on getting the word out. There are some open specifications on (SOAP) web service discovery, but more than likely that's not what you're really looking for. You could also submit your WSDL URL to an online API directory such as ProgrammableWeb or Public APIs.
The simplest way to do-it-yourself would be to run a web site that links to the WSDL, then use search engine optimization techniques to list the site on search engines and make it (and the WSDL it links to) relevant to web searches.
Getting fancier, you can treat your web service as a product via an API Management system. At a high level, this works by hiding the real URL to your web service on its server(s) and instead direct clients to a small website for developers where you document, market, facilitate discovery of your service as well as offer a sign up to use it (so you can track and manage who around the world is using your web service). Clients then consume the web service via separate URL behind what's called an API Gateway. You could charge for access or offer it for free but limit the amount of concurrent requests a client can make - after all, you're likely paying your hosting provider for utilization. Some of the cloud service providers Amazon, Azure, standalone API management vendors such as Apigee, Mashery, and many others.

Categories