Skip to content

Commit

Permalink
Merge bd91c0f into 39b66f7
Browse files Browse the repository at this point in the history
  • Loading branch information
micheljung committed Jul 31, 2018
2 parents 39b66f7 + bd91c0f commit 55ab965
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 72 deletions.
14 changes: 12 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,21 @@ script:

after_success:
- ./gradlew jacocoTestReport coveralls
- export IMAGE_TAG=faf-java-api;
- export REPO=faforever/faf-java-api;
- if [ -n "${TRAVIS_TAG}" ]; then
./gradlew --stacktrace pushDockerImage;
docker build -t ${IMAGE_TAG} . &&
echo "${DOCKER_PASSWORD}" | docker login -u "${DOCKER_USERNAME}" --password-stdin &&
docker tag ${IMAGE_TAG} ${REPO}:${TRAVIS_TAG} &&
docker push ${REPO};
fi
# TODO Codacy coverage reporter does not yet support Java 9. See https://github.com/codacy/codacy-coverage-reporter/issues/76
# ./gradlew sendCoverageToCodacy;
- if [ "${TRAVIS_BRANCH}" == "develop" ]; then
./gradlew jacocoTestReport sendCoverageToCodacy;
docker build -t ${IMAGE_TAG} . &&
echo "${DOCKER_PASSWORD}" | docker login -u "${DOCKER_USERNAME}" --password-stdin &&
docker tag ${IMAGE_TAG} ${REPO}:${TRAVIS_BRANCH} &&
docker push ${REPO};
fi

before_cache:
Expand Down
7 changes: 7 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM openjdk:9-jdk-slim

MAINTAINER Michel Jung <michel.jung89@gmail.com>

VOLUME /tmp
COPY build/libs/faf-java-api-*.jar app.jar
ENTRYPOINT ["java", "-server", "-Djava.security.egd=file:/dev/./urandom", "-jar", "app.jar"]
69 changes: 0 additions & 69 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ buildscript {
maven { url 'http://repo.spring.io/plugins-release' }
}
dependencies {
classpath("com.bmuschko:gradle-docker-plugin:${gradleDockerVersion}")
classpath("org.springframework.build.gradle:propdeps-plugin:${propdepsVersion}")
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
classpath("org.kt3k.gradle.plugin:coveralls-gradle-plugin:${coverallsGradlePluginVersion}")
Expand Down Expand Up @@ -195,74 +194,6 @@ task sendCoverageToCodacy(type: JavaExec, dependsOn: jacocoTestReport) {
args = ["report", "-l", "Java", "-r", "${buildDir}/reports/jacoco/test/jacocoTestReport.xml"]
}

// DOCKER

apply plugin: 'com.bmuschko.docker-remote-api'
apply plugin: 'application'
mainClassName = 'com.faforever.api.FafApiApplication'

import com.bmuschko.gradle.docker.DockerRemoteApiPlugin
import com.bmuschko.gradle.docker.tasks.image.DockerBuildImage
import com.bmuschko.gradle.docker.tasks.image.DockerPushImage
import com.bmuschko.gradle.docker.tasks.image.Dockerfile

applicationName = rootProject.name
docker {
if (project.hasProperty('dockerHost')) {
url = dockerHost
}

registryCredentials {
if (project.hasProperty('dockerUsername') && project.hasProperty('dockerPassword')) {
username = dockerUsername
password = dockerPassword
}
}
}

task dockerCopyDistResources(type: Copy, dependsOn: distTar) {
group = DockerRemoteApiPlugin.DEFAULT_TASK_GROUP
description = "Copies the distribution resources to a temporary directory for image creation."

from { distTar.archivePath }
from 'src/main/docker/default-cmd.sh'
into { createDockerfile.destFile.parentFile }
}

task createDockerfile(type: Dockerfile, dependsOn: dockerCopyDistResources) {
group = DockerRemoteApiPlugin.DEFAULT_TASK_GROUP
destFile = file("${buildDir}/docker/Dockerfile")
from 'frolvlad/alpine-oraclejdk8:slim'
maintainer 'Michel Jung "michel.jung89@gmail.com"'

environmentVariable 'user', 'root'

user '${user}'

volume '/tmp'
addFile 'default-cmd.sh', 'default-cmd.sh'
addFile({ distTar.archivePath.name }, { '/' })

runCommand 'chmod +x default-cmd.sh'

exposePort 8010

defaultCommand './default-cmd.sh', "/${project.name}-${project.version}/bin/${project.name}"
}

task buildDockerImage(type: DockerBuildImage, dependsOn: createDockerfile) {
inputDir file(createDockerfile.destFile.parentFile)
tag "${project.group}/${rootProject.name}:${project.version}"
}

task pushDockerImage(type: DockerPushImage, dependsOn: buildDockerImage) {
group = DockerRemoteApiPlugin.DEFAULT_TASK_GROUP
description = "Publishes the created docker image tagged with the project's version."

imageName "${project.group}/${rootProject.name}"
tag project.version
}

configurations.all {
// Cache -SNAPSHOT for 60 seconds only
resolutionStrategy.cacheChangingModulesFor 60, 'seconds'
Expand Down
1 change: 0 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ jjwtVersion=0.7.0
javaxInjectVersion=1
elideVersion=4.2.3
mysqlConnectorVersion=6.0.5
gradleDockerVersion=3.2.5
propdepsVersion=0.0.7
swaggerVersion=2.6.1
swaggerCoreVersion=1.5.8
Expand Down

0 comments on commit 55ab965

Please sign in to comment.