[RAB-1] initial setup of structure

This commit is contained in:
Sheldan
2022-02-08 00:22:44 +01:00
parent c9b71bc227
commit 5194440be8
45 changed files with 3946 additions and 0 deletions

30
.github/workflows/build.yml vendored Normal file
View File

@@ -0,0 +1,30 @@
# This workflow will build a Java project with Maven
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven
name: Execute build
on:
push:
branches:
- master
- feature/**
pull_request:
branches: [ master ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: Build with Maven
run: mvn -s settings.xml -B install --file pom.xml
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
user: Sheldan
token: ${{ secrets.ABSTRACTO_PAT }}

38
.github/workflows/release.yml vendored Normal file
View File

@@ -0,0 +1,38 @@
name: Publish package to GitHub Packages
on:
release:
types: [created]
jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
persist-credentials: false
- name: Set up Java for publishing to GitHub Packages
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: Load current version
id: version
run: echo "version=$(mvn -s settings.xml --file pom.xml -q -Dexec.executable="echo" -Dexec.args='${project.version}' --non-recursive exec:exec)" >> $GITHUB_ENV
- name: Publish to GitHub Packages
run: mvn -s settings.xml --file pom.xml -B deploy -Dmaven.wagon.http.pool=false -DskipTests=true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
user: Sheldan
token: ${{ secrets.ABSTRACTO_PAT }}
- name: Login to GitHub Packages Docker Registry
uses: docker/login-action@v1
with:
registry: docker.pkg.github.com
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Push deployment container
working-directory: ./deployment/image-packaging/src/main/docker
run: docker-compose build && docker-compose push
env:
REGISTRY_PREFIX: docker.pkg.github.com/sheldan/r-austria-bot/
VERSION: ${{ env.version }}
ABSTRACTO_VERSION: 1.3.11
ABSTRACTO_REGISTRY_PREFIX: docker.pkg.github.com/sheldan/abstracto/

25
.gitignore vendored Normal file
View File

@@ -0,0 +1,25 @@
# Compiled class file
*.class
.idea/
target/
*.iml
# Log file
*.log
# BlueJ files
*.ctxt
# Mobile Tools for Java (J2ME)
.mtj.tmp/
# Package Files #
*.jar
*.war
*.nar
*.ear
*.zip
*.tar.gz
*.rar
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*

View File

@@ -0,0 +1,80 @@
<?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">
<parent>
<groupId>dev.sheldan.raustria.bot.application</groupId>
<artifactId>application</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>executable</artifactId>
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<id>repackage</id>
<goals>
<goal>repackage</goal>
</goals>
<configuration>
<classifier>exec</classifier>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>dev.sheldan.abstracto.core</groupId>
<artifactId>core-impl</artifactId>
</dependency>
<dependency>
<groupId>dev.sheldan.abstracto.core</groupId>
<artifactId>metrics-impl</artifactId>
</dependency>
<!-- modules containing commands -->
<dependency>
<groupId>dev.sheldan.abstracto.scheduling</groupId>
<artifactId>scheduling-impl</artifactId>
</dependency>
<dependency>
<groupId>dev.sheldan.abstracto.modules</groupId>
<artifactId>link-embed-impl</artifactId>
</dependency>
<dependency>
<groupId>dev.sheldan.abstracto.modules</groupId>
<artifactId>starboard-impl</artifactId>
</dependency>
</dependencies>
</project>

View File

@@ -0,0 +1,37 @@
package dev.sheldan.raustria.bot.executable;
import dev.sheldan.abstracto.core.service.Startup;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.domain.EntityScan;
import org.springframework.boot.autoconfigure.freemarker.FreeMarkerAutoConfiguration;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.transaction.annotation.EnableTransactionManagement;
@SpringBootApplication
@EnableAutoConfiguration(exclude = { FreeMarkerAutoConfiguration.class })
@ComponentScan(basePackages = {"dev.sheldan.abstracto", "dev.sheldan.raustria.bot"})
@EnableCaching
@EnableJpaRepositories(basePackages = {"dev.sheldan.abstracto", "dev.sheldan.raustria.bot"})
@EntityScan(basePackages = {"dev.sheldan.abstracto", "dev.sheldan.raustria.bot"})
@EnableTransactionManagement
public class Application implements CommandLineRunner {
@Autowired
private Startup startup;
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
@Override
public void run(String... args) throws Exception {
startup.startBot();
}
}

View File

@@ -0,0 +1,21 @@
spring.datasource.url=jdbc:postgresql://localhost:5432/abstracto
spring.datasource.username= abstracto
spring.datasource.password= abstracto
spring.jpa.properties.hibernate.default_schema=abstracto
spring.quartz.jdbc.initialize-schema=never
spring.jpa.hibernate.ddl-auto = none
spring.jpa.show-sql = false
spring.jpa.properties.hibernate.format_sql = true
log4j.logger.org.hibernate.SQL=trace
log4j.logger.org.hibernate.type.descriptor.sql=trace
log4j.logger.org.hibernate.type=trace
management.metrics.tags.application=r-austria-bot
spring.security.user.name=abstracto
spring.security.user.password=password
spring.security.user.roles=USER
spring.application.name=RAustriaBot

View File

@@ -0,0 +1,11 @@
spring.datasource.url=jdbc:postgresql://${DB_HOST}:${DB_PORT}/${DB_NAME}
spring.datasource.username= ${DB_USER}
spring.datasource.password= ${DB_PASS}
spring.jpa.hibernate.default_schema=${DB_NAME}
spring.quartz.jdbc.initialize-schema=never
management.metrics.tags.application=r-austria-bot
spring.security.user.name= ${REST_USER_NAME}
spring.security.user.password= ${REST_PASSWORD}
spring.security.user.roles=USER
spring.application.name=RAustriaBot

View File

@@ -0,0 +1,58 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration scan="true" scanPeriod="30 seconds">
<property name="LOG_PATH" value="logs"/>
<appender name="stdout" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>
%d{dd-MM-yyyy HH:mm:ss.SSS} %magenta([%thread]) %highlight(%-5level) %logger{36} - %msg%n
</pattern>
</encoder>
</appender>
<appender name="logFileAppender" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${LOG_PATH}/log.log</file>
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<Pattern>
%d{dd-MM-yyyy HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
</Pattern>
</encoder>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>
${LOG_PATH}/archived/log_%d{dd-MM-yyyy}.log
</fileNamePattern>
<maxHistory>10</maxHistory>
<totalSizeCap>1GB</totalSizeCap>
</rollingPolicy>
</appender>
<appender name="requests-file" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${LOG_PATH}/requests_log.log</file>
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<Pattern>
%d{dd-MM-yyyy HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
</Pattern>
</encoder>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>
${LOG_PATH}/archived/requests_log_%d{dd-MM-yyyy}.log
</fileNamePattern>
<maxHistory>10</maxHistory>
<totalSizeCap>1GB</totalSizeCap>
</rollingPolicy>
</appender>
<logger name="dev.sheldan.abstracto" level="INFO"/>
<logger name="dev.sheldan.abstracto.core.logging" level="DEBUG">
<appender-ref ref="requests-file"/>
</logger>
<root level="info">
<appender-ref ref="logFileAppender"/>
<appender-ref ref="stdout"/>
</root>
</configuration>

41
application/pom.xml Normal file
View File

@@ -0,0 +1,41 @@
<?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">
<parent>
<groupId>dev.sheldan.raustria.bot</groupId>
<artifactId>r-austria-bot</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<packaging>pom</packaging>
<groupId>dev.sheldan.raustria.bot.application</groupId>
<artifactId>application</artifactId>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>dev.sheldan.abstracto</groupId>
<artifactId>bundle</artifactId>
<version>${abstracto.version}</version>
<scope>import</scope>
<type>pom</type>
</dependency>
</dependencies>
</dependencyManagement>
<modules>
<module>executable</module>
</modules>
<dependencies>
<dependency>
<groupId>dev.sheldan.abstracto.core</groupId>
<artifactId>core-int</artifactId>
</dependency>
</dependencies>
</project>

View File

@@ -0,0 +1,34 @@
<?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">
<parent>
<groupId>dev.sheldan.raustria.bot</groupId>
<artifactId>deployment</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<packaging>pom</packaging>
<artifactId>docker-compose</artifactId>
<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<id>assembly-docker-compose-configuration</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<descriptors>
<descriptor>src/main/assembly/docker-compose.xml</descriptor>
</descriptors>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@@ -0,0 +1,19 @@
<assembly xmlns="http://maven.apache.org/ASSEMBLY/2.1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.1.0 http://maven.apache.org/xsd/assembly-2.1.0.xsd">
<id>docker-compose</id>
<formats>
<format>zip</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<fileSets>
<fileSet>
<outputDirectory>./docker-compose</outputDirectory>
<directory>${project.basedir}/src/main/resources/</directory>
<includes>
<include>**/*</include>
</includes>
<filtered>true</filtered>
</fileSet>
</fileSets>
</assembly>

