From 21eec17576b24039974c793ae98109b4ff416413 Mon Sep 17 00:00:00 2001 From: Struchkov Mark Date: Sun, 4 Dec 2022 11:43:40 +0300 Subject: [PATCH 1/6] =?UTF-8?q?=D0=A3=D0=B4=D0=B0=D0=BB=D0=B8=D0=BB=20?= =?UTF-8?q?=D0=BB=D0=B8=D1=88=D0=BD=D0=B8=D0=B5=20=D0=BF=D1=80=D0=BE=D0=BF?= =?UTF-8?q?=D0=B5=D1=80=D1=82=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gitlab-app/src/main/resources/application.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/gitlab-app/src/main/resources/application.yml b/gitlab-app/src/main/resources/application.yml index d0c4dd7..f991e5d 100644 --- a/gitlab-app/src/main/resources/application.yml +++ b/gitlab-app/src/main/resources/application.yml @@ -1,5 +1,3 @@ -server: - port: 8018 spring: datasource: url: ${DATASOURCE_URL} From b8edeac40478afea9312669b73847b8c2e49e73c Mon Sep 17 00:00:00 2001 From: Struchkov Mark Date: Sun, 4 Dec 2022 11:54:36 +0300 Subject: [PATCH 2/6] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D0=BB?= =?UTF-8?q?=20Dockerfile=20=D0=B8=20docker-compose.yml?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 37 +++++++++++++++++++++++++ gitlab-app/Dockerfile => Dockerfile-old | 6 ++-- docker-compose-dev.yml | 29 +++++++++++++++++++ docker-compose.yml | 31 +++++++++++++++++++++ pom.xml | 2 +- 5 files changed, 101 insertions(+), 4 deletions(-) create mode 100644 Dockerfile rename gitlab-app/Dockerfile => Dockerfile-old (90%) create mode 100644 docker-compose-dev.yml create mode 100644 docker-compose.yml diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..1c3ba0a --- /dev/null +++ b/Dockerfile @@ -0,0 +1,37 @@ +FROM eclipse-temurin:17 as app-build +ENV RELEASE=17 + +WORKDIR /opt/build +COPY ./gitlab-app/target/gitlab-notification.jar ./application.jar + +RUN java -Djarmode=layertools -jar application.jar extract +RUN $JAVA_HOME/bin/jlink \ + --add-modules `jdeps --ignore-missing-deps -q -recursive --multi-release ${RELEASE} --print-module-deps -cp 'dependencies/BOOT-INF/lib/*' application.jar`,jdk.crypto.cryptoki \ + --strip-debug \ + --no-man-pages \ + --no-header-files \ + --compress=2 \ + --output jdk + +FROM debian:buster-slim + +ARG BUILD_PATH=/opt/build +ENV JAVA_HOME=/opt/jdk +ENV PATH "${JAVA_HOME}/bin:${PATH}" +ENV TELEGRAM_PERSON_ID=TELEGRAM_PERSON_ID DATASOURCE_URL=DATASOURCE_URL \ + DATASOURCE_PASSWORD=DATASOURCE_PASSWORD DATASOURCE_USERNAME=DATASOURCE_USERNAME \ + GITLAB_PERSONAL_TOKEN=GITLAB_PERSONAL_TOKEN TELEGRAM_BOT_TOKEN=TELEGRAM_BOT_TOKEN \ + TELEGRAM_BOT_USERNAME=TELEGRAM_BOT_USERNAME GITLAB_URL=GITLAB_URL GITLAB_REPLACE_URL=GITLAB_REPLACE_URL + +RUN groupadd --gid 1000 spring-app \ + && useradd --uid 1000 --gid spring-app --shell /bin/bash --create-home spring-app + +USER spring-app:spring-app +WORKDIR /opt/workspace + +COPY --from=app-build $BUILD_PATH/jdk $JAVA_HOME +COPY --from=app-build $BUILD_PATH/spring-boot-loader/ ./ +COPY --from=app-build $BUILD_PATH/dependencies/ ./ +COPY --from=app-build $BUILD_PATH/application/ ./ + +ENTRYPOINT java -DTELEGRAM_BOT_USERNAME=$TELEGRAM_BOT_USERNAME -DTELEGRAM_BOT_TOKEN=$TELEGRAM_BOT_TOKEN -DTELEGRAM_PERSON_ID=$TELEGRAM_PERSON_ID -DDATASOURCE_URL=$DATASOURCE_URL -DDATASOURCE_PASSWORD=$DATASOURCE_PASSWORD -DDATASOURCE_USERNAME=$DATASOURCE_USERNAME -DGITLAB_PERSONAL_TOKEN=$GITLAB_PERSONAL_TOKEN -DGITLAB_URL=$GITLAB_URL -DGITLAB_REPLACE_URL=$GITLAB_REPLACE_URL org.springframework.boot.loader.JarLauncher \ No newline at end of file diff --git a/gitlab-app/Dockerfile b/Dockerfile-old similarity index 90% rename from gitlab-app/Dockerfile rename to Dockerfile-old index 06b6cf3..b54c4db 100644 --- a/gitlab-app/Dockerfile +++ b/Dockerfile-old @@ -1,12 +1,12 @@ -FROM openjdk:17.0.2-jdk-slim-buster -MAINTAINER uPagge +FROM amazoncorretto:17.0.5 +MAINTAINER uPagge RUN apt upgrade && addgroup gitlabbot --disabled-password && \ adduser gitlabbot --ingroup gitlabbot && \ mkdir -p /bot && \ chown -R gitlabbot:gitlabbot /bot WORKDIR /bot USER gitlabbot:gitlabbot -COPY target/gitlab-notification.jar app.jar +COPY gitlab-app/target/gitlab-notification.jar app.jar ENV TELEGRAM_PERSON_ID=TELEGRAM_PERSON_ID DATASOURCE_URL=DATASOURCE_URL \ DATASOURCE_PASSWORD=DATASOURCE_PASSWORD DATASOURCE_USERNAME=DATASOURCE_USERNAME \ GITLAB_PERSONAL_TOKEN=GITLAB_PERSONAL_TOKEN TELEGRAM_BOT_TOKEN=TELEGRAM_BOT_TOKEN \ diff --git a/docker-compose-dev.yml b/docker-compose-dev.yml new file mode 100644 index 0000000..f28cabc --- /dev/null +++ b/docker-compose-dev.yml @@ -0,0 +1,29 @@ +version: '3.3' + +services: + + database: + image: postgres:15.1-alpine + environment: + POSTGRES_DB: "gitlab_bot" + POSTGRES_USER: "postgres" + POSTGRES_PASSWORD: ${DATASOURCE_PASSWORD} + volumes: + - database:/var/lib/postgresql/data/ + + gitlab-bot: + build: . + depends_on: + - database + environment: + TELEGRAM_BOT_TOKEN: ${TELEGRAM_BOT_TOKEN} + TELEGRAM_BOT_USERNAME: ${TELEGRAM_BOT_USERNAME} + GITLAB_PERSONAL_TOKEN: ${GITLAB_PERSONAL_TOKEN} + TELEGRAM_PERSON_ID: ${TELEGRAM_PERSON_ID} + GITLAB_URL: ${GITLAB_URL} + DATASOURCE_URL: "jdbc:postgresql://database:5432/gitlab_bot" + DATASOURCE_USERNAME: "postgres" + DATASOURCE_PASSWORD: ${DATASOURCE_PASSWORD} + +volumes: + database: \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..9562991 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,31 @@ +version: '3.3' + +services: + + database: + image: postgres:15.1-alpine + restart: always + environment: + POSTGRES_DB: "gitlab_bot" + POSTGRES_USER: "postgres" + POSTGRES_PASSWORD: ${DATASOURCE_PASSWORD} + volumes: + - database:/var/lib/postgresql/data/ + + gitlab-bot: + image: upagge/gitlab-telegram-notify:latest + restart: always + depends_on: + - database + environment: + TELEGRAM_BOT_TOKEN: ${TELEGRAM_BOT_TOKEN} + TELEGRAM_BOT_USERNAME: ${TELEGRAM_BOT_USERNAME} + GITLAB_PERSONAL_TOKEN: ${GITLAB_PERSONAL_TOKEN} + TELEGRAM_PERSON_ID: ${TELEGRAM_PERSON_ID} + GITLAB_URL: ${GITLAB_URL} + DATASOURCE_URL: "jdbc:postgresql://database:5432/gitlab_bot" + DATASOURCE_USERNAME: "postgres" + DATASOURCE_PASSWORD: ${DATASOURCE_PASSWORD} + +volumes: + database: \ No newline at end of file diff --git a/pom.xml b/pom.xml index eb0f676..b9eb7b5 100644 --- a/pom.xml +++ b/pom.xml @@ -44,7 +44,7 @@ UTF-8 UTF-8 - 0.0.37 + 0.0.38 2.2 From 5e71fd2838177511b6892b0a284eece9fc5a36d3 Mon Sep 17 00:00:00 2001 From: Struchkov Mark Date: Sun, 4 Dec 2022 12:12:28 +0300 Subject: [PATCH 3/6] =?UTF-8?q?=D0=9F=D0=BE=D0=BF=D1=80=D0=B0=D0=B2=D0=B8?= =?UTF-8?q?=D0=BB=20.gitlab-ci.yml?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitlab-ci.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 010a140..ada580f 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -29,6 +29,5 @@ docker-build: before_script: - echo "$CI_REGISTRY_PASSWORD" | docker login $CI_REGISTRY --username $CI_REGISTRY_USER --password-stdin script: - - cd gitlab-app - docker buildx create --use - docker buildx build --push --platform linux/amd64,linux/arm64/v8 -t "$CI_REGISTRY_IMAGE:latest" -t "$CI_REGISTRY_IMAGE:$CI_COMMIT_TAG" . \ No newline at end of file From ab2ba0aef98e6b76978af0cbeb29be5ed3fcaff6 Mon Sep 17 00:00:00 2001 From: Struchkov Mark Date: Sun, 4 Dec 2022 12:33:51 +0300 Subject: [PATCH 4/6] =?UTF-8?q?=D0=9F=D0=BE=D0=BF=D1=80=D0=B0=D0=B2=D0=B8?= =?UTF-8?q?=D0=BB=20Dockerfile?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitlab-ci.yml | 2 +- Dockerfile | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ada580f..eeb5118 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -3,7 +3,7 @@ stages: - deploy build: - image: maven:3.8.4-openjdk-17 + image: maven:3.8.6-eclipse-temurin-17 stage: build variables: MAVEN_OPTS: "-Dmaven.repo.local=./.m2/repository" diff --git a/Dockerfile b/Dockerfile index 1c3ba0a..c51f805 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,7 +7,8 @@ COPY ./gitlab-app/target/gitlab-notification.jar ./application.jar RUN java -Djarmode=layertools -jar application.jar extract RUN $JAVA_HOME/bin/jlink \ --add-modules `jdeps --ignore-missing-deps -q -recursive --multi-release ${RELEASE} --print-module-deps -cp 'dependencies/BOOT-INF/lib/*' application.jar`,jdk.crypto.cryptoki \ - --strip-debug \ + --strip-java-debug-attributes \ + --strip-native-debug-symbols objcopy=/usr/bin/objcopy \ --no-man-pages \ --no-header-files \ --compress=2 \ From a413b41c67dc335c2f8e39188613239ba1d24c68 Mon Sep 17 00:00:00 2001 From: Struchkov Mark Date: Sun, 4 Dec 2022 12:53:26 +0300 Subject: [PATCH 5/6] =?UTF-8?q?=D0=9F=D0=BE=D0=BF=D1=80=D0=B0=D0=B2=D0=B8?= =?UTF-8?q?=D0=BB=20Dockerfile?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Dockerfile b/Dockerfile index c51f805..08ee8bb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,8 @@ FROM eclipse-temurin:17 as app-build ENV RELEASE=17 +RUN apt-get install binutils + WORKDIR /opt/build COPY ./gitlab-app/target/gitlab-notification.jar ./application.jar From 96eed922b1b672163198aa6263ce094d39d5ad17 Mon Sep 17 00:00:00 2001 From: Struchkov Mark Date: Sun, 4 Dec 2022 13:07:15 +0300 Subject: [PATCH 6/6] =?UTF-8?q?=D0=9F=D0=BE=D0=BF=D1=80=D0=B0=D0=B2=D0=B8?= =?UTF-8?q?=D0=BB=20Dockerfile?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 3 --- 1 file changed, 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 08ee8bb..881ac59 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,6 @@ FROM eclipse-temurin:17 as app-build ENV RELEASE=17 -RUN apt-get install binutils - WORKDIR /opt/build COPY ./gitlab-app/target/gitlab-notification.jar ./application.jar @@ -10,7 +8,6 @@ RUN java -Djarmode=layertools -jar application.jar extract RUN $JAVA_HOME/bin/jlink \ --add-modules `jdeps --ignore-missing-deps -q -recursive --multi-release ${RELEASE} --print-module-deps -cp 'dependencies/BOOT-INF/lib/*' application.jar`,jdk.crypto.cryptoki \ --strip-java-debug-attributes \ - --strip-native-debug-symbols objcopy=/usr/bin/objcopy \ --no-man-pages \ --no-header-files \ --compress=2 \