🚀 feat(CI): Ajout de la configuration CI/CD pour l'API Node.js avec Drone CI
continuous-integration/drone/push Build is failing
Details
continuous-integration/drone/push Build is failing
Details
- 🛠️ Ajout du fichier drone.yml avec des étapes pour l'installation, le build, les tests et le déploiement - ✅ Mise en place des scripts de test dans package.json - 🐳 Création du Dockerfile pour le déploiement de l'applicationpull/5/head
parent
451c5edc78
commit
f3bae05a19
@ -0,0 +1,63 @@
|
|||||||
|
kind: pipeline
|
||||||
|
type: docker
|
||||||
|
name: LeftOvers_Api
|
||||||
|
|
||||||
|
trigger:
|
||||||
|
event:
|
||||||
|
- push
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: api-build
|
||||||
|
image: node:latest
|
||||||
|
commands:
|
||||||
|
- cd ./API-Project
|
||||||
|
- npm install
|
||||||
|
- npm run start
|
||||||
|
|
||||||
|
- name: test
|
||||||
|
image: node:latest
|
||||||
|
commands:
|
||||||
|
- cd ./API-Project
|
||||||
|
- npm run test
|
||||||
|
depends_on: [ api-build ]
|
||||||
|
|
||||||
|
- name: docker-build-and-push
|
||||||
|
image: plugins/docker
|
||||||
|
settings:
|
||||||
|
dockerfile: API-Project/Dockerfile
|
||||||
|
context: API-Project
|
||||||
|
registry: hub.codefirst.iut.uca.fr
|
||||||
|
repo: hub.codefirst.iut.uca.fr/rathan.hassou/leftovers_api
|
||||||
|
username:
|
||||||
|
from_secret: SECRET_REGISTRY_USERNAME
|
||||||
|
password:
|
||||||
|
from_secret: SECRET_REGISTRY_PASSWORD
|
||||||
|
depends_on: [ api-build ]
|
||||||
|
|
||||||
|
#container deployment
|
||||||
|
- name: deploy-container
|
||||||
|
image: hub.codefirst.iut.uca.fr/thomas.bellembois/codefirst-dockerproxy-clientdrone:latest
|
||||||
|
environment:
|
||||||
|
IMAGENAME: hub.codefirst.iut.uca.fr/rathan.hassou/leftovers_api:latest
|
||||||
|
CONTAINERNAME: left-over-container
|
||||||
|
COMMAND: create
|
||||||
|
OVERWRITE: true
|
||||||
|
ADMINS: louison.parant,remi.regnault,rayhan.hassou
|
||||||
|
depends_on: [ docker-build-and-push ]
|
||||||
|
|
||||||
|
- name: code-analysis
|
||||||
|
image: node:latest
|
||||||
|
environment:
|
||||||
|
SONAR_TOKEN:
|
||||||
|
from_secret: SONAR_TOKEN_API
|
||||||
|
settings:
|
||||||
|
sources: ./API-Project
|
||||||
|
commands:
|
||||||
|
- export SONAR_SCANNER_VERSION=4.7.0.2747
|
||||||
|
- export SONAR_SCANNER_HOME=$HOME/.sonar/sonar-scanner-$SONAR_SCANNER_VERSION-linux
|
||||||
|
- curl --create-dirs -sSLo $HOME/.sonar/sonar-scanner.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-$SONAR_SCANNER_VERSION-linux.zip
|
||||||
|
- unzip -o $HOME/.sonar/sonar-scanner.zip -d $HOME/.sonar/
|
||||||
|
- export PATH=$SONAR_SCANNER_HOME/bin:$PATH
|
||||||
|
- export SONAR_SCANNER_OPTS="-server"
|
||||||
|
- sonar-scanner -D sonar.projectKey=LeftOvers_Api -D sonar.sources=. -D sonar.host.url=https://codefirst.iut.uca.fr/sonar
|
||||||
|
depends_on: [ api-build ]
|
@ -0,0 +1,21 @@
|
|||||||
|
FROM node:14 AS builder
|
||||||
|
|
||||||
|
WORKDIR /usr/src/app
|
||||||
|
|
||||||
|
COPY package*.json ./
|
||||||
|
RUN npm install
|
||||||
|
|
||||||
|
COPY . .
|
||||||
|
|
||||||
|
RUN npm run build
|
||||||
|
|
||||||
|
FROM node:14
|
||||||
|
|
||||||
|
WORKDIR /usr/src/app
|
||||||
|
|
||||||
|
COPY --from=builder /usr/src/app/node_modules ./node_modules
|
||||||
|
COPY --from=builder /usr/src/app/dist ./dist
|
||||||
|
|
||||||
|
EXPOSE 80
|
||||||
|
|
||||||
|
CMD [ "node", "dist/index.js" ]
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in new issue