View File

@@ -0,0 +1,32 @@
# database configuration
DATABASE_HOST=database
DATABASE_PORT=5432
DATABASE_USER=abstracto
DATABASE_NAME=abstracto
DATABASE_PASSWORD=abstracto
GRAFANA_DATABASE_PASSWORD=grafana
GRAFANA_DATABASE_USER=grafana
# deployment configuration, whether or not the container should execute the parts on startup
EXECUTE_DEPLOYMENT=true
EXECUTE_LIQUIBASE=true
EXECUTE_TEMPLATES=true
# whether or not remote debug should be enabled on the application
REMOTE_DEBUG=false
DEBUG_PORT=5005
TOMCAT_PORT=8080
# authentication for actuator endpoints
REST_USER_NAME=abstracto
REST_PASSWORD=password
# port grafana will be reachable
GRAFANA_PORT=3000
# port prometheus will be reachable
LOKI_PORT=3100
PROMETHEUS_PORT=9090
# port pg admin will be reachable
PGADMIN_PORT=5050
# default authentication for pg admin
PGADMIN_DEFAULT_EMAIL=sheldan@sheldan.dev
PGADMIN_DEFAULT_PASSWORD=admin
TOKEN=<INSERT TOKEN>
YOUTUBE_API_KEY=<INSERT KEY>
R_AUSTRIA_BOT_VERSION=1.0.0

