Cannot get node hello world app to deploy on GCloud - node.js

I cannot for the life of me the the hello world app that google provides to work. I am following the tutorial here: https://cloud.google.com/nodejs/getting-started/hello-world
I have followed all the steps and the hello world code runs perfectly on my local machine. However, when I try to run
gcloud preview app deploy app.yaml --promote
I get the following output:
You are about to deploy the following modules:
- empirical-lens-111022/default (from [C:\Users\zakpt\Downloads\nodejs-getting-started-1-hello-world\nodejs-getting-started-1-hello-world\app.yaml])
Deployed URL: [https://empirical-lens-111022.appspot.com]
Do you want to continue (Y/n)? y
Beginning deployment...
Verifying that Managed VMs are enabled and ready.
Provisioning remote build service.
Copying certificates for secure access. You may be prompted to create an SSH keypair.
ERROR: (gcloud.preview.app.deploy) Couldn't connect to the Docker daemon.
I have no idea what to do, since the Docker isn't mentioned at all in the tutorial, and googling has only shown solutions for OSX. I am on Windows 10

Related

Azure Web App, streamlit stuck in `Please wait...`

I've created a web app service with B1 tier pricing in linux/python3.7
I've hooked up my Azure git to the deployement center, the application builds correctly, I've edited the start command to python -m streamlit run app.py --server.port 8000 --server.address 0.0.0.0. The app launches, I can access to the URL, but streamlit is stuck into Please wait...
I've tried to enable WebSockets, since some people said it was the issue. I could not found the option in the Portal, so I had to use the command az webapp config set --web-sockets-enabled true --name MyAppName --resource-group MyResourceGroup. In the output json, I can see the option enabled.
"webSocketsEnabled": true,
I tried to enable/disable all kind of options in the configuration Portal, but nothing is working. Any idea on what I am doing wrong?
(The app works in local mode, and I don't have access to Docker on my local computer, so I can not use this option to build my docker image)
EDIT 1:
In the chrome console, I get an error:
WebSocket connection to '' failed: WebSocket is closed before the connection is established.
But WebSocket is enabled, or at least from what my previous commands says
After reproducing from my end, I could able to reproduce the same error when the webapp is deployed with python 3.9.
RESULTS:
But when I re-deployed a new Web app with Runtime version- Python 3.10 the error was resolved. The below code works fine when the streamlit app runs locally.
import streamlit as st
st.set_page_config(page_title="My Test app", page_icon=":tada", layout="wide")
# --- HEADER SECTION ----
st.subheader("Hi, I am test app :wave:")
st.title("A test app to test streamlit")
st.write("I am passionate py developer")
st.write("[Learn More >](https://streamlit.io/)")
Python -m streamlit run app.py
RESULTS:
Deployed the same to a new app service on azure with Runtime stack Python version 3.10, OS Linux and SKU B1 Pricing tier (Basic).
Note- Free tier is not supported for Streamlit app atleast B1 or above is mandatory.
Deploy the local code of censusapp in Azure App Service via VS code.
After the code is deployed > Try accessing the website you will receive an application error, to resolve that. Let’s add python -m streamlit run app.py --server.port 8000 --server.address 0.0.0.0> in the startup command in the Configuration.
Disable HTTPS Only to OFF and set the configuration settings as below:-
NOTE: Even if you set this settings to OFF> you can browse your website with https://
After these settings are added and validated, follow the below steps
Browse your website
Wait until the website loads
Now you can see that the error doesn't show up anymore and the website runs successfully in the browser.
Make sure that if your Web app is running on lower Python version than 3.10 Please re-create a new Web App on Azure with runtime stack python 3.10 to resolve this issue.

Connect Node.js API to virtual machine on Microsoft Azure / Azure CLI

Currently, I'm working on a project which is hosted on Microsoft Azure as a resource. The project is presented on a virtual machine and is operated using commands on the Azure CLI.
Now I've been asked to create a web app for it using Node.js and React.js. I'm totally lost on how to connect the Node.js API to the virtual machine. Is there any way to trigger those Azure CLI commands through a Node.js app. Any help would be appreciated!
EDIT:
Managed to solve the issue. Used this npm package 'ssh-exec' which lets you execute commands on a virtual machine remotely after connecting using IP Address, username, password. Very simple to use.
Link to package - https://www.npmjs.com/package/ssh-exec
Managed to solve the issue. Used this npm package 'ssh-exec' which lets you execute commands on a virtual machine remotely after connecting using IP Address, username, password. Very simple to use.
Link to package - https://www.npmjs.com/package/ssh-exec
There are some few steps to connect Node.js API to VM,
Firstly, we need to clone the project that we will be deploying to the Azure VM. This project is a basic Node.js API with a single endpoint for returning an array of todo objects. Go to the location where you want to store the project and clone it:
git clone --single-branch --branch base-project https://github.com/coderonfleek/node-azure-vm.git
Once the project has been cloned, go to the root of the project and install dependencies:
cd node-azure-vm
npm install
Run the application using the npm run dev command. The application will start up at the address http://localhost:5000. When the application is up and running, enter http://localhost:5000/todos in your browser to see the list of todos.
enter image description here
Now, go to the package.json file of your project and add these scripts in the scripts sections:
"scripts": {
.....,
"stop": "pm2 kill",
"start": "pm2 start server.js"
}
The start and stop scripts will use the pm2 process manager to start and stop the Node.js application on the VM. The pm2 script will be installed globally on the VM when it has been set up.
At the root of the project, run the rm -rf .git command to remove any .git history. Then push the project to GitHub. Make sure that this is the GitHub account connected to your CircleCI account.
Then, Setting up a virtual machine on Azure to run Node.js.
Next, create a new VM on Azure and set its environment up for hosting the Node.js application. These are the steps:
Create a new VM instance
Install nginx
Configure nginx to act as a proxy server. Route all traffic to port 80 on your VM to the running instance of the Node.js application on port 5000
Install Node.js on the VM and clone the app from the GitHub repo into a folder in the VM
Install pm2 globally
Do not be intimidated by the complexity of these steps! You can complete all five with one command. At the root of your project, create a new file named cloud-init-github.txt; it is a cloud-init file. Cloud-init is an industry-standard method for cloud instance initialization.
cloud init- code
(REFER THE BELOW LINK FOR COMPLETE DETAILS)
https://circleci.com/blog/cd-azure-vm/

Flask web api is not working even when nginx and uwsgi is up and running

I have Ubuntu 16.04 on VMware workstation 12 player and my desktop is Windows 10. I have created a simple Flask web api and using nginx and uwsgi. Same application is working on my Azure Ubuntu 16.04 VM without any problem.
I have not made any changes in code I brought all the files from Azure VM via scp from my local VMware VM. But still app is not working. I have followed steps given in following URLs:
I have executed all the step accept last step, instead of creating uWSGI Emperor I created systemd service
https://vladikk.com/2013/09/12/serving-flask-with-nginx-on-ubuntu/
https://www.digitalocean.com/community/questions/convert-run-at-startup-script-from-upstart-to-systemd-for-ubuntu-16
https://www.digitalocean.com/community/tutorials/how-to-set-up-nginx-server-blocks-virtual-hosts-on-ubuntu-16-04
Web api is working when i am running it from terminal using "python3 MLService.py &" command. which means flask along with my code has no issue. it is some thing with uwsgi and nginx.

what happens when the command gcloud app deploy --version v1 is issued to deploy a nodejs application?

Can any one help me understand gcloud app deploy? I tried deploying an application but it gave me the error:
ERROR: (gcloud.app.deploy) Error Response: [13] An internal error
occurred while creating a Google Cloud Storage bucket.
Thanks,
-VR
gcloud is google sdk command to interact with its cloud services, you can read more about it here https://cloud.google.com/sdk/gcloud/
you can run gcloud commands either by installing gcloud sdk or from a gcloud shell where sdk is pre-installed.
gcloud app deploy looks for app.yaml which can be configured based on this documentation https://cloud.google.com/appengine/docs/flexible/nodejs/configuring-your-app-with-app-yaml
To address the error try running this command gcloud config set app/use_deprecated_preparation True; and give a try.
once we run gcloud app deploy --version v1 a version of the application is created and can be accessed by the corresponding url from version column.
one can even login to the running instance of VM by accessing respective instance ssh.
this command will tar ball the folder containing app.yaml and will be used to create the running nodejs instance; the entire deployment depends on PORT being used as part of NodeJS application for running production instance, and a proper package.json which will have all the dependencies listed and contains a start script to run the application.


Deploy ember application in Bluemix

I am trying to deploy an existing ember-nodejs application into bluemix environment. I tried the following steps.
bluemix api https://api.ng.bluemix.net
bluemix login -u username -o org_name -s space_name
cf push app_name
I also tried the above command with an ember build pack from the list of
compatible CF build packs
cf push app_name -b https://github.com/cloudfoundry-community/cf-docs-contrib/wiki/Buildpacks
Uploading is successful, but the application doesnt start up. Is there a recommended way of deploying ember-node js application?
Update
It was a memory issue. I removed the other running apps and tried the cf push command again. The node modules got installed and the application also started without any fuss.
According to the user, this was actually a memory issue. Once he stopped the other running apps, his node modules were installed and the application started without any further errors. There are no issues specific to deploying ember-nodejs applications in the Bluemix environment.

Resources