add Docker configuration and Jenkins pipeline for application deployment

This commit is contained in:
Vincent Guillet
2025-09-24 11:32:43 +02:00
parent 18f0364e26
commit 2e5b2b3ff5
3 changed files with 126 additions and 0 deletions

9
Dockerfile Normal file
View File

@@ -0,0 +1,9 @@
FROM jenkins/jenkins:lts
USER root
RUN apt update && apt install -y docker.io && apt install -y docker-compose
RUN docker --version
USER jenkins

32
docker-compose.yml Normal file
View File

@@ -0,0 +1,32 @@
services:
spring:
build:
context: ./api
dockerfile: Dockerfile
container_name: gameovergne-api
depends_on:
- mysql
networks:
- gameovergne-app-network
ports:
- "3000:8080"
environment:
- SPRING_IMAGE_NAME=gameovergne-api
- IMAGE_TAG=latest
angular:
build:
context: ./client
dockerfile: Dockerfile
networks:
- gameovergne-app-network
container_name: gameovergne-client
ports:
- "4200:4200"
environment:
- ANGULAR_IMAGE_NAME=gameovergne-client
- IMAGE_TAG=latest
networks:
gameovergne-app-network:
external: true

85
jenkinsfile Normal file
View File

@@ -0,0 +1,85 @@
pipeline {
agent any
tools {
maven 'mvn'
nodejs 'npm'
}
environment {
JAVA_HOME = '/opt/java/openjdk'
PATH = "${JAVA_HOME}/bin:${env.PATH}"
SPRING_IMAGE_NAME = 'spring-jenkins'
ANGULAR_IMAGE_NAME = 'angular-jenkins'
IMAGE_TAG = 'latest'
}
stages {
stage('Checkout sur la branche dev') {
steps {
git branch: 'dev', url: 'https://gitea.unifihomenetwork.com/vincentguillet/gameovergne-app.git'
}
}
stage('Maven Build') {
steps {
dir('api') {
sh 'mvn compile'
}
}
}
stage('Angular Build') {
steps {
dir('client') {
sh 'npm install'
sh 'npm run build'
}
}
}
stage('Maven Test') {
steps {
dir('api') {
sh 'mvn test'
}
}
}
stage('Spring Docker Build') {
steps {
dir('api') {
sh 'docker-compose build spring'
}
}
}
stage('Angular Docker Build') {
steps {
dir('client') {
sh 'docker-compose build angular'
}
}
}
stage('Spring Deployment') {
steps {
sh """
docker-compose stop spring
docker-compose rm spring
docker-compose up -d --no-recreate spring
"""
}
}
stage('Angular Deployment') {
steps {
sh """
docker-compose stop angular
docker-compose rm angular
docker-compose up -d --no-recreate angular
"""
}
}
}
}