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.3: Features/properties-makefile-dockerfile #202

Open
wants to merge 20 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
78a315e
Added Micrometer Prometheus to Maven pom
Dec 13, 2019
84d393c
Updated WebConfig to include a StringHttpMessageConverter in order to…
Dec 13, 2019
2702562
Updated "dev" config to setup advanced Spring Actuator properties - A…
Dec 13, 2019
f7f763e
Updated README - Removed commented dev property
Dec 13, 2019
2856bf9
Added property to export all Tomcat metrics
Dec 14, 2019
5b4e6cd
Fixed Actuator login issue
Dec 15, 2019
de32f00
Moved Actuator-related properties from dev.yml to base.yml
bygui86 Dec 16, 2019
d393cf8
Added missing javadoc comment
Dec 18, 2019
eb00270
Added dynamic port configuration to Dockerfile
Dec 20, 2019
51859a3
Merge branch 'master' into features/improve-dockerfile
Dec 20, 2019
1d0712d
Refactored application properties system
Dec 20, 2019
2866733
Added Makefile - Removed buildAndRun script
Dec 20, 2019
86c0ee5
Merge branch 'features/improve-dockerfile' into features/properties-m…
Dec 20, 2019
c9694fc
Fixed start.sh as discussed in the PR
Jan 4, 2020
8d3a9fe
Merge branch 'features/properties-makefile-docker' into features/prop…
Jan 4, 2020
484eb76
Merge branch 'features/properties-makefile-docker-2' into features/pr…
Jan 4, 2020
dc4ae09
Dockerfile refactoring - Updated makefile
Jan 4, 2020
a43abe8
Fix start script big mistake
bygui86 Jan 5, 2020
a16170e
Merge branch 'features/properties-makefile-docker' into features/prop…
bygui86 Jan 5, 2020
65a229b
Merge branch 'features/properties-makefile-docker-2' into features/pr…
bygui86 Jan 5, 2020
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
39 changes: 0 additions & 39 deletions Dockerfile

This file was deleted.

131 changes: 131 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@

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

# Available values: local | release
DOCKERFILE_PREFIX = local

# If DOCKERFILE_PREFIX set as 'release', please properly specify also following variables
WEBVIEW_RELEASE_VERSION = 2.5.0
WEBVIEW_RELEASE_SHA1 = 00a8db474ba2c584c5a473c8ca9acbd0259c01de
WEBVIEW_RELEASE_URL = https://github.com/SourceLabOrg/kafka-webview/releases/download/v$(WEBVIEW_RELEASE_VERSION)/kafka-webview-ui-$(WEBVIEW_RELEASE_VERSION)-bin.zip



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



# ACTIONS

## BUILD

### Kafka-WebView only

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

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

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

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)

## DOCKER

docker-build : ## Build Docker image
ifeq ($(DOCKERFILE_PREFIX), local)
docker build \
-f $(DOCKERFILE_PREFIX).Dockerfile \
-t sourcelaborg/kafka-webview \
.
else
docker build \
-f $(DOCKERFILE_PREFIX).Dockerfile \
-t sourcelaborg/kafka-webview \
--build-arg WEBVIEW_VER=$(WEBVIEW_RELEASE_VERSION) \
--build-arg WEBVIEW_SHA1=$(WEBVIEW_RELEASE_SHA1) \
--build-arg WEBVIEW_URL=$(WEBVIEW_RELEASE_URL) \
.
endif

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)

## 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)

jar-run : 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-run : docker-build ## Build Docker image and run Kafka-WebView in container
docker run -ti --rm --name kafka-webview \
-p 8080:8080 -p 9090:9090 \
sourcelaborg/kafka-webview

docker-run-daemon : docker-build ## Build Docker image and run Kafka-WebView in container as daemon
docker run -d --rm --name kafka-webview \
-p 8080:8080 -p 9090:9090 \
sourcelaborg/kafka-webview

## 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 "DOCKERFILE_PREFIX: $(DOCKERFILE_PREFIX)"
@echo "WEBVIEW_RELEASE_VERSION: $(WEBVIEW_RELEASE_VERSION)"
@echo "WEBVIEW_RELEASE_SHA1: $(WEBVIEW_RELEASE_SHA1)"
@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