ci: implements jenkins deploy

This commit is contained in:
2026-02-21 09:26:25 +01:00
parent b5c8364b47
commit 8e04882983
3 changed files with 130 additions and 0 deletions

83
Jenkinsfile vendored Normal file
View File

@@ -0,0 +1,83 @@
pipeline {
agent any
environment {
APP_NAME = "pablotj-portfolio-web"
REGISTRY_URL = "registry.pablotj.com"
NAMESPACE = "andromeda"
USER = "andromeda"
PASS = credentials('docker-registry-password')
TAG = "latest"
HOST_PORT = "8080"
CONTAINER_PORT = "3000"
}
stages {
stage('Preparar') {
steps {
echo "Limpiando workspace..."
deleteDir()
}
}
stage('Checkout') {
steps {
echo "Clonando repo..."
checkout scm
}
}
stage('Deploy Docker') {
steps {
echo "Usando archivo .env secreto de Jenkins"
// Se copia el secret file a un archivo .env temporal en el workspace
withCredentials([file(credentialsId: 'pablotj-portfolio-website-env', variable: 'SECRET_ENV')]) {
sh 'cp $SECRET_ENV .env'
// Ejecuta el Makefile deploy
sh "${MAKE_CMD} deploy"
}
}
}
stage('Build') {
steps {
echo "Construyendo imagen..."
sh "make build"
}
}
stage('Tag') {
steps {
echo "Tagging imagen..."
sh "make tag"
}
}
stage('Login & Push') {
steps {
echo "Subiendo imagen al registry..."
sh "docker login ${REGISTRY_URL} -u ${USER} -p ${PASS}"
sh "make push"
}
}
stage('Deploy') {
steps {
echo "Deteniendo y levantando contenedor..."
sh "make deploy"
}
}
}
post {
success {
echo "Despliegue completado correctamente"
}
failure {
echo "Ha fallado el pipeline"
}
}
}