Let’s Chat example
Create Docker images for Node/Express.js applications
Let’s Chat is self-hosted chat app for small to big teams.
The example Node.JS project
You can see the example project at https://github.com/codefreshdemo/demochat. The repository contains the source code of the project along with two Dockerfiles (one for unit tests) and various docker-compose configurations
The project requires a Mongo Database to work and by default it uses port 5000 for its web interface.
Create a CI pipeline for Node.js
Creating a CI/CD pipeline for NodeJS is very easy, because Codefresh has built-in steps for creating Docker images and running commands with containers.
Here is the full pipeline that creates the Docker image after checking out the code.
codefresh.yml
Note that you should change
codefreshdemo
in the clone step with your own Github account if you fork the repository. Also in both build steps you should changecodefreshdemo/demochat
with your own image name that is compliant to your Dockerhub account or other connected registry.
This pipeline has 4 stages and performs the following:
- Clones the source code using the git-clone step
- Builds a Docker image for unit tests with the build step
- Runs unit tests in the Docker image that was just created with a freestyle step
- Building a Docker image for the final application
- Runs integration tests using a composition step
If you run the pipeline multiple times, you will also see the Codefresh caching mechanisms in action for faster build times.
Related articles
Voting app example
Codefresh YAML for pipeline definitions
Steps in pipelines
Creating pipelines
How Codefresh pipelines work