Skip to content

Commit 4edcc00

Browse files
committed
add spring-data-history-audit
1 parent a181a83 commit 4edcc00

28 files changed

+1140
-24
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ elasticsearch/
22
docker-cluster/
33
elastic/data/data/
44
out/
5+
target/
56

67
**/src/main/gen
78

.travis.yml

+26-24
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
group: edge
2-
dist: trusty
1+
sudo: required
2+
3+
service: docker
34

45
language: java
56
jdk:
@@ -12,28 +13,18 @@ env:
1213

1314
install: true
1415
before_install:
15-
- sudo apt update
16+
## docker
17+
#- wget get.docker.com -O- | sudo sh -
18+
#- sudo usermod -aG docker $(whoami)
1619

17-
# install docker-compose
18-
- sudo apt install -y python-pip curl jq libxml2-utils
20+
# docker-compose, curl, jq, httpie
21+
- sudo apt update --allow-unauthenticated
22+
- sudo apt -y install curl jq libxml2-utils python-pip
1923
- sudo pip install docker-compose httpie
20-
- sudo usermod -aG docker $(whoami)
21-
22-
# kill whatever running on ports
23-
- sudo kill $(sudo lsof -t -i:5672) | true
24-
- sudo kill $(sudo lsof -t -i:5432) | true
25-
- lsof -i tcp:27017 | awk 'NR!=1 {print $2}' | xargs kill | true
26-
- sudo kill $(sudo lsof -t -i:27017) | true
27-
28-
- sudo kill $(sudo lsof -t -i:9200) | true
29-
- sudo kill $(sudo lsof -t -i:9300) | true
30-
- sudo kill $(sudo lsof -t -i:5601) | true
3124

