diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml deleted file mode 100644 index 58516fb..0000000 --- a/.github/workflows/deploy.yaml +++ /dev/null @@ -1,26 +0,0 @@ -name: Deploy - -on: - workflow_dispatch: - workflow_run: - workflows: [ "Build dispatcher module", "Build node module" ] - types: - - completed - -jobs: - deploy: - runs-on: ubuntu-latest - if: ${{ github.event.workflow_run.conclusion == 'success' }} - steps: - - name: Checkout repository - uses: actions/checkout@v3 - - - name: Execute remote SSH commands and deploy - uses: appleboy/ssh-action@master - with: - host: ${{ secrets.REMOTE_IP }} - username: ${{ secrets.REMOTE_USER }} - key: ${{ secrets.SSH_PRIVATE_KEY }} - port: ${{ secrets.SSH_PORT }} - script: | - echo "LOL" \ No newline at end of file diff --git a/.github/workflows/dispatcher.yaml b/.github/workflows/dispatcher.yaml index a65f9a5..530874e 100644 --- a/.github/workflows/dispatcher.yaml +++ b/.github/workflows/dispatcher.yaml @@ -10,7 +10,7 @@ on: paths: [ .github/workflows/dispatcher.yaml, dispatcher/** ] jobs: - compile: + build: runs-on: ubuntu-latest steps: @@ -23,72 +23,5 @@ jobs: java-version: '17' distribution: 'temurin' - - name: Run compile - run: mvn -f dispatcher/pom.xml clean compile --no-transfer-progress - check_style: - needs: [ compile ] - runs-on: ubuntu-latest - steps: - - name: Checkout repository - uses: actions/checkout@v3 - - - name: Set up JDK 17 - uses: actions/setup-java@v3 - with: - java-version: '17' - distribution: 'temurin' - - - name: Run Checkstyle - run: mvn -f dispatcher/pom.xml clean checkstyle:check - test: - needs: [ check_style ] - runs-on: ubuntu-latest - steps: - - name: Checkout repository - uses: actions/checkout@v3 - - - name: Set up JDK 17 - uses: actions/setup-java@v3 - with: - java-version: '17' - distribution: 'temurin' - - - name: Run tests - run: mvn -f dispatcher/pom.xml clean test - package: - needs: [ test ] - runs-on: ubuntu-latest - steps: - - name: Checkout repository - uses: actions/checkout@v3 - - - name: Set up JDK 17 - uses: actions/setup-java@v3 - with: - java-version: '17' - distribution: 'temurin' - - - name: Package the application - run: mvn -f dispatcher/pom.xml package - -# deploy: -# runs-on: ubuntu-latest -# needs: build -# -# steps: -# - name: Checkout repository -# uses: actions/checkout@v3 -# -# - name: Set up SSH agent -# uses: webfactory/ssh-agent@v0.8.1 -# with: -# ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }} -# -# - name: Deploy and Run Docker Compose -# run: | -# ssh ${{ secrets.SSH_USERNAME }}@${{ secrets.SSH_HOST }} << 'EOF' -# cd /path/to/your/docker-compose/directory -# docker-compose pull -# docker-compose down -# docker-compose up -d --build -# EOF + - name: Run Build + run: gradle clean build -p ./dispatcher \ No newline at end of file diff --git a/.github/workflows/node.yaml b/.github/workflows/node.yaml index ab560fa..364bc29 100644 --- a/.github/workflows/node.yaml +++ b/.github/workflows/node.yaml @@ -10,7 +10,7 @@ on: paths: [ .github/workflows/node.yaml, node/** ] jobs: - compile: + build: runs-on: ubuntu-latest steps: @@ -23,50 +23,5 @@ jobs: java-version: '17' distribution: 'temurin' - - name: Run compile - run: mvn -f node/pom.xml clean compile --no-transfer-progress - check_style: - needs: [ compile ] - runs-on: ubuntu-latest - steps: - - name: Checkout repository - uses: actions/checkout@v3 - - - name: Set up JDK 17 - uses: actions/setup-java@v3 - with: - java-version: '17' - distribution: 'temurin' - - - name: Run Checkstyle - run: mvn -f node/pom.xml clean checkstyle:check - test: - needs: [ check_style ] - runs-on: ubuntu-latest - steps: - - name: Checkout repository - uses: actions/checkout@v3 - - - name: Set up JDK 17 - uses: actions/setup-java@v3 - with: - java-version: '17' - distribution: 'temurin' - - - name: Run tests - run: mvn -f node/pom.xml clean test - package: - needs: [ test ] - runs-on: ubuntu-latest - steps: - - name: Checkout repository - uses: actions/checkout@v3 - - - name: Set up JDK 17 - uses: actions/setup-java@v3 - with: - java-version: '17' - distribution: 'temurin' - - - name: Package the application - run: mvn -f node/pom.xml package \ No newline at end of file + - name: Run build + run: gradle clean build -p ./node \ No newline at end of file diff --git a/.gitignore b/.gitignore index 4f2c39b..29fa0bd 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,8 @@ +**/.gradle/** +**/gradlew +**/gradlew.bat +**/gradle/** + # Compiled class file *.class *.iml diff --git a/dispatcher/Dockerfile b/dispatcher/Dockerfile index 71989a4..c95163f 100644 --- a/dispatcher/Dockerfile +++ b/dispatcher/Dockerfile @@ -1,15 +1,10 @@ -FROM maven:3.8-openjdk-17-slim +FROM gradle:7.6-jdk17 AS build ENV HOME=/home/app -ENV MVN_SETTINGS=/usr/share/maven/ref/settings.xml -RUN mkdir -p ${HOME} \ - && mkdir -p /usr/share/maven/ref \ - && mkdir -p ${HOME}/dispatcher - -ADD ./properties/settings.xml /usr/share/maven/ref/ +RUN mkdir -p ${HOME} && mkdir -p ${HOME}/dispatcher ADD ./dispatcher ${HOME}/dispatcher -RUN mvn -f ${HOME}/dispatcher/pom.xml -s ${MVN_SETTINGS} clean package +RUN gradle clean build -p ${HOME}/dispatcher -CMD ["java", "-jar", "/home/app/dispatcher/target/dispatcher-0.0.1.jar"] \ No newline at end of file +CMD ["java", "-jar", "/home/app/dispatcher/build/libs/dispatcher-0.0.1.jar"] \ No newline at end of file diff --git a/dispatcher/build.gradle b/dispatcher/build.gradle new file mode 100644 index 0000000..1fcbcd7 --- /dev/null +++ b/dispatcher/build.gradle @@ -0,0 +1,59 @@ +plugins { + id 'java' + id 'org.springframework.boot' version '3.3.0' + id "io.spring.dependency-management" version "1.1.3" +} + +group = 'com.bipbup' +version = '0.0.1' + +java { + toolchain { + languageVersion = JavaLanguageVersion.of(17) + } +} + +configurations { + compileOnly { + extendsFrom annotationProcessor + } + + configureEach { + exclude group: 'org.apache.logging.log4j', module: 'log4j-to-slf4j' + exclude group: 'org.slf4j', module: 'slf4j-log4j12' + } +} + +repositories { + mavenCentral() +} + +dependencies { + implementation('org.springframework.boot:spring-boot-starter-web') { + exclude group: 'org.springframework.boot', module: 'spring-boot-starter-logging' + } + + implementation('org.telegram:telegrambots-spring-boot-starter:6.9.7.1') { + exclude group: 'commons-logging', module: 'commons-logging' + } + + implementation 'org.springframework.kafka:spring-kafka' + + implementation 'org.springframework.boot:spring-boot-starter-log4j2' + + compileOnly 'org.projectlombok:lombok' + annotationProcessor 'org.projectlombok:lombok' +} + +dependencies { + testImplementation 'org.springframework.boot:spring-boot-starter-test' + testCompileOnly 'org.projectlombok:lombok' + testAnnotationProcessor 'org.projectlombok:lombok' +} + +test { + useJUnitPlatform() +} + + + diff --git a/dispatcher/demo.gradle b/dispatcher/demo.gradle deleted file mode 100644 index 30abd9d..0000000 --- a/dispatcher/demo.gradle +++ /dev/null @@ -1,53 +0,0 @@ -plugins { - id 'org.springframework.boot' version '3.3.0' - id 'io.spring.dependency-management' version '1.1.3' - id 'java' -} - -group = 'com.bipbup' -version = '0.0.1' -sourceCompatibility = '17' - -repositories { - mavenCentral() -} - -ext { - telegrambotsVersion = '6.9.7.1' -} - -dependencies { - // Spring Boot Web Starter - implementation 'org.springframework.boot:spring-boot-starter-web' { - exclude group: 'org.springframework.boot', module: 'spring-boot-starter-logging' - } - - // Telegram Bot Integration - implementation "org.telegram:telegrambots-spring-boot-starter:${telegrambotsVersion}" - - // Kafka Support - implementation 'org.springframework.kafka:spring-kafka' - - // Log4j2 for logging - implementation 'org.springframework.boot:spring-boot-starter-log4j2' - - // Lombok for reducing boilerplate code - compileOnly 'org.projectlombok:lombok' - annotationProcessor 'org.projectlombok:lombok' - - // Spring Boot Testing Support - testImplementation 'org.springframework.boot:spring-boot-starter-test' -} - -test { - useJUnitPlatform() -} - -bootJar { - enabled = true -} - -tasks.withType(JavaCompile) { - options.encoding = 'UTF-8' - options.release = 17 -} diff --git a/dispatcher/pom.xml b/dispatcher/pom.xml deleted file mode 100644 index e69483e..0000000 --- a/dispatcher/pom.xml +++ /dev/null @@ -1,120 +0,0 @@ - - - 4.0.0 - - - org.springframework.boot - spring-boot-starter-parent - 3.3.0 - - - - com.bipbup - dispatcher - 0.0.1 - dispatcher-service - Dispatcher Service - - - 17 - 17 - UTF-8 - 6.9.7.1 - 3.3.1 - 10.12.7 - - - - - - org.springframework.boot - spring-boot-starter-web - - - org.springframework.boot - spring-boot-starter-logging - - - - - - - org.telegram - telegrambots-spring-boot-starter - ${telegrambots.version} - - - commons-logging - commons-logging - - - - - - - org.springframework.kafka - spring-kafka - - - - - org.springframework.boot - spring-boot-starter-log4j2 - - - - - org.springframework.boot - spring-boot-starter-test - test - - - - - org.projectlombok - lombok - provided - - - - - - - - org.springframework.boot - spring-boot-maven-plugin - - - - - org.apache.maven.plugins - maven-compiler-plugin - - ${maven.compiler.source} - ${maven.compiler.target} - - - - - org.apache.maven.plugins - maven-checkstyle-plugin - ${maven-checkstyle-plugin.version} - - - com.puppycrawl.tools - checkstyle - ${checkstyle.version} - - - - ../properties/checkstyle.xml - true - true - true - - - - - diff --git a/dispatcher/settings.gradle b/dispatcher/settings.gradle new file mode 100644 index 0000000..92ee83c --- /dev/null +++ b/dispatcher/settings.gradle @@ -0,0 +1,2 @@ +rootProject.name = 'dispatcher' + diff --git a/docker-compose.yml b/docker-compose.yml index 29cec9d..9079249 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -16,8 +16,6 @@ services: build: context: ./ dockerfile: ./dispatcher/Dockerfile -# ports: -# - ${DISPATCHER_PORT}:${DISPATCHER_PORT} environment: DISPATCHER_PORT: ${DISPATCHER_PORT} BOT_URI: ${BOT_URI} @@ -176,7 +174,6 @@ services: - "traefik.http.routers.traefik.service=api@internal" - "traefik.http.services.traefik.loadbalancer.server.port=8088" - # Установка пароля для входа в админку - "traefik.http.middlewares.traefik-auth.basicauth.users=${TRAEFIK_USER}:${TRAEFIK_PASSWORD}" - "traefik.http.routers.traefik.middlewares=traefik-auth" diff --git a/node/Dockerfile b/node/Dockerfile index 6e004b8..e5056d6 100644 --- a/node/Dockerfile +++ b/node/Dockerfile @@ -1,11 +1,10 @@ -FROM maven:3.8-openjdk-17-slim +FROM gradle:7.6-jdk17 AS build ENV HOME=/home/app -ENV MVN_SETTINGS=/usr/share/maven/ref/settings.xml ADD ./properties/settings.xml /usr/share/maven/ref/ ADD ./node ${HOME}/node -RUN mvn -f ${HOME}/node/pom.xml -s ${MVN_SETTINGS} clean package +RUN gradle clean build -p ${HOME}/node -CMD ["java", "-jar", "/home/app/node/target/node-0.0.1.jar"] \ No newline at end of file +CMD ["java", "-jar", "/home/app/node/build/libs/node-0.0.1.jar"] \ No newline at end of file diff --git a/node/demo.gradle b/node/build.gradle similarity index 58% rename from node/demo.gradle rename to node/build.gradle index bf538d4..67eb6f7 100644 --- a/node/demo.gradle +++ b/node/build.gradle @@ -1,30 +1,40 @@ plugins { - id 'org.springframework.boot' version '3.3.0' - id 'io.spring.dependency-management' version '1.1.3' id 'java' + id 'org.springframework.boot' version '3.3.0' + id "io.spring.dependency-management" version "1.1.3" } group = 'com.bipbup' version = '0.0.1' -sourceCompatibility = '17' -repositories { - mavenCentral() +java { + toolchain { + languageVersion = JavaLanguageVersion.of(17) + } +} + +configurations { + compileOnly { + extendsFrom annotationProcessor + } + + configureEach { + exclude group: 'org.apache.logging.log4j', module: 'log4j-to-slf4j' + exclude group: 'org.slf4j', module: 'slf4j-log4j12' + exclude group: 'ch.qos.logback' + } } -ext { - hashidsVersion = '1.0.1' - telegrambotsVersion = '6.9.7.1' +repositories { + mavenCentral() } dependencies { - // Spring Boot Web Starter - implementation 'org.springframework.boot:spring-boot-starter-web' { + implementation('org.springframework.boot:spring-boot-starter-web') { exclude group: 'org.springframework.boot', module: 'spring-boot-starter-logging' } - // Telegram Bot Integration - implementation "org.telegram:telegrambots-spring-boot-starter:${telegrambotsVersion}" + implementation 'org.telegram:telegrambots-spring-boot-starter:6.9.7.1' // Spring Data JPA for ORM implementation 'org.springframework.boot:spring-boot-starter-data-jpa' @@ -42,25 +52,23 @@ dependencies { implementation 'org.liquibase:liquibase-core' // Hashids for ID encoding - implementation "org.hashids:hashids:${hashidsVersion}" + implementation "org.hashids:hashids:1.0.1" + + implementation 'org.springframework.boot:spring-boot-starter-log4j2' - // Lombok for reducing boilerplate code compileOnly 'org.projectlombok:lombok' annotationProcessor 'org.projectlombok:lombok' +} - // Spring Boot Testing Support +dependencies { testImplementation 'org.springframework.boot:spring-boot-starter-test' + testCompileOnly 'org.projectlombok:lombok' + testAnnotationProcessor 'org.projectlombok:lombok' } test { useJUnitPlatform() } -bootJar { - enabled = true -} -tasks.withType(JavaCompile) { - options.encoding = 'UTF-8' - options.release = 17 -} + diff --git a/node/pom.xml b/node/pom.xml deleted file mode 100644 index 7e7de5b..0000000 --- a/node/pom.xml +++ /dev/null @@ -1,140 +0,0 @@ - - - - 4.0.0 - - - org.springframework.boot - spring-boot-starter-parent - 3.3.0 - - - - com.bipbup - node - 0.0.1 - node-service - Node Service - - - 17 - 17 - UTF-8 - 1.0.1 - 6.9.7.1 - 3.3.1 - 10.12.7 - - - - - - org.springframework.boot - spring-boot-starter-web - - - org.springframework.boot - spring-boot-starter-logging - - - - - - - org.telegram - telegrambots-spring-boot-starter - ${telegrambots.version} - - - - - org.springframework.boot - spring-boot-starter-data-jpa - - - - - org.springframework.boot - spring-boot-starter-data-redis - - - - - org.springframework.kafka - spring-kafka - - - - - org.postgresql - postgresql - - - - - org.liquibase - liquibase-core - - - - - org.hashids - hashids - ${hashids.version} - - - - - org.projectlombok - lombok - - - - - org.springframework.boot - spring-boot-starter-test - test - - - - - - - - org.springframework.boot - spring-boot-maven-plugin - - - - - org.apache.maven.plugins - maven-compiler-plugin - - ${maven.compiler.source} - ${maven.compiler.target} - - - - - org.apache.maven.plugins - maven-checkstyle-plugin - ${maven-checkstyle-plugin.version} - - - com.puppycrawl.tools - checkstyle - ${checkstyle.version} - - - - ../properties/checkstyle.xml - true - true - true - - - - - diff --git a/node/settings.gradle b/node/settings.gradle new file mode 100644 index 0000000..484ae9a --- /dev/null +++ b/node/settings.gradle @@ -0,0 +1,2 @@ +rootProject.name = 'node' +