Google Cloud Build - google-cloud-platform

Hi I am new to Google Cloud Platform. I want to build an Java application which should be built using Google Cloud Build without docker containers. And also the built application to be tested and artifact to be saved in bucket. Can anyone help me on this ?

Cloud Build is conceptually a pipeline mechanism that takes some set of files as input (commonly in some source repo) and applies a number of processing steps to the files including steps that produce output: file(s) | step-1 | step-2 | ... | step-n.
Most of the examples show Cloud Build producing Docker images but this underplays all the many things it can do.
Importantly, each of the processors (steps) must be a Docker containers but the input and output need not be docker images.
You can use javac or mvn or gradle steps to compile your code and then use the gsutil step to copy the war or jar to Google Cloud Storage.
https://github.com/GoogleCloudPlatform/cloud-builders/tree/master/javac
https://github.com/GoogleCloudPlatform/cloud-builders/tree/master/mvn
https://github.com/GoogleCloudPlatform/cloud-builders/tree/master/gradle
https://github.com/GoogleCloudPlatform/cloud-builders/tree/master/gsutil

Since you mentioned that you without docker container, I assume you want to deploy your application not in docker image. You can deploy your app into Google App Engine Standard. So in how to deploy into App Engine, you can refer to this documentation: https://cloud.google.com/build/docs/deploying-builds/deploy-appengine
To run the application on App Engine, you create app.yaml on your project Then you put these lines inside app.yaml
runtime: java11
entrypoint: java -Xmx64m -jar {your application artifact in jar file}```

Related

Update the Web-Front-End of a Google Kubernetes Engine Webapplication

i used this https://cloud.google.com/kubernetes-engine/docs/tutorials/guestbook?hl=de to bulid a Guestbook with Google Kubernetes Engine.
I applyed this an everything works.
Now i wanted to change the index.html for a better Look.
How can i upload or update the changed file?
I tried to apply the frontend service again with this
kubectl apply -f frontend-service.yaml
But it did not work.
You will have to rebuild the containers if you make changes to the source code. I suggest you:
Download docker and run docker build to rebuild the containers locally.
Push the containers to your own Artifact Registry(AR) following this guide https://cloud.google.com/artifact-registry/docs/docker/pushing-and-pulling.
Update the yaml files to point to your own AR.
Redeploy the application to GKE

Provisioning a custom Docker image on AWS CodeBuild takes a very long time

My Dockerfile:
FROM mcr.microsoft.com/dotnet/framework/sdk:4.8-windowsservercore-ltsc2016
COPY AWSCLIV2.msi .
RUN Start-Process msiexec.exe -Wait -ArgumentList '/I AWSCLIV2.msi /quiet /qn /norestart /log awscli.log'
RUN rm AWSCLIV2.msi
My CodeBuild environment needs to be able to build a .NET Framework project as well as use AWS CLI. Due to limitations, I can only have one CodeBuild stage. I push to ECR the docker image created using the above Dockerfile and set my CodeBuild environment to use that image. However it takes ~10 minutes to provision.
CodeBuild provides caching that only lasts ~15 minutes which is not helpful for more infrequent builds. I also found this solution that others linked to https://github.com/aws/aws-codebuild-docker-images/issues/26#issuecomment-370177343 but I'm not sure how it can be applied to Windows containers.
If anyone has any pointers on decreasing the provisioning time, I would really appreciate it.
Windows images are large, so the provisioning time which includes the time to pull down the custom image to CodeBuild instance will be relatively long.
There are two approaches that can help:
Use CodeBuild provided images for the build environment, as the latest version for these images are pre-cached on the build servers.
Use the base layer for the custom image same as that of CodeBuild image, so that the base layer could be reused and won't incur download time. e.g.:
For Microsoft Windows, use a Windows container with a container OS that is version microsoft/windowsservercore:10.0.x (for example, microsoft/windowsservercore:10.0.14393.2125). Link

Pushing Fortio in cloud foundry using docker image

I am trying to push Fortio(a load testing tool for microservices) as an application in cloud foundry. I am trying it with a docker image from hub.
cf push <app-name> --docker-image fortio:fortio random-route
Application crashes when it tries to start the application. cf logs says : executable file not found in $PATH
It is working fine in my local docker setup but not in cloud foundry.
Any help??
https://docs.cloudfoundry.org/devguide/deploy-apps/push-docker.html
A Docker image that meets the following requirements:
The Docker image must contain an /etc/passwd file with an entry for the root user. In addition, the home directory and the shell for that root user must be present in the image file system.
Unfortunately, public Docker image fortio/fortio doesn't meet this particular requirement.
Solutions:
build customized Docker app image with shell and /etc/passwd
use source code and push it as a native golang app and not a Dockerized app

How to run C++ files on the Google Cloud Functions?

From what I am aware, Google Cloud Functions only allows you to deploy NodeJs or Python scripts.
Question: How would I be able to deploy a simple Hello_World.cpp on Google Cloud Functions? For example, writing a hello world HTTP function.
What are alternate methods to do this? I want to use serverless approach, since it's cheapest method. Therefore, that is why I'm going with Google Cloud Functions. Would I have to use docker in order to run C++ files? I've been stuck on this for a while and any guidance or help would be appreciated.
You can compile your C++ function into a WebAssembly module using emscripten. Then you can call it from a small nodejs glue code.
I built an example for you here:
https://github.com/ArthurSonzogni/gcloud-cpp-starter
You can run C++ Code by node.js on google cloud functions (tested with node.js 10)
how to using C++ and N-API (node-addon-api) https://medium.com/#atulanand94/beginners-guide-to-writing-nodejs-addons-using-c-and-n-api-node-addon-api-9b3b718a9a7f
use https://console.cloud.google.com/functions and click CREATE FUNCTION to upload .zip or gcloud functions deploy --runtime nodejs10 --trigger-http
The trick is when you zip file you need to remove /build and /node_modules folder then use command line by cd to folder of index.js and 'zip your_name.zip -r *'
ps. when I use firebase deploy --only functions it will error because it doesn't know file addon.node format (in fact it shouldn't read this file because it need to be recompiled) but I think if we using gcloud functions command line with .gcloudignore for /build and /node_modules it will success https://cloud.google.com/functions/docs/deploying/filesystem
HOW DOES IT WORK
I think when you deploy node.js source code to cloud functions it will run npm install and your C++ code will be compiled too (like npm run build will be auto run after npm install)
You can't use C++ on Cloud Functions, period. You can only use Node.js 6.14, Node.js 8.11.1 (beta) and Python 3.7 (also beta).
If you wish to use C++ in GCP with a serverless approach, my best suggestion would be running your own Custom Runtime in App Engine. You would still need to configure some instances options, but you don't have to manage servers and so on.
You can only use App Engine Flexible Environment (or, of course, standard VM architecture, Compute Engine). Extract from the docs (https://cloud.google.com/appengine/docs/flexible/):
Runtimes - The flexible environment includes native support for Java 8
(with no web-serving framework), Eclipse Jetty 9, Python 2.7 and Python 3.6,
Node.js, Ruby, PHP, .NET core, and Go. Developers can customize these
runtimes or provide their own runtime by supplying a custom Docker image
or Dockerfile from the open source community.
As an interesting side note, Google Serverless Containers will give you the chance to deploy your dockerized application but in a serverless flavour (in fact it's built on top of Google Cloud Functions technology). It's currently in Alpha stage.

AWS Codebuild .NET Core building docker image

We tried the default AWS codebuild image to build .NET core apps and it worked fine.
Now we require to build to Docker images, but the default image has no docker installed.
AWS has the option to run the Builder image in Priviledged mode so you can run docker-in-docker operations.
I would like to know if there is an image I can use that has both .NET Core and Docker installed, so I can build the code, and then the image.
Thanks!!
You'll need to create you own docker image and provide that to CodeBuild (as part of project environment configuration).
You can find CodeBuild's vended docker images here for reference https://github.com/aws/aws-codebuild-docker-images
You need to create a docker image which has both docker daemon and .NET core on the same image. Refer to this sample on how to start the docker daemon before starting builds in your custom docker images http://docs.aws.amazon.com/codebuild/latest/userguide/sample-docker-custom-image.html