JHipster v7.1.0: Docker compose sub-generator fails, cant fins installed docker compose - jhipster

I have describe my applications and entities including the docker deployment in a jdl file and when running 'jhipster jdl myjdlfile' the apps and entities are generated without error but the docker compose subgenerator fails when the following message;
INFO! Generating 1 deployment.
INFO! Generating deployment docker-compose in a new parallel process
✔ Docker is installed
Found .yo-rc.json config file...
Docker Compose 1.6.0 or later is not installed on your computer.
Read https://docs.docker.com/compose/install/
🐳 Welcome to the JHipster Docker Compose Sub-Generator 🐳
Files will be generated in folder: /<remove intentionally>/docker-compose
Checking Docker images in applications directories...
ls: no such file or directory: /<remove intentionally>/gateway/target/jib-cache
ls: no such file or directory: /<remove intentionally>/backend/target/jib-cache
force ../gateway/.yo-rc.json
force ../backend/.yo-rc.json
force .yo-rc.json
create docker-compose.yml
create README-DOCKER-COMPOSE.md
create central-server-config/application.yml
No change to package.json was detected. No package manager install will be executed.
WARNING! Docker Compose configuration generated, but no Jib cache found
If you forgot to generate the Docker image for this application, please run:
To generate the missing Docker image(s), please run:
./mvnw -ntp -Pprod verify jib:dockerBuild in /<remove intentionally>/gateway
./mvnw -ntp -Pprod verify jib:dockerBuild in /<remove intentionally>/backend
You can launch all your infrastructure by running : docker-compose up -d
Congratulations, JHipster execution is complete!
Sponsored with ❤️ by #oktadev.
INFO! Generator docker-compose child process exited with code 0
Congratulations, JHipster execution is complete!
If I build the projects and run in each project './mvnw -ntp -Pprod verify jib:dockerBuild' everything gets build and I can start all applications with docker-compose.
The part that I do not understand is why it says that "Docker Compose 1.6.0 or later is not installed on your computer"? Since I do have docker-compose installed v2.0.0-beta.6
I have;
Docker version 20.10.7, build f0df350
Docker Compose version v2.0.0-beta.6
openjdk 11.0.11 2021-04-20
OpenJDK Runtime Environment AdoptOpenJDK-11.0.11+9 (build 11.0.11+9)
OpenJDK 64-Bit Server VM AdoptOpenJDK-11.0.11+9 (build 11.0.11+9, mixed mode)
JHipster v7.1.0
Node v16.5.0
npm v7.20.1
The deployment part of the jdl file is;
deployment {
deploymentType docker-compose
appsFolders [gateway, backend]
dockerRepositoryName "carestra"
serviceDiscoveryType eureka
}

Related

Dependencies from Docker image not found in the running container

Background
So I'm trying to set up a Docker container for development, and one of my dependencies is webpack.
Repo Steps:
install this in the image with an npm install webpack.
The image builds successfully
I run it
In the Docker Desktop GUI shell I type webpack -v
Then get output webpack: command not found.
Question
How does it not find the command if it was one of the dependencies installed on the base image?

Jenkins NodeJS plugin: can't execute 'node'

When using the NodeJS tool on a slave that is configured with a global package, the following error is given:
env: can't execute 'node': No such file or directory
If the build runs on an executor in master, there is no error and the package is installed as expected.
I am using the kubernetes plugin with jenkins/jnlp-slave:3.27-1 as the slave image.
Jenkins Version: 2.164.2
Kubernetes Plugin: 1.14.9
NodeJS Plugin: 1.2.9
Note: This is not a duplicate of Jenkins - env: ‘node’: No such file or directory as I am not using the alpine image as was the problem in that question.
Same issue on my Jenkins.
The "download from nodejs.org" installer extracts the node package into a local directory.
It will then run "npm install -g" for each of the packages listed in the "Global npm packages to install" field in the NodeJS installer configuration ("Global tool configuration").
However, it does that before setting the system PATH to the directory where it extracted node, so npm will not find node.
I'm convinced that's a bug in the NodeJS Jenkins plugin. Your options are, as agusluc said, creating a custom jnlp-slave image (which is what I did), or file a bug with the developer of the plugin and hope it will be fixed.

Unable to deploy React Application to Kubernetes

