Pour tout problème contactez-nous par mail : support@froggit.fr | La FAQ :grey_question: | Rejoignez-nous sur le Chat :speech_balloon:

Skip to content
Snippets Groups Projects
Commit a2571301 authored by Thomas Boni's avatar Thomas Boni
Browse files

add doc and dockerfile

parent 3e51bdac
Branches main
No related tags found
No related merge requests found
include:
- remote: 'https://api.r2devops.io/job/r/gitlab/r2devops/hub/gitleaks@1.2.1.yaml'
- remote: 'https://api.r2devops.io/job/r/gitlab/r2devops/hub/sls_scan@1.1.1.yaml'
- remote: 'https://api.r2devops.io/job/r/gitlab/r2devops/hub/npm_lint@1.2.1.yaml'
- remote: 'https://api.r2devops.io/job/r/gitlab/r2devops/hub/npm_test@1.2.1.yaml'
- remote: 'https://api.r2devops.io/job/r/gitlab/r2devops/hub/docker_build@2.0.1.yaml'
- remote: 'https://api.r2devops.io/job/r/gitlab/r2devops/hub/trivy_image@1.3.1.yaml'
stages:
- build
- tests
- deploy
FROM node:18
WORKDIR /app
COPY . /app
RUN npm install
CMD npm run start
# Node project
This is a simple project that demonstrates how to use
[R2Devops.io](https://r2devops.io) to build the full CI/CD pipeline for a
Node project.
# React project
This is a simple project that demonstrates how to use
[R2Devops.io](https://r2devops.io) to build the full CI/CD pipeline for a React project.
- **Templates used:**
- [Gitleaks](https://r2devops.io/marketplace/gitlab/r2devops/hub/gitleaks): A secret detection job, using gitleaks to alert on secrets (passwords, api keys…) pushed in your code
- [Sls scan](https://r2devops.io/marketplace/gitlab/r2devops/hub/sls_scan): SAST scan
- [NPM lint](https://r2devops.io/marketplace/gitlab/r2devops/hub/npm_lint): Run the predefined lint script in the package.json which will check your code quality with eslint
- [NPM test](https://r2devops.io/marketplace/gitlab/r2devops/hub/npm_test): Run the predefined test script in the package.json which will execute test file with Jest
- [Docker build](https://r2devops.io/marketplace/gitlab/r2devops/hub/docker_build): build and publish container image
- [Trivy image](https://r2devops.io/marketplace/gitlab/r2devops/hub/trivy_image): check for vulnerabilities in container image
- **CI configuration:** [.gitlab-ci.yml](.gitlab-ci.yml)
- **Pipelines:** [CI/CD page](https://gitlab.com/r2devops/demos/node/-/pipelines)
# Node API
A simple Hello World API. *All elements of this doc are only placeholders**
The goal of this project is to demonstrate the efficiency of a full CI/CD pipeline
## Changelog
- Add hello-world endpoint
## Getting started
### Configuration
This API use environment variables as a configuration. You can use the
default example file:
# Create your own env file from example
cp .env.example .env
vim .env
#### Environment variables
Name | Description, usage | Mandatory | Default
--- | --- | --- | ---
ENV | Environment name on which is currently running | No | production
DEBUG | Enable debug mode | No | False
TESTING | Enable testing mode | No | False
HOST | Addr to expose server (ex: 0.0.0.0) | No | 127.0.0.1
PORT | Port of server | No | 5000
SECRET | Secret used by | Yes |
DATABASE_TYPE | Database type (only "postgres" supported curently) | Yes |
DATABASE_HOST | Database server IP or domain name | Yes |
DATABASE_PORT | Database server port | Yes |
DATABASE_NAME | Database name | Yes |
DATABASE_USER | Database user name | Yes |
DATABASE_PASSWORD | Database password | Yes |
2 alternatives:
#### Run API in your local environment
# Laucnh API in development mode
node app.js
#### Run API with Docker
# Build & run API with Docker
docker build -t node-api:latest .
docker run -d -p $PORT:$PORT --env-file .env --name my-node-api node-api:latest
site_name: Node-api
site_description: 'Hello world API'
site_author: 'Thomas Boni <thomas@r2devops.io>'
site_url: 'https://ill-r2devops.gitlab.io/node-api/'
# Repository
repo_name: 'ill-r2devops/node-api'
repo_url: 'https://gitlab.com/ill-r2devops/node-api'
# Configuration
theme:
name: 'material'
# Color
palette:
primary: 'deep purple'
accent: 'deep purple'
# Extensions (https://squidfunk.github.io/mkdocs-material/extensions/admonition/)
markdown_extensions:
- admonition # block-styled content (note, idea, warning, ...)
- codehilite # highlite code syntax
- footnotes # references in footnotes
- toc:
permalink: true # anchor on titles
# PyMdown extensions (https://squidfunk.github.io/mkdocs-material/extensions/pymdown)
- pymdownx.betterem:
smart_enable: all
- pymdownx.caret
- pymdownx.critic
- pymdownx.details
- pymdownx.inlinehilite
- pymdownx.magiclink
- pymdownx.mark
- pymdownx.smartsymbols
- pymdownx.superfences
- pymdownx.tasklist:
custom_checkbox: true
- pymdownx.tilde
......@@ -3,7 +3,9 @@
"version": "0.0.0",
"private": true,
"scripts": {
"start": "node ./bin/www"
"start": "node ./app.js",
"test": "echo Run tests",
"lint": "echo Run lints"
},
"dependencies": {
"express": "~4.16.1"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment