Gitlab CI/CD Pipeline
This commit is contained in:
48
backend/.gitlab-ci.yml
Normal file
48
backend/.gitlab-ci.yml
Normal file
@@ -0,0 +1,48 @@
|
||||
build_backend:
|
||||
stage: build
|
||||
image: maven:3.9.9-eclipse-temurin-21@sha256:2e3824afeb41f61761adee95318814e6669bd59aaf61255b2af47064b8755c02
|
||||
script:
|
||||
- cd backend
|
||||
- mvn package
|
||||
artifacts:
|
||||
paths:
|
||||
- backend/common/target/
|
||||
- backend/gateway/target/
|
||||
- backend/discovery/target/
|
||||
- backend/server/target
|
||||
expire_in: 1 hour
|
||||
|
||||
docker_common:
|
||||
extends: .docker-common-template
|
||||
variables:
|
||||
IMAGE_NAME: common
|
||||
WORKDIR_PATH: backend
|
||||
DOCKERFILE_PATH: Dockerfile.base
|
||||
needs:
|
||||
- build_backend
|
||||
|
||||
docker_gateway:
|
||||
extends: .docker-build-template
|
||||
variables:
|
||||
IMAGE_NAME: gateway
|
||||
COMMON_IMAGE: "$CI_REGISTRY/$CI_PROJECT_PATH/common"
|
||||
WORKDIR_PATH: backend
|
||||
DOCKERFILE_PATH: Dockerfile.app
|
||||
BUILD_FOLDER: "gateway/target"
|
||||
MAIN_CLASS: dev.rheinsw.gateway.GatewayApplication
|
||||
needs:
|
||||
- build_backend
|
||||
- docker_common
|
||||
|
||||
docker_server:
|
||||
extends: .docker-build-template
|
||||
variables:
|
||||
IMAGE_NAME: server
|
||||
COMMON_IMAGE: "$CI_REGISTRY/$CI_PROJECT_PATH/common"
|
||||
WORKDIR_PATH: backend
|
||||
DOCKERFILE_PATH: Dockerfile.app
|
||||
BUILD_FOLDER: "server/target"
|
||||
MAIN_CLASS: dev.rheinsw.server.ServerApplication
|
||||
needs:
|
||||
- build_backend
|
||||
- docker_common
|
||||
32
backend/Dockerfile.app
Normal file
32
backend/Dockerfile.app
Normal file
@@ -0,0 +1,32 @@
|
||||
# Dockerfile.app
|
||||
|
||||
ARG COMMON_IMAGE
|
||||
FROM ${COMMON_IMAGE}
|
||||
|
||||
ARG BUILD_FOLDER
|
||||
ARG MAIN_CLASS
|
||||
ARG IMAGE_NAME
|
||||
ARG IMAGE_TAG
|
||||
|
||||
ENV BUILD_FOLDER=${BUILD_FOLDER}
|
||||
ENV MAIN_CLASS=${MAIN_CLASS}
|
||||
ENV IMAGE_NAME=${IMAGE_NAME}
|
||||
ENV IMAGE_TAG=${IMAGE_TAG}
|
||||
|
||||
# Log ARGs at build time
|
||||
RUN echo "BUILD_FOLDER: ${BUILD_FOLDER}" && \
|
||||
echo "MAIN_CLASS: ${MAIN_CLASS}" && \
|
||||
echo "IMAGE_NAME: ${IMAGE_NAME}" && \
|
||||
echo "IMAGE_TAG: ${IMAGE_TAG}"
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Copy artifacts (relative to /app)
|
||||
COPY ${BUILD_FOLDER}/${IMAGE_NAME}-*.jar app.jar
|
||||
COPY ${BUILD_FOLDER}/libs/ libs/
|
||||
|
||||
# Copy and set entrypoint (relative to /app)
|
||||
COPY entrypoint.sh entrypoint.sh
|
||||
RUN chmod +x entrypoint.sh
|
||||
|
||||
ENTRYPOINT ["./entrypoint.sh"]
|
||||
6
backend/Dockerfile.base
Normal file
6
backend/Dockerfile.base
Normal file
@@ -0,0 +1,6 @@
|
||||
# Dockerfile.base
|
||||
FROM eclipse-temurin:21-jre
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY common/target/common-*.jar libs/common.jar
|
||||
@@ -1,32 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>dev.rheinsw</groupId>
|
||||
<artifactId>backend</artifactId>
|
||||
<version>1.0.0</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>discovery</artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>21</maven.compiler.source>
|
||||
<maven.compiler.target>21</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
@@ -1,19 +0,0 @@
|
||||
package dev.rheinsw.discovery;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;
|
||||
|
||||
/**
|
||||
* @author Bummsa / BoomerHD / Thatsaphorn Atchariyaphap
|
||||
* @since 21.04.25
|
||||
*/
|
||||
@SpringBootApplication
|
||||
@EnableEurekaServer
|
||||
public class DiscoveryServerApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(DiscoveryServerApplication.class, args);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
server:
|
||||
port: 8761
|
||||
|
||||
spring:
|
||||
application:
|
||||
name: discovery-server
|
||||
|
||||
eureka:
|
||||
client:
|
||||
register-with-eureka: false
|
||||
fetch-registry: false
|
||||
server:
|
||||
wait-time-in-ms-when-sync-empty: 0
|
||||
26
backend/entrypoint.sh
Normal file
26
backend/entrypoint.sh
Normal file
@@ -0,0 +1,26 @@
|
||||
#!/bin/sh
|
||||
|
||||
echo "---------------------------"
|
||||
echo "Starting Java Application"
|
||||
echo "Main class : ${MAIN_CLASS}"
|
||||
echo "App JAR : app.jar"
|
||||
echo "Libs folder : libs/"
|
||||
echo "Detected JARs in libs/:"
|
||||
find libs -type f -name "*.jar" -exec echo " -> {}" \;
|
||||
|
||||
if [ ! -f app.jar ]; then
|
||||
echo "ERROR: app.jar not found. Ensure it is copied into the container."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Build classpath string
|
||||
CLASSPATH="app.jar"
|
||||
for jar in libs/*.jar; do
|
||||
CLASSPATH="$CLASSPATH:$jar"
|
||||
done
|
||||
|
||||
echo "---------------------------"
|
||||
echo "Executing: java -cp \"$CLASSPATH\" $MAIN_CLASS"
|
||||
echo "---------------------------"
|
||||
|
||||
exec java -cp "$CLASSPATH" "$MAIN_CLASS"
|
||||
@@ -18,14 +18,55 @@
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>${maven.compiler.plugin.version}</version>
|
||||
<configuration>
|
||||
<source>${maven.compiler.source}</source>
|
||||
<target>${maven.compiler.target}</target>
|
||||
<annotationProcessorPaths>
|
||||
<path>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>${lombok.version}</version>
|
||||
</path>
|
||||
</annotationProcessorPaths>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-dependency-plugin</artifactId>
|
||||
<version>3.6.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>copy-dependencies</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>copy-dependencies</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<outputDirectory>${project.build.directory}/libs</outputDirectory>
|
||||
<includeScope>runtime</includeScope>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-gateway</artifactId>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/com.github.ben-manes.caffeine/caffeine -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
|
||||
<groupId>com.github.ben-manes.caffeine</groupId>
|
||||
<artifactId>caffeine</artifactId>
|
||||
<version>3.2.0</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Tools -->
|
||||
|
||||
@@ -1,11 +1,6 @@
|
||||
server:
|
||||
port: 8080
|
||||
|
||||
eureka:
|
||||
client:
|
||||
service-url:
|
||||
defaultZone: http://localhost:8761/eureka/
|
||||
|
||||
spring:
|
||||
application:
|
||||
name: gateway
|
||||
@@ -16,7 +11,7 @@ spring:
|
||||
gateway:
|
||||
routes:
|
||||
- id: server
|
||||
uri: lb://server
|
||||
uri: http://localhost:8081
|
||||
predicates:
|
||||
- Path=/api/**
|
||||
filters:
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
|
||||
<modules>
|
||||
<module>common</module>
|
||||
<module>discovery</module>
|
||||
<module>gateway</module>
|
||||
<module>server</module>
|
||||
</modules>
|
||||
|
||||
@@ -36,6 +36,28 @@
|
||||
</annotationProcessorPaths>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-dependency-plugin</artifactId>
|
||||
<version>3.6.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>copy-dependencies</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>copy-dependencies</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<outputDirectory>${project.build.directory}/libs</outputDirectory>
|
||||
<includeScope>runtime</includeScope>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<!-- <plugin>-->
|
||||
<!-- <groupId>org.springframework.boot</groupId>-->
|
||||
<!-- <artifactId>spring-boot-maven-plugin</artifactId>-->
|
||||
<!-- </plugin>-->
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
@@ -45,10 +67,6 @@
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-mail</artifactId>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package dev.rheinsw.server.contact.controller;
|
||||
|
||||
import dev.rheinsw.server.contact.domain.model.ContactRequestDto;
|
||||
import dev.rheinsw.server.contact.model.ContactRequestDto;
|
||||
import dev.rheinsw.server.contact.usecase.SubmitContactUseCase;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package dev.rheinsw.server.contact.domain.model;
|
||||
package dev.rheinsw.server.contact.model;
|
||||
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
@@ -1,4 +1,4 @@
|
||||
package dev.rheinsw.server.contact.domain.model;
|
||||
package dev.rheinsw.server.contact.model;
|
||||
|
||||
import dev.rheinsw.shared.transport.Dto;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package dev.rheinsw.server.contact.domain.model;
|
||||
package dev.rheinsw.server.contact.model;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
@@ -1,6 +1,6 @@
|
||||
package dev.rheinsw.server.contact.repository;
|
||||
|
||||
import dev.rheinsw.server.contact.domain.model.ContactRequest;
|
||||
import dev.rheinsw.server.contact.model.ContactRequest;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package dev.rheinsw.server.contact.usecase;
|
||||
|
||||
import dev.rheinsw.server.contact.domain.model.ContactRequestDto;
|
||||
import dev.rheinsw.server.contact.model.ContactRequestDto;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package dev.rheinsw.server.contact.usecase;
|
||||
|
||||
import dev.rheinsw.server.contact.domain.model.ContactRequest;
|
||||
import dev.rheinsw.server.contact.domain.model.ContactRequestDto;
|
||||
import dev.rheinsw.server.contact.model.ContactRequest;
|
||||
import dev.rheinsw.server.contact.model.ContactRequestDto;
|
||||
import dev.rheinsw.server.contact.repository.ContactRequestsRepo;
|
||||
import dev.rheinsw.server.contact.util.HCaptchaValidator;
|
||||
import dev.rheinsw.server.mail.domain.MailRequest;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package dev.rheinsw.server.contact.util;
|
||||
|
||||
import dev.rheinsw.server.contact.domain.model.HCaptchaConfig;
|
||||
import dev.rheinsw.server.contact.model.HCaptchaConfig;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
server:
|
||||
port: 0 # random port
|
||||
port: 8081
|
||||
|
||||
spring:
|
||||
application:
|
||||
name: server
|
||||
datasource:
|
||||
url: jdbc:postgresql://localhost:5432/rheinsw_dev
|
||||
username: rheinsw
|
||||
password: rheinsw
|
||||
url: jdbc:postgresql://${DB_HOST}:${DB_PORT}/${DB_NAME}
|
||||
username: ${DB_USERNAME}
|
||||
password: ${DB_PASSWORD}
|
||||
|
||||
jpa:
|
||||
hibernate:
|
||||
@@ -20,8 +20,8 @@ spring:
|
||||
mail:
|
||||
host: smtp.resend.com
|
||||
port: 587
|
||||
username: resend
|
||||
password: re_JnLD5ndg_GnKtXcTqskXm1bg7Wxnghna3
|
||||
username: ${MAIL_USERNAME}
|
||||
password: ${MAIL_PASSWORD}
|
||||
properties:
|
||||
mail:
|
||||
smtp:
|
||||
@@ -30,15 +30,10 @@ spring:
|
||||
enable: true
|
||||
default-encoding: UTF-8
|
||||
|
||||
eureka:
|
||||
client:
|
||||
service-url:
|
||||
defaultZone: http://localhost:8761/eureka/
|
||||
|
||||
hcaptcha:
|
||||
secret: ES_ff59a664dc764f92870bf2c7b4eab7c5
|
||||
secret: ${HCAPTCHA_SECRET}
|
||||
|
||||
logging:
|
||||
level:
|
||||
org.hibernate.SQL: DEBUG
|
||||
org.hibernate.type.descriptor.sql.BasicBinder: TRACE
|
||||
org.hibernate.SQL: ${LOG_SQL_LEVEL}
|
||||
org.hibernate.type.descriptor.sql.BasicBinder: ${LOG_BINDER_LEVEL}
|
||||
Reference in New Issue
Block a user