ci: implements jenkins deploy

This commit is contained in:
2026-02-21 10:47:21 +01:00
parent 4e72e6da77
commit 83070ccbda
4 changed files with 47 additions and 14 deletions

View File

@@ -1,16 +1,47 @@
# Stage 1: Build # --- Stage 1: Build & Dependencies ---
FROM maven:3.9-eclipse-temurin-21-alpine AS build FROM maven:3.9-eclipse-temurin-21-alpine AS build
WORKDIR /app WORKDIR /app
# Copiamos todo el proyecto # 1. Copiamos los archivos de configuración (Estructura de poms)
COPY . . COPY pom.xml .
COPY application/pom.xml ./application/
COPY bootstrap/pom.xml ./bootstrap/
COPY domain/pom.xml ./domain/
COPY infrastructure/pom.xml ./infrastructure/
# Compilamos todo el proyecto (todos los módulos) # 2. Descargamos dependencias (Cacheamos esta capa)
RUN mvn clean package -DskipTests # Usamos install de los poms para que los módulos se reconozcan entre sí
RUN mvn dependency:go-offline -B
# Stage 2: Run # 3. Copiamos el código fuente y compilamos
FROM openjdk:21-jdk COPY application/src ./application/src
COPY bootstrap/src ./bootstrap/src
COPY domain/src ./domain/src
COPY infrastructure/src ./infrastructure/src
RUN mvn clean package -DskipTests -B
# --- Stage 2: Run (Imagen final ligera) ---
FROM eclipse-temurin:21-jre-alpine
WORKDIR /app WORKDIR /app
# Seguridad: Usuario no-root
RUN addgroup -S spring && adduser -S spring -G spring
USER spring:spring
# Copiamos solo el JAR final (ajustado a tu módulo bootstrap)
COPY --from=build /app/bootstrap/target/*.jar app.jar COPY --from=build /app/bootstrap/target/*.jar app.jar
# Configuración de Memoria y Rendimiento para Microservicios
# -XX:+UseSerialGC: Menos consumo de RAM para apps < 1GB
# -XX:TieredStopAtLevel=1: Arranque más rápido y menos uso de RAM del compilador JIT
# -XX:MaxRAMPercentage: Se ajusta dinámicamente al límite de Docker
ENV JAVA_OPTS="-XX:+UseContainerSupport \
-XX:MaxRAMPercentage=75.0 \
-XX:+UseSerialGC \
-XX:TieredStopAtLevel=1 \
-Xms128m"
EXPOSE 80 EXPOSE 80
ENTRYPOINT ["java", "-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005", "-Xmx512m", "-Xms256m", "-jar", "app.jar"]
ENTRYPOINT ["sh", "-c", "java $JAVA_OPTS -jar app.jar"]

3
Jenkinsfile vendored
View File

@@ -70,5 +70,8 @@ pipeline {
failure { failure {
echo "❌ Pipeline failed!" echo "❌ Pipeline failed!"
} }
always {
deleteDir()
}
} }
} }

View File

@@ -1,3 +1,4 @@
STACK=pablotj-portfolio
APP_NAME=pablotj-portfolio-api APP_NAME=pablotj-portfolio-api
IMAGE_NAME=$(APP_NAME) IMAGE_NAME=$(APP_NAME)
@@ -6,7 +7,7 @@ NAMESPACE=andromeda
TAG?=latest TAG?=latest
HOST_PORT=8181 HOST_PORT=8181
CONTAINER_PORT=80 CONTAINER_PORT=8080
IMAGE_FULL=$(REGISTRY_URL)/$(NAMESPACE)/$(IMAGE_NAME):$(TAG) IMAGE_FULL=$(REGISTRY_URL)/$(NAMESPACE)/$(IMAGE_NAME):$(TAG)
@@ -22,6 +23,9 @@ push:
run: run:
docker run -d \ docker run -d \
--name $(APP_NAME) \ --name $(APP_NAME) \
--label com.docker.compose.service="$(APP_NAME)" \
--label com.docker.compose.project="$(STACK)" \
--network andromeda \
-p $(HOST_PORT):$(CONTAINER_PORT) \ -p $(HOST_PORT):$(CONTAINER_PORT) \
--env-file .env \ --env-file .env \
$(IMAGE_FULL) $(IMAGE_FULL)

View File

@@ -124,11 +124,6 @@ alter table if exists experience_skill
foreign key (experience_id) foreign key (experience_id)
references experience; references experience;
alter table if exists profile_social_link
add constraint FKfh1pbfvvg3palcr1yip6jffik
foreign key (PROFILE_ID)
references profile;
alter table if exists project_feature alter table if exists project_feature
add constraint FKdifppyvrfito5in15ox4db0up add constraint FKdifppyvrfito5in15ox4db0up
foreign key (project_id) foreign key (project_id)