How to to use Docker for ElectronJS app built in Windows? - node.js

I am working on a desktop application build using ElectronJS framework on Windows.
May be I haven't understood Docker properly, but how do I use docker for this app?
My end goal is to not let people install node, npm and electron packages on their local system. They can use the docker image to develop this application.
Update
I figured out how to package my project in docker image. Now I am struggling to run the app through the Docker Container.
How to run a GUI(Electron Application) application using docker container?
Thanks.

In your case you need custom docker images that will have node, npm and ElectronJS in it.
I found one such image on dockerhub, you can use it or build your own custom image by checking its dockerfile.

Related

Running Vue JS project in Docker

I have already built a few VueJs applications for myself. Now I am working with a team. One backend and me frontend.
Now I'm wondering how do I include the environment in the repository. Until today I always had node on my local machine. With nvm I could also jump between versions on the local machine. But now I want future colleagues who will develop the app to have the same environment. So work with the same node and npm version. I thought this could be done with a dockerfile or docker-compose.yml. Then I can log into the container and run the npm run build for example.
Question But how does it work with npm run dev? Do I have access with the browser to the port that is assigned in the container of the Vue app?

Remove dependancies from package.json when building a docker image

So I have an express / nodejs web server, that I can run two ways:
run it as a desktop electron app based web server, so we can run it in offline environments
Build it into an image that runs as a node server with no electron
I am wondering, when I do build the image using a dockerfile, is there a way to remove the electron dependencies as it is not needed in the docker container
Or would i create two projects with different package.json files that use the same files?

How would I update node.js inside of Docker container on Windows

I am running into a problem finding good documentation on how to update and check the version of Node that runs on my Docker container. This is just a regular container for .net 2 application. Thank you in advance.
To answer your questions directly:
If you don't have the Image's Dockerfile:
You can probably (!) determine the version of NodeJS in your container by getting a shell into the container and then running node --version or perhaps npm --version. You could try docker run .... --entrypoint=bash your-container node --version
You can change a running Container and then use docker commit to create a new Container Image from the result.
If you do have the Image's Dockerfile:
You should be able to review it to determine which version of NodeJS it installs.
You can update the NodeJS version in the Dockerfile and rebuild the Image.
It's considered bad practice to update images and containers directly (i.e. not updating the Dockerfile).
Dockerfiles are used to create Images and Images are used to create containers. The preferred approach is to update the Dockerfile to update the Image and to use the updated Image to create update Containers.
The main reason is to ensure reproducibility and to provide some form of audit in being able to infer the change from the changed Dockerfile.
In your Dockerfile
FROM node:14-alpine as development

How to deploy the Fluid server?

I'm using the Fluid draft-js example here:
https://github.com/microsoft/FluidExamples/tree/main/draft-js
I know I can run the app locally by just running npm start or just the server by using npm start:server
But how can I deploy this app (server) to a production environment? (I'm sorry if this is a stupid question). Should I just upload the repository to a node environment and run the commands? Should I try to make a docker image?
Any ideas?

How do I create a distributable Docker image?

I'd like to build a NodeJS server packaged as an executable, which can then be installed and run on any Linux machine without any pre-requisite dependencies. I was considering packaging it as a Docker image, but that would mean that the user would need Docker to be installed on their system. Is there a way to package a Docker image itself as an executable, so that all the user needs to do is to run an executable file?
With docker NO
The answer for the executable from docker is no.
You can create docker/docker-compose project which you can simply run
if you have docker installed.
Without docker YES
But you can still package it without using docker (with the whole nodejs included in the executable).
Look at this link https://www.npmjs.com/package/pkg

Resources