This is a basic project for Devops test of Affluences. It consists of a REST API for a TODO list app.
- Run the project
- Fix the tests in
/tests
- Write a
Dockerfile
anddocker-compose.yml
- Deploy a simple Prometheus + Grafana visualization stack
- Write a
.gitlab-ci.yml
to run the tests and build the Docker image
/src
: project source code/tests
: test suite/metrics
: files needed to setup the visualization stack
GET /tasks
: retrieve all tasksGET /tasks/:id
: retrieve a single taskPOST /tasks
: add a new taskPUT /tasks/:id
: edit an existing taskDELETE /tasks/:id
: delete an existing task
This app can expose Prometheus metrics when setting the following environment variables : ENABLE_METRICS=true
and PROM_TOKEN=<random string>
The metrics will be available at /metrics
when authenticated using the header Authorization: Bearer <your token>
Use the package manager npm, yarn or pnpm to install dependencies.
[npm|yarn|pnpm] install
There is a .env file at the root of the file, do not forget to edit the values
# Run in watch mode
[npm|yarn|pnpm] run dev
# Build the project
[npm|yarn|pnpm] run build
# Run the built result
[npm|yarn|pnpm] run start
# Run the test suite
[npm|yarn|pnpm] run test
This will check dockerfile syntax, build the project, and make a production image based on alpine.
IMAGENAME="$my-image-name" ./build_dockerfile.sh
docker run --rm -d -p $PORT:$PORT "$my-image-name"
find $PORT
value in .env
.