July 19, 20196 yr Greetings all. Between various home automation scripts and some web things, I keep encountering the need to run various node.js code, usually as "glue" for this and that. It's pretty rare than anyone bothers to put together a docker for this stuff, let alone something that runs out of the box in unraid. I've spent some time going down the rabbit hole trying to build something myself, but I seem to keep getting hung up on getting the actual code into the docker in quite the same way as other packaged dockers I've run. Does anyone have any pointers or, ideally, any specific method they've used to do this in the past. Basically, I need to bring in a node.js docker, import some arbitrary code (ideally I'd like this code to live in the appdata share so I can modify it without updating the docker), and be able to run that code on the docker launch. Any thoughts? Thanks!
July 21, 20196 yr On 7/19/2019 at 9:54 AM, peng1can said: Greetings all. Between various home automation scripts and some web things, I keep encountering the need to run various node.js code, usually as "glue" for this and that. It's pretty rare than anyone bothers to put together a docker for this stuff, let alone something that runs out of the box in unraid. I've spent some time going down the rabbit hole trying to build something myself, but I seem to keep getting hung up on getting the actual code into the docker in quite the same way as other packaged dockers I've run. Does anyone have any pointers or, ideally, any specific method they've used to do this in the past. Basically, I need to bring in a node.js docker, import some arbitrary code (ideally I'd like this code to live in the appdata share so I can modify it without updating the docker), and be able to run that code on the docker launch. Any thoughts? Thanks! Hi @peng1can I'm not saying this is the very best way, but this is what I'd do... Create the folder (in appdata if you'd like) with your node.js code files inside it run a node.js container that executes your code: docker run -d --rm -v /mnt/user/appdata/my_nodejs:/my_nodejs node:lts-alpine node /my_nodejs/peng1can.js change "my_nodejs" to the folder name you made, change "pen1can.js" do your node js file you need to execute Very simple example but it can be expanded depending on what you're doing with node. Edited July 21, 20196 yr by dee31797
July 23, 20196 yr Another thing you could think about is using Node-Red instead of just a node.js script. I've found I could put the vast majority of my home automation related node.js scripts in Node-Red. For me that is easier to support than a random js script running somewhere, but your needs may differ.
February 3, 20206 yr Will npm install get run automatically somehow if you put package.json there too? Will you be able to then control this container from the unraid gui?
February 4, 20206 yr I made a dir for my little node app called "wx": cd /mnt/user/appdata; mkdir wx; cd wx Then I made a simple Dockerfile with the following contents: FROM node:6.8.1 WORKDIR /usr/src/app COPY package.json . RUN npm install COPY server.js . EXPOSE 3006 CMD [ "node", "server.js" ] Then I created the docker image: docker build -t foo/wx . Then I started it with: docker run --net=nginx -h wx --name wx -p 3006:3006 -d foo/wx nginx is the net I created following the spaceinvaderone letsencrypt/nginx video. After starting this container it shows up in the docker tab in unraid but all you can really do is stop or remove it. How can I autostart it? Edited February 4, 20206 yr by uek2wooF added "with the following contents"
June 13, 20206 yr On 2/4/2020 at 9:08 PM, uek2wooF said: I made a dir for my little node app called "wx": cd /mnt/user/appdata; mkdir wx; cd wx Then I made a simple Dockerfile with the following contents: FROM node:6.8.1 WORKDIR /usr/src/app COPY package.json . RUN npm install COPY server.js . EXPOSE 3006 CMD [ "node", "server.js" ] Then I created the docker image: docker build -t foo/wx . Then I started it with: docker run --net=nginx -h wx --name wx -p 3006:3006 -d foo/wx nginx is the net I created following the spaceinvaderone letsencrypt/nginx video. After starting this container it shows up in the docker tab in unraid but all you can really do is stop or remove it. How can I autostart it? How did you solve your problem? Did you add something /boot/config/go to start your app automatically?
Archived
This topic is now archived and is closed to further replies.