Skip to content

Commit

Permalink
Added docker build
Browse files Browse the repository at this point in the history
  • Loading branch information
blootsvoets committed Jan 10, 2018
1 parent 21d0990 commit 90c00e3
Show file tree
Hide file tree
Showing 15 changed files with 429 additions and 140 deletions.
5 changes: 5 additions & 0 deletions .dockerignore
@@ -0,0 +1,5 @@
/.git
/out/
/build/
/.idea/
/src/test
44 changes: 44 additions & 0 deletions Dockerfile
@@ -0,0 +1,44 @@
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

FROM openjdk:8-alpine as builder

RUN mkdir /code
WORKDIR /code

ENV GRADLE_OPTS -Dorg.gradle.daemon=false -Dorg.gradle.project.profile=docker

COPY ./gradle/wrapper /code/gradle/wrapper
COPY ./gradlew /code/
RUN ./gradlew --version

COPY ./gradle/profile.docker.gradle /code/gradle/
COPY ./build.gradle ./gradle.properties ./settings.gradle /code/

RUN ./gradlew downloadDependencies

COPY ./src/ /code/src

RUN ./gradlew jar

FROM confluentinc/cp-kafka-connect:4.0.0

MAINTAINER Nivethika M <nivethika@thehyve.nl> , Joris B <joris@thehyve.nl>

LABEL description="MongoDB Sink Connector"

