A web development codebase integrated with a modularized CI/CD pipeline.
- Develop – Dev codebase running via Docker Compose, mimicking production for development.
- Build – Jenkins with build and push jobs using Docker-in-Docker (DIND) to build and push artifacts.
- Deploy – Pulling the artifact and running it.
- Update – A background service that updates to newer versions automatically.
The website is built using Three.js, a WebGL framework. For development purposes, Docker Compose is used to mount the codebase along with environment variables and configurations, providing features such as hot reload.
Jenkins and Docker are used together in a multi-stage build process. Jenkins jobs like pweb_build (which uses the host's Docker daemon to build the artifact) and pweb_push (which pushes the build to a defined registry) are mounted during the artifact build.
A cloud VM instance with Docker is kept running with two containers:
- One for the deployable build created in the build phase.
- The other for Watchtower, which handles automatic deployments. It monitors the registry and pulls new builds (on push), replacing the old versions with the same configurations and performing graceful shutdowns.
The entire pipeline is abstracted in pweb.yml, a Docker Compose file with multiple configured environments. Profiles are defined to spawn different environments as needed—such as development for local development, build for the build phase, and deploy and update for deployment on the cloud.
(assumed user in present inside the cloned repo)
To spawn the environment ANY
docker-compose -f pweb.yml --profile ${DESIRED-ENV} upTo spawn the environment for development
docker-compose -f pweb.yml --profile development upTo spawn the environment for creatinfg and pushing builds
docker-compose -f pweb.yml --profile build upTo spawn complete pipeline
docker-compose -f pweb.yml --profile pweb up