Volume changes not being detected by docker programs - reactjs

I have mapped my directory (on host OS) to a directory in docker. When i make changes in host directory, they are refelcted in Docker directory but apps like nodemon or react-hot-reloader do not detect them and hence do not restart. However, hot reloading works fine when i make changes directly within docker. I am running an express app. I have tried two OSs (node:alpine3.13 & node:stretch-slim)for Docker but hot reloading works on neither. I also tried installing inotify-tools on alpine but to no avail

Related

VSCode Create Dev Container - docker not found (worked before)

I seem to be unable to create any new dev containers on WSL2 Ubuntu (worked fine before) and I don't know how to debug this.
Environment
Windows 11
WSL2 with Ubuntu distribution
VSCode 1.75.1
Extension: Dev Containers 0.275.1 or 0.279.0 (no difference observed)
Extension: WSL 0.75.3
Docker on Windows: none
Docker on WSL Ubuntu: 20.10.22
Scenario
Open WSL2 Ubuntu terminal
Go to desired development folder
Start
code .
VSCode shows on Windows (Mentioning remote host "WSL:Ubuntu")
Command: Dev Containers: Create dev container (e.g. Python container)
Error shows:
Docker returned an error. Make sure the Docker daemon is running and select an option how to proceed.
Log shows:
Start: Run: docker version --format {{.Server.APIVersion}} [883 ms] findLocalWindowsExecutable: Exectuable 'docker' not found on PATH 'C:\Windows\system32;(...)'. [885 ms] Exectuable 'docker' not found on PATH 'C:\Windows\system32;(...)'. [890 ms] Docker returned an error code ENOENT, message: Exectuable 'docker' not found on PATH 'C:\Windows\system32;(...)'.
Already tried
Previous creation of such dev containers on this environment worked fine.
Executing the old dev containers on the current environment still works fine.
Question
I don't know where to get started to debug this. Probably something changed in my environment causing the creation of dev containers to fail, but I have no clue. I can't really reconstruct what would have changed to the setup.
I didn't expect devcontainers to go and look for docker on my Windows path... I read about docker cli being used under the hood, but I never had docker on this Windows system, so it mustn't be essential in the WSL2 setup since it worked before.
Thanks,
Johan

How to see console.logs of a running nodeJs application on ubuntu 18 EC2 instance?

I am new to the node world. I created a node js rest API. When I run npm start in my local machine or in the terminal for the first time, I can see console.log() in my terminal. Now, I am running the same application on an AWS Ec2 instance with Ubuntu as os. I run npm start and serve my app on port 80. I do this via ssh and after running my server I close the ssh connection. But when I reconnect via ssh, I want to see those console.log() messages in my terminal for some purpose.
I completely understand that logging messages in the terminal is not a good idea and there can be so many alternatives. Just want to know how to access the same terminal window/result as we see when I start my application.
if you are using pm2, you can try "pm2 logs"
So Nodemon won't work well in a production server or in any instance where you need to have the app going by itself.
Nodemon is a dev tool to enable you to restart your server during development. In a "real" vps you need to place the process in the background or it will be automatically killed when the connection times out.
Check out this YT series for a correct deploy architecture in an NGINX server with the use of pm2 and NGINX on a Red Hat server, I've personally used it more than once:
https://www.youtube.com/playlist?list=PLQlWzK5tU-gDyxC1JTpyC2avvJlt3hrIh

Project inside webapp tomcat8 does not run in webpage

I am trying to run my application using tomcat8 inside the Apache2 virtual machine, using MacOS.
The IP address is: http://143.167.11.2:8080
and this the view when I run the link on the browser:
I have installed tomcat8 inside this apache2 VM using: apt-get install tomcat8 by following this instruction: https://www.linode.com/docs/development/frameworks/apache-tomcat-on-ubuntu-16-04/
When I run this address http://143.167.11.2:8080 the result is the same, it just shows this same picture . It does not show the tomcat home page.
I have tried to run this: ./startup.sh and inside the terminal and it started.
But when I run the linked address http://143.167.11.2:8080 the result is same, it shows apache home page.
I tried to put my project inside /var/lib/tomcat8/webapps and then tried to run: http://143.167.11.2:8080/visualisation-dataproject.
But the result like below:
Any idea how can I run my project (that I put on the webapps folder) on the web browser?
Apache2 is usually use for PHP project. Tomcat is usually for java project. There are some possibility why you can not run tomcat on the web browser. One of the reason is you have not install tomcat8 properly. Even you have install it, you should check it really work or not. If it work on the VM, maybe the problem when you set the port for tomcat in server.xml.
To check server.xml, try : sudo nano /etc/tomcat8/server.xml, and find <Connector port="8080" protocol="HTTP/1.1 ... line.
And try to change the port 8080 to another port e.g: 8081. Why? to prevent tomcat8 server running with same port with another server such as apache2.
After that try the step on this link: https://askubuntu.com/a/434085/856656 it should work.

React: deployment with serve in production mode

I have an reactjs application that I have deploy on my web server.
I build my app (So it's create a build folder) and when I want to start it with ~/.npm-packages/bin/serve -s ./build -l tcp://0.0.0.0:8100 it work (with work dir set to react/, build is here react/build but we can see all source code on my page, that theory not possible in production mode.
If I set the work dir to react/build it return a 404 error.
Inside build folder
It doesn't return any other error unfortunately.
Update: I only stock build folder and it work, but we can always see source code even its in production mode.
If I change to react/build, react/build/static or other, it display 404.
If you are using npm's serve (the default for create-react-app, which I am assuming you are using), that second argument is the directory to serve:
$ serve --help
$ serve} [-l listen_uri [-l ...]] [directory]
By default, serve will listen on 0.0.0.0:5000 and serve the
current working directory on that address.
-s, --single Rewrite all not-found requests to `index.html`
But serve is meant for development serving. It works fine for production of a small static site, but consider another production-proven web server.
Your unminified source should not be kept on a production server, at all. You should deploy just the build files to production.

create-react-app does not serve boilerplate app

I haven't made any changes, I just run "create-react-app client", then everything runs correctly, I cd into the directory and run "yarn start".
Then I have two problems:
1) It says "Something is already running on port 3000". Unfortunately when I use lsof and netstat, nothing is running on port 3000. I say to run on a different port, and it then attempts to serve the app.
2) Nothing is served on the new port. The browser opens up, the console gives no errors, but nothing gets served to the browser.
node version 8.7.0
yarn version 1.3.2
create-react-app version 1.3.3
OS MacOS
My hosts file was empty, so "localhost" didn't mean anything.
127.0.0.1 localhost fixed it.

Resources