Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kube-Series-2.2: Features/properties-makefile-dockerfile #200

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
95 changes: 95 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@

# VARIABLES
MAVEN_PROJ_LIST := kafka-webview-ui
MAVEN_SKIP := -DskipTests=true -DskipCheckStyle=true -DskipLicenseCheck=true
RELEASE_VERSION := 2.5.0


# CONFIG
.PHONY: help print-variables
.DEFAULT_GOAL := help


# ACTIONS

## BUILD

### Kafka-WebView only

compile : ## Compile Kafka-WebView project only
mvn clean compile -pl $(MAVEN_PROJ_LIST)

test : ## Test Kafka-WebView project only
mvn clean test -pl $(MAVEN_PROJ_LIST)

package : ## Build Kafka-WebView jar only
mvn clean package -pl $(MAVEN_PROJ_LIST)

package-skip : ## Build Kafka-WebView jar only, skipping tests and checks
mvn clean package -pl $(MAVEN_PROJ_LIST) $(MAVEN_SKIP)

### All

compile-all : ## Compile all projects
mvn clean compile

test-all : ## Test all projects
mvn clean test

package-all : ## Build all jars
mvn clean package

package-all-skip : ## Build all jars, skipping tests and checks
mvn clean package $(MAVEN_SKIP)

## RUN

run : ## Build and run Kafka-WebView only using Maven
export SPRING_PROFILES_ACTIVE="dev"; \
mvn spring-boot:run -pl $(MAVEN_PROJ_LIST) $(MAVEN_SKIP)

run-jar : package-skip ## Build and run Kafka-WebView only using jar
export SPRING_PROFILES_ACTIVE="dev"; \
java $(JVM_OPTS) $(MEM_OPTS) $(JAVA_OPTS) -jar kafka-webview-ui-*.jar

## DOCKER

docker-build : ## Build Docker image
docker build -t sourcelaborg/kafka-webview .

docker-push : ## Push Docker image to Docker Hub
docker push sourcelaborg/kafka-webview:latest

docker-tag-release : ## Tag Docker image with version $(RELEASE_VERSION)
docker tag sourcelaborg/kafka-webview sourcelaborg/kafka-webview:$(RELEASE_VERSION)

docker-push-release : ## Push Docker image version $(RELEASE_VERSION)
docker push sourcelaborg/kafka-webview:$(RELEASE_VERSION)

## SSL

# TODO

## HELPERS

help : ## Help (default action)
@echo ""
@echo "*** \033[33mMakefile help\033[0m ***"
@echo ""
@echo "Targets list:"
@grep -E '^[a-zA-Z_-]+ :.*?## .*$$' $(MAKEFILE_LIST) | sort -k 1,1 | awk 'BEGIN {FS = ":.*?## "}; {printf "\t\033[36m%-30s\033[0m %s\n", $$1, $$2}'
@echo ""

print-variables : ## Print variables values
@echo ""
@echo "*** \033[33mMakefile variables\033[0m ***"
@echo ""
@echo "- - - makefile - - -"
@echo "MAKE: $(MAKE)"
@echo "MAKEFILES: $(MAKEFILES)"
@echo "MAKEFILE_LIST: $(MAKEFILE_LIST)"
@echo "- - -"
@echo "MAVEN_PROJ_LIST: $(MAVEN_PROJ_LIST)"
@echo "MAVEN_SKIP: $(MAVEN_SKIP)"
@echo "RELEASE_VERSION: $(RELEASE_VERSION)"
@echo ""
11 changes: 0 additions & 11 deletions buildAndRun.sh

This file was deleted.

3 changes: 0 additions & 3 deletions kafka-webview-ui/src/assembly/distribution/start.bat
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@

cd /D %~dp0

:: Define configuration
set SPRING_CONFIG_LOCATION=classpath:/config/base.yml,config.yml

:: launch webapp
FOR /F "tokens=* USEBACKQ" %%F IN (`dir /b kafka-webview-ui-*.jar`) DO SET "jar=%%F"
java -jar %jar%
48 changes: 30 additions & 18 deletions kafka-webview-ui/src/assembly/distribution/start.sh
Original file line number Diff line number Diff line change
@@ -1,23 +1,35 @@
#!/bin/bash
#!/bin/sh

CWD=`pwd`
# Get the directory of this script
SCRIPT_DIR=$(dirname "$0")

## Change to local directory
cd "${0%/*}"