I am trying to deploy an application created using Create-React App to Kubernetes through Docker.
When the docker file tries to create the container using Jenkins pipeline, it fails with the below error :
"Starting the development server...
Failed to compile.
./src/index.js
Module not found: Can't resolve './App.js' in '/app/src'
The folder structure is exactly similar to the default 'create-react app' folder structure.
Also below is the Dockerfile:
FROM node:10.6.0-jessie
# set working directory
RUN mkdir /app
WORKDIR /app
COPY . .
# add `/usr/src/app/node_modules/.bin` to $PATH
#ENV PATH /usr/src/app/node_modules/.bin:$PATH
RUN npm install
#RUN npm install react-scripts -g --silent
# start app
CMD ["npm", "start"]
I am unable to understand where I might be going wrong.
Edit 1: I would also like to mention that I am able to run the docker container on my local machine using this config.
So any help would be appreciated.
Update 1 :
I was able to do a kubectl exec -it pod_name -- bash to the container inside the pod. I found out due to some reason the "App.js" file was getting copied to the container as "app.js". Since linux is case sensitive so it was not able to find the file. Changing the import statement in index.js fixed the problem. But I still have no idea as to what might have caused the file to get copied with a lower-case since in my local the file exists as "App.js".
The problem you're having will be omitted when you adjust your deployment process to a more production-ready setup.
What you're doing currently is installing all (development) dependencies on every Kubernetes node, compiling your application, and then starting a development webserver. This makes your deployed builds inconsistent and increases load and bloat on the deployment nodes.
Instead what you want to do is create a production-ready build by running npm run build on a build machine, which will compile your application and output to the build folder in your project. You then want to transfer this folder to your server in a .zip file, which will need a production-ready webserver installed (Nginx is highly recommended and industry standard) to serve the static files from your build.

How to dockerize React App on Windows Containers

I have a React app that I would like to Dockerize for Windows containers. this my Dockerfile:
FROM stefanscherer/node-windows
# Override the base log level (info).
ENV NPM_CONFIG_LOGLEVEL warn
# Expose port for service
EXPOSE 80
# Install and configure `serve`.
RUN npm install -g serve
# Copy source code to image
COPY . .
# Install dependencies
RUN npm install
# Build app and start server from script
CMD [ "npm", "start" ]
The image is successfully built, but when I try to run it I get this error:
Error response from daemon: container 3b4b9e2bab346bbd95b9dc144429026c1abbe7f4d088f1f10d4c959364f50e9e encountered an error during CreateProcess: failure in a Windows system call: The system cannot find the file specified. (0x2) extra info: {"CommandLine":"npm start","WorkingDirectory":"C:\\","Environment":{"NPM_CONFIG_LOGLEVEL":"warn"},"CreateStdInPipe":true,"CreateStdOutPipe":true,"CreateStdErrPipe":true,"ConsoleSize":[0,0]}.
I am new with Docker so I not sure if I am missing something. Any ideas?
This error probabily is because the image base is nanoserver in this case, and then the react-scripts don't works well. Also the docker images from stefanscherer/node-windows arn't updates (the latest versions of NodeJs in these images are 12.x).
Because this, I made one new docker image with some LTS versions as 14.19.0, 16.17.0 for example.
The docker image is henriqueholtz/node-win, where the tags are the NodeJs versions.
Note: For now, the NodeJs don't have official image to windows container.
In the README in docker hub, you can see one example and the links to some articles with more examples.
See some articles with examples:
How to run ReactJs app on Windows container
How to execute windows container with NodeJs
Below one example to run your create-react-app, for example (obviously, you must change the volume to your folder - use powershell):
docker run -t -p 3000:3000 --name=my-own-cra-windows-container -v C:\Projects\my-own-cra\:C:\app\ henriqueholtz/node-win:16.17.0 cmd /c "npm -v & node -v & npm start"

Node.js Deployment through Elastic Beanstalk using Docker

I am trying to deploy a node.js react based isomorphic application using a Dockerfile linked up to Elastic Beanstalk.
When I run my docker build locally I am able to do so successfully. I have noticed however that the npm install command is taking a fair amount of time to complete.
When trying to deploy the application using the eb deploy command it is pretty much crashing the Amazon service or I get an error like this:
ERROR: Timed out while waiting for command to Complete
My guess is that this is down to my node_modules folder being 300MB big. I have also tried adding an artifact declaration into the config.yml file and deploying that way but get the same error.
Is there a best practice way of deploying a node application to AWS Beanstalk or is the best way to manually setup an EC2 instance and relying on Code Commit git hooks?
My Dockerfile is below:
FROM node:argon
ADD package.json /tmp/package.json
RUN npm config set registry https://registry.npmjs.org/
RUN npm set progress=false
RUN cd /tmp && npm install --silent
RUN mkdir -p /usr/src/app && cp -a /tmp/node_modules /usr/src/app
WORKDIR /usr/src/app
ADD . /usr/src/app
EXPOSE 8000
CMD npm run build && npm run start
...and this is my config.yml file:
branch-defaults:
develop:
environment: staging
master:
environment: production
global:
application_name: website-2016
default_ec2_keyname: key-pair
default_platform: 64bit Amazon Linux 2015.09 v2.0.6 running Docker 1.7.1
default_region: eu-west-1
profile: eb-cli
sc: git
You should change your platform to a more current one (I'm using
docker 1.9.1, and there might be newer versions)
I'm using an image from docker hub to deploy my apps into beanstalk. I build them using our CI servers and then run a deploy
command that pulls the image from docker hub. This can save you a
lot of build errors (and build time) and is actually more in touch with the Docker
philosophy of immutable infrastructure.
300MB for node_modules is not small but should present no problem. We deploy this size of dependencies and code regularly.

Resources