COPY --from=builder /code/build/libs/*.jar /etc/kafka-connect/jars/

COPY ./src/main/docker/kafka-wait /usr/bin/kafka-wait

# Load modified launcher
COPY ./src/main/docker/launch /etc/confluent/docker/launch
144 changes: 9 additions & 135 deletions build.gradle
@@ -1,12 +1,7 @@
plugins {
// Apply the java plugin to add support for Java
id 'java-library'
id 'idea'
id 'jacoco'
id 'pmd'
id 'checkstyle'
id "com.jfrog.bintray" version "1.7.3"
id 'maven-publish'
id "com.jfrog.bintray" version "1.7.3" apply false
}

version = '0.2-SNAPSHOT'
Expand All @@ -18,21 +13,10 @@ ext.slf4jVersion = '1.7.25'
ext.kafkaVersion = '1.0.0'
ext.mongodbVersion = '3.6.1'

ext.junitVersion = '4.12'
ext.hamcrestVersion = '1.3'
ext.mockitoVersion = '2.2.29'

configurations {
codacy
}

// In this section you declare where to find the dependencies of your project
repositories {
// Use 'jcenter' for resolving your dependencies.
// You can declare any Maven/Ivy/file repository here.
jcenter()
maven { url 'http://packages.confluent.io/maven/' }
maven { url 'https://jitpack.io' }
maven { url 'http://dl.bintray.com/typesafe/maven-releases' }
}

Expand All @@ -45,14 +29,6 @@ dependencies {
compileOnly group: 'org.apache.kafka', name: 'connect-api', version: kafkaVersion

api group: 'org.mongodb', name: 'mongo-java-driver', version: mongodbVersion

testCompile group: 'junit', name: 'junit', version: junitVersion
testImplementation group: 'org.hamcrest', name: 'hamcrest-all', version: hamcrestVersion
testImplementation group: 'org.mockito', name: 'mockito-core', version: mockitoVersion
testImplementation group: 'org.apache.kafka', name: 'connect-api', version: kafkaVersion
testRuntimeOnly group: 'org.slf4j', name: 'slf4j-simple', version: slf4jVersion

codacy 'com.github.codacy:codacy-coverage-reporter:1.0.10'
}


Expand All @@ -61,121 +37,19 @@ jar {
attributes 'Implementation-Title': 'RADAR-CNS MongoDB connector',
'Implementation-Version': version
}
}

checkstyle {
toolVersion '6.16'
}

pmd {
toolVersion = '5.5.2'
consoleOutput = true

ruleSets = []
ruleSetFiles = files("config/pmd/ruleset.xml")
}


pmdTest {
ruleSetFiles = files("config/pmd/test_ruleset.xml")
}

jacocoTestReport {
reports {
xml.enabled true
csv.enabled false
html.enabled false
}
}

task downloadDependencies(type: Exec) {
configurations.testRuntime.files
configurations.codacy.files
configurations.jacocoAnt.files
commandLine 'echo', 'Downloaded all dependencies'
}

task sendCoverageToCodacy(type: JavaExec, dependsOn: jacocoTestReport) {
main = 'com.codacy.CodacyCoverageReporter'
classpath = configurations.codacy
args = ['-l', 'Java', '-r', "${buildDir}/reports/jacoco/test/jacocoTestReport.xml"]
}

def pomConfig = {
licenses {
license {
name "The Apache Software License, Version 2.0"
url "http://www.apache.org/licenses/LICENSE-2.0.txt"
distribution "RADAR-CNS Distributions"
}
}
developers {
developer {
id "radar-cns"
name "Nivethika"
email "nivethika@thehyve.nl"
from {
configurations.runtimeClasspath.collect {
it.isDirectory() ? it : zipTree(it)
}
}
}
// custom tasks for creating source/javadoc jars
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = 'sources'
from sourceSets.main.output
}

task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}

// add javadoc/source jar tasks as artifacts
artifacts {
archives sourcesJar, javadocJar
}


publishing {
publications {
RadarMongoDBPublication(MavenPublication) {
from components.java
artifact sourcesJar
artifact javadocJar
groupId 'org.radarcns'
artifactId 'kafka-connect-mongodb-sink'
version project.version
pom.withXml {
def root = asNode()
root.appendNode('description', 'The MongoDB sink connector is a tool for scalably and reliably streaming data between Apache Kafka and MongoDB.')
root.appendNode('name', 'kafka-connect-mongodb-sink')
root.appendNode('url', 'https://github.com/RADAR-CNS/MongoDb-Sink-Connector.git')
root.children().last() + pomConfig
}
}
}
task wrapper(type: Wrapper) {
gradleVersion = '4.4'
}



bintray {
user = System.getenv('BINTRAY_USER') ? System.getenv('BINTRAY_USER') : project.hasProperty('bintrayUser')
key = System.getenv('BINTRAY_API_KEY') ? System.getenv('BINTRAY_API_KEY') : project.hasProperty('bintrayApiKey')
override = false
publications = ['RadarMongoDBPublication']
pkg {
repo = 'org.radarcns'
name = 'kafka-connect-mongodb-sink'
userOrg = 'radar-cns'
licenses = ['Apache-2.0']
vcsUrl = 'https://github.com/RADAR-CNS/MongoDb-Sink-Connector.git'
version {
name = project.version
desc = 'Initial alpha release'
vcsTag = System.getenv('TRAVIS_TAG')
released = new Date()
}
}
if (!hasProperty('profile')) {
ext.profile = 'dev'
}

task wrapper(type: Wrapper) {
gradleVersion = '4.4'
}
apply from: "gradle/profile.${profile}.gradle"
29 changes: 29 additions & 0 deletions gradle/codacy.gradle
@@ -0,0 +1,29 @@
apply plugin: 'jacoco'

configurations {
codacy
}

// In this section you declare where to find the dependencies of your project
repositories {
jcenter()
maven { url 'https://jitpack.io' }
}

dependencies {
codacy 'com.github.codacy:codacy-coverage-reporter:2.0.1'
}

jacocoTestReport {
reports {
xml.enabled true
csv.enabled false
html.enabled false
}
}

task sendCoverageToCodacy(type: JavaExec, dependsOn: jacocoTestReport) {
main = 'com.codacy.CodacyCoverageReporter'
classpath = configurations.codacy
args = ['-l', 'Java', '-r', "${buildDir}/reports/jacoco/test/jacocoTestReport.xml"]
}
12 changes: 12 additions & 0 deletions gradle/profile.dev.gradle
@@ -0,0 +1,12 @@
apply from: 'gradle/test.gradle'
apply from: 'gradle/style.gradle'
apply from: 'gradle/publishing.gradle'
apply from: 'gradle/codacy.gradle'

task downloadDependencies(type: Exec) {
configurations.compileClasspath.files
configurations.testRuntimeClasspath.files
configurations.codacy.files
configurations.jacocoAnt.files
commandLine 'echo', 'Downloaded all dependencies'
}
5 changes: 5 additions & 0 deletions gradle/profile.docker.gradle
@@ -0,0 +1,5 @@
task downloadDependencies(type: Exec) {
configurations.compileClasspath.files
configurations.runtimeClasspath.files
commandLine 'echo', 'Downloaded all dependencies'
}
86 changes: 86 additions & 0 deletions gradle/publishing.gradle
@@ -0,0 +1,86 @@
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3'
}
}

apply plugin: 'maven-publish'
apply plugin: 'com.jfrog.bintray'

def pomConfig = {
licenses {
license {
name "The Apache Software License, Version 2.0"
url "http://www.apache.org/licenses/LICENSE-2.0.txt"
distribution "RADAR-CNS Distributions"
}
}
developers {
developer {
id "radar-cns"
name "Nivethika"
email "nivethika@thehyve.nl"
}
}
}
// custom tasks for creating source/javadoc jars
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = 'sources'
from sourceSets.main.output
}

task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}

// add javadoc/source jar tasks as artifacts
artifacts {
archives sourcesJar, javadocJar
}


publishing {
publications {
RadarMongoDBPublication(MavenPublication) {
from components.java
artifact sourcesJar
artifact javadocJar
groupId 'org.radarcns'
artifactId 'kafka-connect-mongodb-sink'
version project.version
pom.withXml {
def root = asNode()
root.appendNode('description', 'The MongoDB sink connector is a tool for scalably and reliably streaming data between Apache Kafka and MongoDB.')
root.appendNode('name', 'kafka-connect-mongodb-sink')
root.appendNode('url', 'https://github.com/RADAR-CNS/MongoDb-Sink-Connector.git')
root.children().last() + pomConfig
}
}
}
}



bintray {
user = System.getenv('BINTRAY_USER') ? System.getenv('BINTRAY_USER') : project.hasProperty('bintrayUser')
key = System.getenv('BINTRAY_API_KEY') ? System.getenv('BINTRAY_API_KEY') : project.hasProperty('bintrayApiKey')
override = false
publications = ['RadarMongoDBPublication']
pkg {
repo = 'org.radarcns'
name = 'kafka-connect-mongodb-sink'
userOrg = 'radar-cns'
licenses = ['Apache-2.0']
vcsUrl = 'https://github.com/RADAR-CNS/MongoDb-Sink-Connector.git'
version {
name = project.version
desc = 'Initial alpha release'
vcsTag = System.getenv('TRAVIS_TAG')
released = new Date()
}
}
}
19 changes: 19 additions & 0 deletions gradle/style.gradle
@@ -0,0 +1,19 @@
apply plugin: 'pmd'
apply plugin: 'checkstyle'

checkstyle {
toolVersion '6.16'
}

pmd {
toolVersion = '5.5.2'
consoleOutput = true

ruleSets = []
ruleSetFiles = files("config/pmd/ruleset.xml")
}


pmdTest {
ruleSetFiles = files("config/pmd/test_ruleset.xml")
}

0 comments on commit 90c00e3

Please sign in to comment.