# Define empty options as defaults if none set
if [[ -z "$HEAP_OPTS" ]]; then
export HEAP_OPTS=""
# Define environment variables
## New
if [[ -z "$JVM_OPTS" ]]; then
export JVM_OPTS="-noverify -server -XX:TieredStopAtLevel=1"
fi
if [[ -z "$LOG_OPTS" ]]; then
export LOG_OPTS=""
if [[ -z "$MEM_OPTS" ]]; then
export MEM_OPTS="-Xms2G -Xmx2G -XX:MaxMetaspaceSize=300M"
fi
if [[ -z "$JAVA_OPTS" ]]; then
export JAVA_OPTS=""
fi
## Deprecated
if [[ ! -z "$LOG_OPTS" ]]; then
echo "Usage of 'LOG_OPTS' is deprecated and will be removed in the future, please switch to 'JAVA_OPTS'"
export JAVA_OPTS="$JAVA_OPTS $LOG_OPTS"
fi
if [[ ! -z "$HEAP_OPTS" ]]; then
echo "Usage of 'HEAP_OPTS' is deprecated and will be removed in the future, please switch to 'MEM_OPTS'"
export MEM_OPTS="$MEM_OPTS $HEAP_OPTS"
fi

## Define configuration
export SPRING_CONFIG_LOCATION=classpath:/config/base.yml,config.yml

## launch webapp
exec java -jar kafka-webview-ui-*.jar $HEAP_OPTS $LOG_OPTS

## Change back to previous directory
cd $CWD
# Start application
echo "Start Kafka-WebView with following parameters:"
echo "\tJVM_OPTS: $JVM_OPTS"
echo "\tMEM_OPTS: $MEM_OPTS"
echo "\tJAVA_OPTS: $JAVA_OPTS"
echo "\tLOG_OPTS: deprecated, added to JAVA_OPTS"
echo "\tHEAP_OPTS: deprecated, added to MEM_OPTS"
echo
java $JVM_OPTS $MEM_OPTS $JAVA_OPTS -jar kafka-webview-ui-*.jar
Original file line number Diff line number Diff line change
@@ -1,20 +1,27 @@

# General
server:

servlet:
session:
persistent: true


# Spring
spring:

jpa:
show-sql: true
# H2 Datbase

h2:
console:
## Disable for release
enabled: true
path: /h2


# Kafka WebView custom
app:
requireSsl: false

user:
enabled: true
## Development server Ldap auth settings
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,95 @@

# General
server:

## What port to run the service on.
port: 8080

tomcat:
remote_ip_header: x-forwarded-for
protocol_header: x-forwarded-proto
mbeanregistry:
enabled: true

servlet:
session:
## User sessions should not be persistent across service restarts by default.
persistent: false
## User login session timeout after 1 hour (3600 seconds)
timeout: 3600


## Various App Configs
# Spring
spring:

application:
name: Kafka Webview

datasource:
url: "jdbc:h2:file:./data/db"
username: sa
password:
driver-class-name: org.h2.Driver

flyway:
locations: "classpath:schema/migration/{vendor}"
baselineOnMigrate: true

servlet:
multipart:
max-file-size: 64MB
max-request-size: 64MB

thymeleaf:
cache: false
enabled: true
prefix: "classpath:/templates/"
suffix: ".html"
mode: HTML
encoding: UTF-8
check-template-location: true

jpa:
hibernate:
ddl-auto: none
show-sql: false
open-in-view: true


# Spring Actuator - Global
management:
server:
port: 9090
endpoints:
web:
exposure:
include: "*"
endpoint:
health:
show-details: when_authorized
metrics:
tags:
application: ${spring.application.name}
## Disable LDAP by default
health:
ldap:
enabled: false

# Spring Actuator - Info endpoint
info:
app:
name: ${spring.application.name}


# Kafka WebView custom
app:

## Application name
name: Kafka WebView

## TODO: add a description to this configuration
uploadPath: "./data/uploads"

## Should be unique to your installation.
## This key will be used for symmetric encryption of JKS/TrustStore secrets if you configure any SSL enabled Kafka clusters.
key: "SuperSecretKey"
Expand Down Expand Up @@ -36,13 +117,14 @@ app:
## Setting to false will disable login requirement.
enabled: true

## Ldap auth settings
## Optional: if you want to use LDAP for user authentication instead of locally defined users.
ldap:
## Disabled by default.
enabled: false

## URL/Hostname for your LDAP server
url: "ldap://localhost:8389/dc=example,dc=org"
url: "ldap://localhost:63182/dc=example,dc=org"

## Example values defined below, adjust as needed.
## How to find user records
Expand Down Expand Up @@ -73,4 +155,4 @@ app:
## If LDAP does not allow anonymous access, define the user/password to connect using.
## If not required, leave both fields empty
bindUser: "cn=ManagementUser"
bindUserPassword: "password-here"
bindUserPassword: "password-here"
Loading