32-
- sudo kill $(sudo lsof -t -i:8001) | true
33-
- sudo kill $(sudo lsof -t -i:8002) | true
34-
- sudo kill $(sudo lsof -t -i:8080) | true
35-
- sudo kill $(sudo lsof -t -i:8081) | true
36-
- sudo kill $(sudo lsof -t -i:80) | true
25+
# kill ports
26+
- source <(curl -fsSL https://raw.github.com/daggerok/bash-functions/master/main.bash)
27+
- stop_any 5672 5432 27017 9200 9300 5601 8001 8002 8080 80
3728

3829
script:
3930
# build docs
@@ -42,6 +33,19 @@ script:
4233
# build all
4334
- export ROOT=$PWD
4435

36+
- cd ${ROOT}/spring-data-history-audit
37+
- bash mvnw
38+
- bash gradlew
39+
- docker-compose build --force-rm --no-cache --pull
40+
- docker-compose up --force-recreate --remove-orphans &
41+
- sleep 30
42+
- http put :8080/my-entities/1 value=ololo
43+
- http put :8080/my-entities/1 value=trololo
44+
- http put :8080/my-entities/1 value=ho-ho-ho
45+
- http put :8080/my-entities
46+
- http put :8080/my-entities-history
47+
- docker-compose down -v
48+
4549
# - >
4650
# for path in \
4751
# spring-data-hazelcast \
@@ -74,9 +78,7 @@ script:
7478
key-value \
7579
; do
7680
77-
export res="$ROOT/$path"
78-
echo $res
79-
cd $res
81+
cd ${ROOT}/${path}
8082
bash gradlew clean build -Ddocker=compose-travis
8183
8284
done;

README.adoc

+1
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,4 @@ This repository contains some spring-data playground projects
1313
//. link:elastic/[spring-data-elasticsearch]
1414
. link:key-value/[kotlin, webflix and spring-data-keyvalue]
1515
. link:key-value-hazelcast/[kotlin and spring-data-hazelcast]
16+
. link:spring-data-history-audit/[spring-data-rest advanced audit]

spring-data-history-audit/.gitignore

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
.gradle
2+
/build/
3+
!gradle/wrapper/gradle-wrapper.jar
4+
5+
### STS ###
6+
.apt_generated
7+
.classpath
8+
.factorypath
9+
.project
10+
.settings
11+
.springBeans
12+
13+
### IntelliJ IDEA ###
14+
.idea
15+
*.iws
16+
*.iml
17+
*.ipr
18+
19+
### NetBeans ###
20+
nbproject/private/
21+
build/
22+
nbbuild/
23+
dist/
24+
nbdist/
25+
.nb-gradle/
+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
FROM openjdk:8u151-jre-alpine
2+
MAINTAINER Maksim Kostromin https://github.com/daggerok
3+
RUN apk --no-cache add busybox-suid bash curl sudo \
4+
&& adduser -h /home/appuser -s /bin/bash -D -u 1025 appuser wheel \
5+
&& echo "appuser ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers \
6+
&& sed -i "s/.*requiretty$/Defaults !requiretty/" /etc/sudoers \
7+
&& apk del busybox-suid \
8+
&& rm -rf /tmp/* /var/cache/apk/*
9+
USER appuser
10+
WORKDIR /home/appuser
11+
VOLUME /home/appuser
12+
ENTRYPOINT java -XX:+UnlockExperimentalVMOptions \
13+
-XX:+UseCGroupMemoryLimitForHeap \
14+
-XshowSettings:vm \
15+
-jar ./app.jar
16+
CMD /bin/bash
17+
EXPOSE 8080
18+
HEALTHCHECK --timeout=2s \
19+
--retries=22 \
20+
CMD curl -f http://127.0.0.1:8080/health || exit 1
21+
COPY --chown=appuser ./target/*.jar ./app.jar
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.5.2/apache-maven-3.5.2-bin.zip

spring-data-history-audit/Dockerfile

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
FROM openjdk:8u151-jre-alpine
2+
MAINTAINER Maksim Kostromin https://github.com/daggerok
3+
RUN apk --no-cache add busybox-suid bash curl sudo \
4+
&& adduser -h /home/appuser -s /bin/bash -D -u 1025 appuser wheel \
5+
&& echo "appuser ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers \
6+
&& sed -i "s/.*requiretty$/Defaults !requiretty/" /etc/sudoers \
7+
&& apk del busybox-suid \
8+
&& rm -rf /tmp/* /var/cache/apk/*
9+
USER appuser
10+
WORKDIR /home/appuser
11+
VOLUME /home/appuser
12+
ENTRYPOINT java -XX:+UnlockExperimentalVMOptions \
13+
-XX:+UseCGroupMemoryLimitForHeap \
14+
-XshowSettings:vm \
15+
-jar ./app.jar
16+
CMD /bin/bash
17+
EXPOSE 8080
18+
HEALTHCHECK --timeout=2s \
19+
--retries=22 \
20+
CMD curl -f http://127.0.0.1:8080/health || exit 1
21+
COPY --chown=appuser ./build/libs/*.jar ./app.jar

spring-data-history-audit/README.adoc

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
= spring-data-history-audit image:https://travis-ci.org/daggerok/spring-data-examples.svg?branch=master["Build Status", link="https://travis-ci.org/daggerok/spring-data-examples"]
2+
3+
//tag::content[]
4+
5+
This repository contains spring-data audition implementation: object diff history audit
6+
7+
.test
8+
----
9+
http put :8080/my-entities/1 value=ololo
10+
http put :8080/my-entities/1 value=trololo
11+
http put :8080/my-entities/1 value=ho-ho-ho
12+
13+
http get :8080/my-entities
14+
http get :8080/my-entities-history
15+
----
16+
17+
.build abd run
18+
----
19+
bash gradlew clean bootRun # bash mvnw clean spring-boot:run
20+
21+
# or in docker:
22+
docker-compose down -v; ./gradlew; docker-compose up --build --force-recreate --remove-orphans
23+
24+
# or using maven:
25+
cp -Rf ./mvn/Dockerfile ./
26+
docker-compose down -v; ./mvnw; docker-compose up --build --force-recreate --remove-orphans
27+
----
28+
29+
//end::content[]
+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
buildscript {
2+
ext {
3+
springBootVersion = "1.5.9.RELEASE"
4+
}
5+
repositories {
6+
mavenCentral()
7+
}
8+
dependencies {
9+
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
10+
}
11+
}
12+
13+
apply plugin: "java"
14+
apply plugin: "eclipse"
15+
apply plugin: "org.springframework.boot"
16+
17+
group = "daggerok"
18+
version = "0.0.1"
19+
sourceCompatibility = targetCompatibility = JavaVersion.VERSION_1_8
20+
21+
repositories {
22+
mavenCentral()
23+
}
24+
25+
dependencies {
26+
compile("org.springframework.boot:spring-boot-starter-data-jpa")
27+
compile("org.springframework.boot:spring-boot-starter-data-rest")
28+
compile("org.springframework.boot:spring-boot-starter-actuator")
29+
compile("com.fasterxml.jackson.datatype:jackson-datatype-jsr310")
30+
compile("com.fasterxml.jackson.datatype:jackson-datatype-jdk8")
31+
compile("com.fasterxml.jackson.core:jackson-databind")
32+
compile("org.hibernate:hibernate-java8")
33+
compileOnly("org.projectlombok:lombok")
34+
runtime("org.springframework.boot:spring-boot-devtools")
35+
// // h2-console:
36+
//runtime("com.h2database:h2")
37+
compile("com.h2database:h2")
38+
}
39+
40+
defaultTasks "clean", "build"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
version: "2.1"
2+
3+
services:
4+
5+
app:
6+
build: .
7+
volumes: ["app-data:/home/app"]
8+
ports: ["8080:8080"]
9+
restart: unless-stopped
10+
networks: [backing-services]
11+
mem_limit: 314572800 # container limit: 350Mb (350 * 1024 * 1024)
12+
13+
volumes:
14+
app-data: {}
15+
16+
networks:
17+
backing-services:
18+
driver: bridge
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
FROM openjdk:8u151-jre-alpine
2+
MAINTAINER Maksim Kostromin https://github.com/daggerok
3+
RUN apk --no-cache add busybox-suid bash curl sudo \
4+
&& adduser -h /home/appuser -s /bin/bash -D -u 1025 appuser wheel \
5+
&& echo "appuser ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers \
6+
&& sed -i "s/.*requiretty$/Defaults !requiretty/" /etc/sudoers \
7+
&& apk del busybox-suid \
8+
&& rm -rf /tmp/* /var/cache/apk/*
9+
USER appuser
10+
WORKDIR /home/appuser
11+
VOLUME /home/appuser
12+
ENTRYPOINT java -XX:+UnlockExperimentalVMOptions \
13+
-XX:+UseCGroupMemoryLimitForHeap \
14+
-XshowSettings:vm \
15+
-jar ./app.jar
16+
CMD /bin/bash
17+
EXPOSE 8080
18+
HEALTHCHECK --timeout=2s \
19+
--retries=22 \
20+
CMD curl -f http://127.0.0.1:8080/health || exit 1
21+
COPY --chown=appuser ./build/libs/*.jar ./app.jar
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#Wed Jan 10 21:44:07 EET 2018
2+
distributionBase=GRADLE_USER_HOME
3+
distributionPath=wrapper/dists
4+
zipStoreBase=GRADLE_USER_HOME
5+
zipStorePath=wrapper/dists
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-3.5.1-all.zip

0 commit comments

Comments
 (0)