View File

@@ -0,0 +1,10 @@
# Setup for local docker-compose deployment
* Install docker [here](https://docs.docker.com/get-docker/)
* Install docker-compose [here](https://docs.docker.com/compose/install/).
* Execute `docker-compose build` in `image-packaging`.
* Fill out values in `.env` for token and database password. There are some default values, but token is required to be changed.
* Execute `fill-prometheus-file-sh` in order to populate the prometheus config with the correct password (https://github.com/prometheus/prometheus/issues/2357)
* Execute `docker-compose up` in this directory and wait for completion.
* Per default pgAdmin is available on `localhost:5050` with the configured user and password. It will contain a configuration in the servers list.

View File

@@ -0,0 +1,146 @@
version: '3.7'
services:
db:
image: ${REGISTRY_PREFIX}r_austria_bot_database:${R_AUSTRIA_BOT_VERSION}
container_name: database
restart: always
environment:
POSTGRES_PASSWORD: ${DATABASE_PASSWORD}
POSTGRES_USER: ${DATABASE_USER}
ports:
- "127.0.0.1:${DATABASE_PORT}:5432"
networks:
- raustriabot
volumes:
- r-austria-bot-db-data:/var/lib/postgresql/data
deployment_container:
container_name: deployment
image: ${REGISTRY_PREFIX}r_austria_bot_deployment:${R_AUSTRIA_BOT_VERSION}
depends_on:
- db
environment:
DB_PASS: ${DATABASE_PASSWORD}
DB_HOST: ${DATABASE_HOST}
DB_PORT: ${DATABASE_PORT}
DB_USER: ${DATABASE_USER}
DB_NAME: ${DATABASE_NAME}
ABSTRACTO_GRAFANA_DB_PASS: ${GRAFANA_DATABASE_PASSWORD}
ABSTRACTO_GRAFANA_DB_USER: ${GRAFANA_DATABASE_USER}
EXECUTE_DEPLOYMENT: ${EXECUTE_DEPLOYMENT}
EXECUTE_LIQUIBASE: ${EXECUTE_LIQUIBASE}
EXECUTE_TEMPLATES: ${EXECUTE_TEMPLATES}
LIQUIBASE_PATH: ${LIQUIBASE_PATH:-/liquibase}
POSTGRES_DRIVER_PATH: ${EXECUTE_DEPLOYMENT:-/postgres/driver.jar}
WAIT_HOSTS: ${DATABASE_HOST}:${DATABASE_PORT}
networks:
- raustriabot
bot:
image: ${REGISTRY_PREFIX}r_austria_bot:${R_AUSTRIA_BOT_VERSION}
depends_on:
- db
- deployment_container
restart: on-failure
container_name: raustriabot
environment:
TOKEN: ${TOKEN}
REMOTE_DEBUG: ${REMOTE_DEBUG}
DB_PASS: ${DATABASE_PASSWORD}
DB_HOST: ${DATABASE_HOST}
DB_PORT: ${DATABASE_PORT}
DB_USER: ${DATABASE_USER}
DB_NAME: ${DATABASE_NAME}
REST_USER_NAME: ${REST_USER_NAME}
REST_PASSWORD: ${REST_PASSWORD}
YOUTUBE_API_KEY: ${YOUTUBE_API_KEY}
command: sh -c "while ping -c1 deployment_container &>/dev/null; do sleep 1; done; echo 'Liquibase finished!' && ./start.sh"
ports:
- "127.0.0.1:${DEBUG_PORT}:5005"
- "127.0.0.1:${TOMCAT_PORT}:8080"
networks:
- raustriabot
volumes:
- r-austria-bot-bot-logs:/logs
- ./config:/config
pgadmin:
container_name: pgadmin
image: ${REGISTRY_PREFIX}r_austria_bot_pg_admin:${R_AUSTRIA_BOT_VERSION}
depends_on:
- db
environment:
PGADMIN_DEFAULT_EMAIL: ${PGADMIN_DEFAULT_EMAIL}
PGADMIN_DEFAULT_PASSWORD: ${PGADMIN_DEFAULT_PASSWORD}
ports:
- "127.0.0.1:${PGADMIN_PORT}:80"
restart: unless-stopped
networks:
- raustriabot
prometheus:
container_name: prometheus
image: ${REGISTRY_PREFIX}r_austria_bot_prometheus:${R_AUSTRIA_BOT_VERSION}
depends_on:
- bot
ports:
- "127.0.0.1:${PROMETHEUS_PORT}:9090"
restart: unless-stopped
networks:
- raustriabot
volumes:
- ./res/prometheus-scrapper-password-filled:/etc/prometheus/micrometer_password
- r-austria-bot-prometheus-data:/prometheus
grafana:
container_name: grafana
image: ${REGISTRY_PREFIX}r_austria_bot_grafana:${R_AUSTRIA_BOT_VERSION}
depends_on:
- prometheus
- bot
ports:
- "127.0.0.1:${GRAFANA_PORT}:3000"
restart: unless-stopped
environment:
DB_PASS: ${GRAFANA_DATABASE_PASSWORD}
DB_HOST: ${DATABASE_HOST}
DB_PORT: ${DATABASE_PORT}
DB_USER: ${GRAFANA_DATABASE_USER}
DB_NAME: ${DATABASE_NAME}
PROMETHEUS_HOST: 'prometheus'
PROMETHEUS_PORT: 9090
LOKI_HOST: 'loki'
LOKI_PORT: ${LOKI_PORT}
volumes:
- r-austria-bot-grafana-user-data:/var/lib/grafana
networks:
- raustriabot
promtail:
container_name: promtail
image: ${REGISTRY_PREFIX}r_austria_bot_promtail:${R_AUSTRIA_BOT_VERSION}
depends_on:
- bot
restart: unless-stopped
command: -config.file=/mnt/config/promtail-config.yaml
volumes:
- r-austria-bot-bot-logs:/logs
networks:
- raustriabot
loki:
container_name: loki
image: ${REGISTRY_PREFIX}r_austria_bot_loki:${R_AUSTRIA_BOT_VERSION}
depends_on:
- promtail
command: -config.file=/mnt/config/loki-config.yaml
ports:
- "127.0.0.1:${LOKI_PORT}:3100"
restart: unless-stopped
networks:
- raustriabot
networks:
raustriabot:
driver: bridge
name: raustriabot-network
volumes:
r-austria-bot-db-data:
r-austria-bot-grafana-user-data:
r-austria-bot-prometheus-data:
r-austria-bot-bot-logs:

View File

@@ -0,0 +1,5 @@
#!/bin/bash
set -o allexport
source .env
set +o allexport
envsubst < res/prometheus-scrapper-password > res/prometheus-scrapper-password-filled

View File

@@ -0,0 +1,166 @@
<?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">
<parent>
<groupId>dev.sheldan.raustria.bot</groupId>
<artifactId>deployment</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>image-packaging</artifactId>
<packaging>pom</packaging>
<properties>
<file.basedir>${project.basedir}/src/main/docker/</file.basedir>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy</id>
<phase>package</phase>
<goals>
<goal>copy</goal>
</goals>
</execution>
</executions>
<configuration>
<artifactItems>
<!-- backend jar -->
<artifactItem>
<groupId>dev.sheldan.raustria.bot.application</groupId>
<artifactId>executable</artifactId>
<version>${project.version}</version>
<classifier>exec</classifier>
<type>jar</type>
<overWrite>true</overWrite>
<outputDirectory>${file.basedir}/r-austria-bot/bot</outputDirectory>
<destFileName>app.jar</destFileName>
</artifactItem>
<!-- template artefacts -->
<artifactItem>
<groupId>dev.sheldan.abstracto-templates.templates</groupId>
<artifactId>core</artifactId>
<version>${abstracto.templates.version}</version>
<type>zip</type>
<overWrite>true</overWrite>
<outputDirectory>${file.basedir}/deployment/template-artifacts/</outputDirectory>
<destFileName>core.zip</destFileName>
</artifactItem>
<artifactItem>
<groupId>dev.sheldan.abstracto-templates.templates</groupId>
<artifactId>link-embed</artifactId>
<version>${abstracto.templates.version}</version>
<type>zip</type>
<overWrite>true</overWrite>
<outputDirectory>${file.basedir}/deployment/template-artifacts/</outputDirectory>
<destFileName>link-embed.zip</destFileName>
</artifactItem>
<artifactItem>
<groupId>dev.sheldan.abstracto-templates.templates</groupId>
<artifactId>starboard</artifactId>
<version>${abstracto.templates.version}</version>
<type>zip</type>
<overWrite>true</overWrite>
<outputDirectory>${file.basedir}/deployment/template-artifacts/</outputDirectory>
<destFileName>starboard.zip</destFileName>
</artifactItem>
<!-- translation artefacts -->
<artifactItem>
<groupId>dev.sheldan.abstracto-templates.translations</groupId>
<artifactId>core</artifactId>
<version>${abstracto.templates.version}</version>
<type>zip</type>
<overWrite>true</overWrite>
<outputDirectory>${file.basedir}/deployment/translation-artifacts/</outputDirectory>
<destFileName>core.zip</destFileName>
</artifactItem>
<artifactItem>
<groupId>dev.sheldan.abstracto-templates.translations</groupId>
<artifactId>link-embed</artifactId>
<version>${abstracto.templates.version}</version>
<type>zip</type>
<overWrite>true</overWrite>
<outputDirectory>${file.basedir}/deployment/translation-artifacts/</outputDirectory>
<destFileName>link-embed.zip</destFileName>
</artifactItem>
<artifactItem>
<groupId>dev.sheldan.abstracto-templates.translations</groupId>
<artifactId>starboard</artifactId>
<version>${abstracto.templates.version}</version>
<type>zip</type>
<overWrite>true</overWrite>
<outputDirectory>${file.basedir}/deployment/translation-artifacts/</outputDirectory>
<destFileName>starboard.zip</destFileName>
</artifactItem>
<!-- custom -->
<!-- liquibase artifacts -->
<artifactItem>
<groupId>dev.sheldan.abstracto.scheduling</groupId>
<artifactId>scheduling-impl</artifactId>
<version>${abstracto.version}</version>
<classifier>liquibase</classifier>
<type>zip</type>
<overWrite>true</overWrite>
<outputDirectory>${file.basedir}/deployment/liquibase-artifacts/</outputDirectory>
<destFileName>scheduling.zip</destFileName>
</artifactItem>
<artifactItem>
<groupId>dev.sheldan.abstracto.core</groupId>
<artifactId>core-impl</artifactId>
<version>${abstracto.version}</version>
<classifier>liquibase</classifier>
<type>zip</type>
<overWrite>true</overWrite>
<outputDirectory>${file.basedir}/deployment/liquibase-artifacts/</outputDirectory>
<destFileName>core.zip</destFileName>
</artifactItem>
<artifactItem>
<groupId>dev.sheldan.abstracto.modules</groupId>
<artifactId>link-embed-impl</artifactId>
<version>${abstracto.version}</version>
<classifier>liquibase</classifier>
<type>zip</type>
<overWrite>true</overWrite>
<outputDirectory>${file.basedir}/deployment/liquibase-artifacts/</outputDirectory>
<destFileName>link-embed.zip</destFileName>
</artifactItem>
<artifactItem>
<groupId>dev.sheldan.abstracto.modules</groupId>
<artifactId>starboard-impl</artifactId>
<version>${abstracto.version}</version>
<classifier>liquibase</classifier>
<type>zip</type>
<overWrite>true</overWrite>
<outputDirectory>${file.basedir}/deployment/liquibase-artifacts/</outputDirectory>
<destFileName>starboard.zip</destFileName>
</artifactItem>
<!-- customizations -->
<!-- overrides -->
<!-- overrides translations -->
</artifactItems>
</configuration>
</plugin>
</plugins>
</build>
</project>

View File

@@ -0,0 +1,6 @@
PROMTAIL_VERSION=2.2.1
LOKI_VERSION=2.2.1
PROMETHEUS_VERSION=v2.28.1
PG_ADMIN_VERSION=5.5
GRAFANA_VERSION=8.0.6
POSTGRES_VERSION=13.3-buster

View File

@@ -0,0 +1,5 @@
ARG POSTGRES_VERSION
FROM postgres:${POSTGRES_VERSION}
MAINTAINER Sheldan
VOLUME /tmp
ADD sql/init.sql /docker-entrypoint-initdb.d/init.sql

View File

@@ -0,0 +1 @@
CREATE SCHEMA abstracto

View File

@@ -0,0 +1,8 @@
ARG ABSTRACTO_REGISTRY_PREFIX
ARG ABSTRACTO_VERSION=latest
FROM ${ABSTRACTO_REGISTRY_PREFIX}abstracto_deployment:${ABSTRACTO_VERSION:-latest}
MAINTAINER Sheldan
ADD template-artifacts /templates
ADD translation-artifacts /translations
ADD liquibase-artifacts /liquibase-zips
ADD config /

View File

@@ -0,0 +1,12 @@
{
"template_artifacts": ["core","starboard", "link-embed"],
"translation_artifacts": ["core", "starboard", "link-embed"],
"liquibase_artifacts": [
{ "zip": "scheduling", "file": "scheduling-changeLog.xml" },
{ "zip": "core", "file": "core-changeLog.xml" },
{ "zip": "link-embed", "file": "link-embed-changeLog.xml"},
{ "zip": "starboard", "file": "starboard-changeLog.xml"}
]
}

View File

@@ -0,0 +1,50 @@
version: "3.7"
services:
bot:
build:
context: r-austria-bot
image: ${REGISTRY_PREFIX}r_austria_bot:${VERSION:-latest}
database:
build:
context: database
args:
POSTGRES_VERSION: ${POSTGRES_VERSION}
image: ${REGISTRY_PREFIX}r_austria_bot_database:${VERSION:-latest}
pg_admin:
build:
context: pgAdmin
args:
PG_ADMIN_VERSION: ${PG_ADMIN_VERSION}
image: ${REGISTRY_PREFIX}r_austria_bot_pg_admin:${VERSION:-latest}
deployment_container:
build:
context: deployment
args:
ABSTRACTO_REGISTRY_PREFIX: ${ABSTRACTO_REGISTRY_PREFIX}
ABSTRACTO_VERSION: ${ABSTRACTO_VERSION}
image: ${REGISTRY_PREFIX}r_austria_bot_deployment:${VERSION:-latest}
prometheus:
build:
context: prometheus
args:
PROMETHEUS_VERSION: ${PROMETHEUS_VERSION}
image: ${REGISTRY_PREFIX}r_austria_bot_prometheus:${VERSION:-latest}
grafana:
build:
context: grafana
args:
GRAFANA_VERSION: ${GRAFANA_VERSION}
image: ${REGISTRY_PREFIX}r_austria_bot_grafana:${VERSION:-latest}
promtail:
build:
context: promtail
args:
PROMTAIL_VERSION: ${PROMTAIL_VERSION}
image: ${REGISTRY_PREFIX}r_austria_bot_promtail:${VERSION:-latest}
loki:
build:
context: loki
args:
LOKI_VERSION: ${LOKI_VERSION}
image: ${REGISTRY_PREFIX}r_austria_bot_loki:${VERSION:-latest}

View File

@@ -0,0 +1,6 @@
ARG GRAFANA_VERSION
FROM grafana/grafana:${GRAFANA_VERSION}
MAINTAINER Sheldan
ADD ./provisioning /etc/grafana/provisioning
ADD ./config.ini /etc/grafana/config.ini
ADD ./dashboards /var/lib/grafana/dashboards

View File

@@ -0,0 +1,2 @@
[paths]
provisioning = conf/provisioning

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,65 @@
{
"annotations": {
"list": [
{
"builtIn": 1,
"datasource": "-- Grafana --",
"enable": true,
"hide": true,
"iconColor": "rgba(0, 211, 255, 1)",
"name": "Annotations & Alerts",
"type": "dashboard"
}
]
},
"editable": true,
"gnetId": null,
"graphTooltip": 0,
"id": 4,
"links": [],
"panels": [
{
"datasource": "Loki",
"gridPos": {
"h": 14,
"w": 24,
"x": 0,
"y": 0
},
"id": 2,
"options": {
"dedupStrategy": "none",
"enableLogDetails": true,
"showLabels": false,
"showTime": false,
"sortOrder": "Descending",
"wrapLogMessage": true
},
"targets": [
{
"expr": "{job=\"r-austria-bot-logs\", filename=\"/logs/log.log\"}",
"queryType": "randomWalk",
"refId": "A"
}
],
"title": "RAustria Bot logs",
"type": "logs"
}
],
"refresh": "",
"schemaVersion": 30,
"style": "dark",
"tags": [],
"templating": {
"list": []
},
"time": {
"from": "now-3h",
"to": "now"
},
"timepicker": {},
"timezone": "",
"title": "RAustria Bot logs",
"uid": "1uGb0q4nz",
"version": 2
}

View File

@@ -0,0 +1,6 @@
- name: 'r-austria-bot-dashboards'
org_id: 1
folder: ''
type: 'file'
options:
folder: '/var/lib/grafana/dashboards'

View File

@@ -0,0 +1,29 @@
apiVersion: 1
datasources:
- access: 'proxy'
editable: true
is_default: true
name: 'prometheus'
org_id: 1
type: 'prometheus'
url: 'http://${PROMETHEUS_HOST}:${PROMETHEUS_PORT}'
version: 1
- name: 'postgres-db'
type: postgres
access: 'proxy'
url: '${DB_HOST}:${DB_PORT}'
password: '${DB_PASS}'
user: '${DB_USER}'
database: '${DB_NAME}'
basicAuth: false
is_default: false
jsonData:
sslmode: 'disable'
version: 1
editable: false
- name: Loki
type: loki
access: proxy
url: 'http://${LOKI_HOST}:${LOKI_PORT}'
jsonData:
maxLines: 2000

View File

@@ -0,0 +1,4 @@
ARG LOKI_VERSION
FROM grafana/loki:${LOKI_VERSION}
MAINTAINER Sheldan
ADD loki.yml /mnt/config/loki-config.yaml

View File

@@ -0,0 +1,66 @@
auth_enabled: false
server:
http_listen_port: 3100
grpc_listen_port: 9096
ingester:
wal:
enabled: true
dir: /tmp/wal
lifecycler:
address: 127.0.0.1
ring:
kvstore:
store: inmemory
replication_factor: 1
final_sleep: 0s
chunk_idle_period: 1h
max_chunk_age: 1h
chunk_target_size: 1048576
chunk_retain_period: 30s
max_transfer_retries: 0
schema_config:
configs:
- from: 2020-10-24
store: boltdb-shipper
object_store: filesystem
schema: v11
index:
prefix: index_
period: 24h
storage_config:
boltdb_shipper:
active_index_directory: /tmp/loki/boltdb-shipper-active
cache_location: /tmp/loki/boltdb-shipper-cache
cache_ttl: 24h
shared_store: filesystem
filesystem:
directory: /tmp/loki/chunks
compactor:
working_directory: /tmp/loki/boltdb-shipper-compactor
shared_store: filesystem
limits_config:
reject_old_samples: true
reject_old_samples_max_age: 168h
chunk_store_config:
max_look_back_period: 0s
table_manager:
retention_deletes_enabled: true
retention_period: 360h
ruler:
storage:
type: local
local:
directory: /tmp/loki/rules
rule_path: /tmp/loki/rules-temp
ring:
kvstore:
store: inmemory

View File

@@ -0,0 +1,5 @@
ARG PG_ADMIN_VERSION
FROM dpage/pgadmin4:${PG_ADMIN_VERSION}
MAINTAINER Sheldan
VOLUME /tmp
ADD config/servers.json /pgadmin4/servers.json

View File

@@ -0,0 +1,13 @@
{
"Servers": {
"1": {
"Name": "r-austria bot database",
"Group": "Server Group 1",
"Port": 5432,
"Username": "abstracto",
"Host": "db",
"SSLMode": "prefer",
"MaintenanceDB": "postgres"
}
}
}

View File

@@ -0,0 +1,4 @@
ARG PROMETHEUS_VERSION
FROM prom/prometheus:${PROMETHEUS_VERSION}
MAINTAINER Sheldan
ADD prometheus.yml /etc/prometheus/prometheus.yml

View File

@@ -0,0 +1,17 @@
global:
scrape_interval: 10s
scrape_timeout: 10s
evaluation_interval: 1m
scrape_configs:
- job_name: r_austria_bot_micrometer
honor_timestamps: true
scrape_interval: 5s
scrape_timeout: 5s
metrics_path: /actuator/prometheus
scheme: http
static_configs:
- targets:
- r_austra:8080
basic_auth:
username: "abstracto"
password_file: /etc/prometheus/micrometer_password

View File

@@ -0,0 +1,4 @@
ARG PROMTAIL_VERSION
FROM grafana/promtail:${PROMTAIL_VERSION}
MAINTAINER Sheldan
ADD promtail.yaml /mnt/config/promtail-config.yaml

View File

@@ -0,0 +1,17 @@
server:
disable: true
positions:
filename: /tmp/positions.yaml
clients:
- url: http://loki:3100/loki/api/v1/push
scrape_configs:
- job_name: system
static_configs:
- targets:
- localhost
labels:
job: r-austria-bot-logs
__path__: /logs/*.log

View File

@@ -0,0 +1,10 @@
FROM openjdk:8-jdk-alpine
MAINTAINER Sheldan
VOLUME /tmp
ADD bot/app.jar /app.jar
ADD config/* /config/
VOLUME ["/config"]
VOLUME ["/logs"]
ADD wrapper/*.sh /
RUN chmod +x /start.sh
CMD ["/start.sh"]

View File

@@ -0,0 +1,2 @@
logging.config=config/logback.xml

View File

@@ -0,0 +1,58 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration scan="true" scanPeriod="30 seconds">
<property name="LOG_PATH" value="logs"/>
<appender name="stdout" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>
%d{dd-MM-yyyy HH:mm:ss.SSS} %magenta([%thread]) %highlight(%-5level) %logger{36} - %msg%n
</pattern>
</encoder>
</appender>
<appender name="logFileAppender" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${LOG_PATH}/log.log</file>
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<Pattern>
%d{dd-MM-yyyy HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
</Pattern>
</encoder>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>
${LOG_PATH}/archived/log_%d{dd-MM-yyyy}.log
</fileNamePattern>
<maxHistory>10</maxHistory>
<totalSizeCap>1GB</totalSizeCap>
</rollingPolicy>
</appender>
<appender name="requests-file" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${LOG_PATH}/requests_log.log</file>
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<Pattern>
%d{dd-MM-yyyy HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
</Pattern>
</encoder>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>
${LOG_PATH}/archived/requests_log_%d{dd-MM-yyyy}.log
</fileNamePattern>
<maxHistory>10</maxHistory>
<totalSizeCap>1GB</totalSizeCap>
</rollingPolicy>
</appender>
<logger name="dev.sheldan.abstracto" level="INFO"/>
<logger name="dev.sheldan.abstracto.core.logging" level="DEBUG">
<appender-ref ref="requests-file"/>
</logger>
<root level="info">
<appender-ref ref="logFileAppender"/>
<appender-ref ref="stdout"/>
</root>
</configuration>

View File

@@ -0,0 +1,7 @@
#!/bin/sh
DEBUG_PARAMS=""
if [ "x$REMOTE_DEBUG" = 'xtrue' ]; then
DEBUG_PARAMS="-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005"
echo "Starting with remote debugging on port 5005"
fi;
java ${DEBUG_PARAMS} -jar app.jar

22
deployment/pom.xml Normal file
View File

@@ -0,0 +1,22 @@
<?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">
<parent>
<groupId>dev.sheldan.raustria.bot</groupId>
<artifactId>r-austria-bot</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>deployment</artifactId>
<packaging>pom</packaging>
<modules>
<module>docker-compose</module>
<module>image-packaging</module>
</modules>
</project>

62
pom.xml Normal file
View File

@@ -0,0 +1,62 @@
<?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>
<packaging>pom</packaging>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.3.1.RELEASE</version>
<relativePath />
</parent>
<groupId>dev.sheldan.raustria.bot</groupId>
<artifactId>r-austria-bot</artifactId>
<version>1.0.0-SNAPSHOT</version>
<properties>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>1.8</maven.compiler.source>
<!-- edit in release.yml as well -->
<!-- when releasing a new bot version, update the .env as well-->
<abstracto.version>1.3.11</abstracto.version>
<abstracto.templates.version>1.3.1</abstracto.templates.version>
</properties>
<modules>
<module>application</module>
<module>templates</module>
<module>deployment</module>
</modules>
<repositories>
<repository>
<id>jcenter</id>
<name>jcenter-bintray</name>
<url>https://jcenter.bintray.com</url>
</repository>
<repository>
<id>github</id>
<url>https://maven.pkg.github.com/Sheldan/*</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<distributionManagement>
<repository>
<id>github</id>
<name>GitHub Packages</name>
<url>https://maven.pkg.github.com/Sheldan/r-austria-bot</url>
</repository>
</distributionManagement>
<scm>
<url>https://maven.pkg.github.com/Sheldan/r-austria-bot</url>
<developerConnection>scm:git:git@github.com:Sheldan/r-austria-bot.git</developerConnection>
<tag>HEAD</tag>
</scm>
</project>

36
settings.xml Normal file
View File

@@ -0,0 +1,36 @@
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
http://maven.apache.org/xsd/settings-1.0.0.xsd">
<activeProfiles>
<activeProfile>github</activeProfile>
</activeProfiles>
<profiles>
<profile>
<id>github</id>
<repositories>
<repository>
<id>central</id>
<url>https://repo1.maven.org/maven2</url>
</repository>
<repository>
<id>github</id>
<url>https://maven.pkg.github.com/Sheldan/*</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
</profile>
</profiles>
<servers>
<server>
<id>github</id>
<username>${env.user}</username>
<password>${env.token}</password>
</server>
</servers>
</settings>

15
templates/pom.xml Normal file
View File

@@ -0,0 +1,15 @@
<?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">
<parent>
<artifactId>r-austria-bot</artifactId>
<groupId>dev.sheldan.raustria.bot</groupId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>templates</artifactId>
</project>