Azure Web App Node deployment, change app root directory? - node.js

I am trying to deploy a Node app on an Azure App Service, using Github and Kudu, running on Windows. The deployment works and the app is started.
My codebase is organised as follows:
/config
/res
/src
package.json
and package.json contains node src/start.js.
The problem I am having is that it seems that on that deployment the root directory for the Node app is site/wwwroot/src and not (as on my local machine, or my previous deployment on AWS) site/wwwroot. This leads to my code not finding the files inside /config or /res since the paths used in the code presume that the root is top level, and not inside /src (e.g. ./res/myFile.jpg will try opening site/wwwroot/src/res/myFile.jpg and not site/wwwroot/res/myFile.jpg).
I have been looking around but can't find how to change this. Can anyone help me?
Thanks!

For those wondering: I didn't solve it but a workaround is to put your entrypoint js file in the root directory. So instead of having node src/index.js you use node index.js, while keeping all your other sources in /src.

Related

How to deploy nodejs app on jelastic in ROOT subdirectory

I'm trying to deploy a nodejs app on jelastic using pm2. Though I understand the classical use would be to have the app in ROOT folder, having ROOT folder containing package.json and ecosystem.config.js file.
Howerver the company I work with is used to have one GIT repo per project, with subdir /api for backend and /web for the frontend.
So my nodejs app is actually in ROOT/web/
Is there anyway to configure things so that it works? I tried changing node variables PROCESS_MANAGER_FILE and ROOT_DIR but it always somehow fail.
Thank you for your help

Changing Jelastic Node.js root folder

I am trying to deploy a React app in my Jelastic Node.js server but I am not being able to make it work.
I am using vite for building. To test the deployment, I am building my app on my local environment and deploying the build directory into the Node.js server which works fine sometimes but sometimes it too doesn't work and the site is unreachable. I don't know what causes this.
But I want to make this process automatic and set the root directory to dist directory which is default build directory for vite so that I could pull it from GitHub and run build command and deploy it automatically. I searched for changing the configurations in Jelastic Node.js but couldn't find any relating to this issue.
You can either a) add VCS project into any non ROOT context, and for ROOT create a symlink through WebSSH (but this can cause downtime during deployment) or b) add VCS project into any non ROOT context and add a deployment hook to which copy content from dist into ROOT (and in this case downtime is minimized).

how to deploy node app to Heroku if the code is in a subfolder?

I have a nextjs and nodejs app in client and server directories respectively, and I know that heroku needs package.json in the root folder to deploy the node app but, it is in the server directory, how can I deploy this, I tried everything I found in other StackOverflow questions but they have ancient solutions, that doesn't seem to work now, is there any workaround?
/myProject
-- client
-- server
It's possible to specify your start script by adding a file Procfile in the root directory.
You may need a Procfile like this:
web: cd client && npm start
worker: cd server && npm start
Next, Enable both web and worker in Heroku App > Resources Tab.
See the official doc also: https://devcenter.heroku.com/articles/deploying-nodejs#specifying-a-start-script

Permission denied on deploying react web app on azure

I am deploying a react web app on azure by creating a workflow on github.
Now after committing changes it shows an error on creating build as:
The same error occured when I was deploying it using surge.sh
Can anyone help me out?
It seems to be a problem related to the Node.js module in your repository. Therefore, I suggest you do the following
Part 1: Reinstall the Node module
yarn uninstall
yarn install
Part 2: Redeploy the project via GitHub Action
Part 3: Deploy the React app directly from Azure Portal
Adding to Mark's response. Try the following steps to further narrow-down the issue:
-Please check if there is a .deployment file in the root of the repository, and provide this file if present, along with the deploy._ file if present (deploy.cmd, deploy.sh, deploy.ps1).
-Just to isolate, test the deployment directly from your local Git repository to a new App Service.
--If a .deployment and deploy.sh file are included in the root directory of the app code, Kudu will use the legacy build to run the commands specified in the deploy.sh script.
--Just to highlight on this, Kudu is the engine behind Git deployments on both Windows and Linux. By default, App service uses Oryx to build/install and Kudu will determine type of stack is used and creates a generic deploy.sh script to install the packages.
-App Service sets the environment variable PORT in the Node.js container, and forwards the incoming requests to your container at that port number. your app should listen to that port using process.env.PORT
const port = process.env.PORT || 3000
1.Add a start-up script: Add the PM2 configuration file or your script file
2.Go to Azure Configuration>General Settings
If your build folder is at the root of the project:
Start up command: pm2 serve /home/site/wwwroot --no-daemon --spa
Certain web frameworks may use custom startup scripts when running in production mode.
Refer this doc Customize build automation for more details.

Hosting react app on godaddy

I bought domain and cheapest hosting on GoDaddy, but have no idea how to upload my react app to cPanel.
Uploading simple index.html into public_html works, but I haven't yet found how to proceed with react app.
Here is the project that I want to upload.
In case what I am asking is not possible, I would appreciate any other recommendations on how to get my react app going on domain I just bought.
Thanks in advance!
According to your projects package.json file, the production build command is build:prod. So if you are using npm run: npm run build:prod or if using yarn yarn build:prod.
Then your webpack.config.js states that the output production javascript bundle.js file will be in public/dist/. So you need to upload the public folder AFTER running the command above to produce bundle.js. Make sure that you keep file and folder structure the same when uploading the contents public folder.

Resources