Merge pull request #26 from uPagge/develop

Develop
This commit is contained in:
Struchkov Mark 2022-12-04 13:24:05 +03:00 committed by GitHub
commit e8ef39cdb7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 102 additions and 8 deletions

View File

@ -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"
@ -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" .

37
Dockerfile Normal file
View File

@ -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-java-debug-attributes \
--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

View File

@ -1,12 +1,12 @@
FROM openjdk:17.0.2-jdk-slim-buster
MAINTAINER uPagge <me@upagge.ru>
FROM amazoncorretto:17.0.5
MAINTAINER uPagge <mark@struchkov.dev>
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 \

29
docker-compose-dev.yml Normal file
View File

@ -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:

31
docker-compose.yml Normal file
View File

@ -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:

View File

@ -1,5 +1,3 @@
server:
port: 8018
spring:
datasource:
url: ${DATASOURCE_URL}

View File

@ -44,7 +44,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<godfather.telegram.core.version>0.0.37</godfather.telegram.core.version>
<godfather.telegram.core.version>0.0.38</godfather.telegram.core.version>
<javax.persistance.version>2.2</javax.persistance.version>