Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
91dc86a
Ignore volume
AlexTalker Aug 29, 2019
af0b83a
Initial draft for API deployment
AlexTalker Sep 1, 2019
ca2d75a
Improvement draft
AlexTalker Sep 10, 2019
253ee69
Extend git ignore
AlexTalker Sep 10, 2019
d2d21fb
Save up current changes
AlexTalker Oct 4, 2019
12c3bb7
Fix up api-deployer
AlexTalker Oct 4, 2019
ff2349d
Put docker files in order
AlexTalker Oct 4, 2019
eeb23fa
Fix up grafana once more
AlexTalker Oct 4, 2019
5bbd0b9
Fix up services monitoring
AlexTalker Oct 4, 2019
95e2ba2
Grafana changes
AlexTalker Oct 4, 2019
acbed46
Improve .gitignore
AlexTalker Oct 4, 2019
ddc42b2
Fix up artifactory deployment
AlexTalker Oct 5, 2019
ffc3994
Include repo setup in api-deployer
AlexTalker Oct 5, 2019
96e6ec7
Do not try to use artifactory by SSL for now
AlexTalker Oct 5, 2019
e7ae9c8
Parametrize artifactory usage properly
AlexTalker Oct 5, 2019
89c1eb4
Clean up usage of mavenCentral
AlexTalker Oct 5, 2019
a7b583b
Checking travis
AlexTalker Oct 5, 2019
c2c0e41
Trying out artifactory
AlexTalker Oct 5, 2019
a2d9d7d
Fix up a typo
AlexTalker Oct 5, 2019
38874d5
Trying to wait for the artifactory
AlexTalker Oct 5, 2019
be7d0b7
Fix up waiting
AlexTalker Oct 5, 2019
2709400
Do actual project building
AlexTalker Oct 5, 2019
79da0f1
Trying out extended timeout
AlexTalker Oct 5, 2019
960d0e4
Debug travis docker network
AlexTalker Oct 5, 2019
af78fdd
Trying to determine IP at build time
AlexTalker Oct 5, 2019
91ce636
Trying to fix the issue by variable substitituion
AlexTalker Oct 5, 2019
e63b20c
Fixing up a doc
AlexTalker Oct 5, 2019
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
16 changes: 15 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
.gradle
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we need this?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If running gradle from top, this directory is created. Also, I think this will ignore .gradle in each sub-directory also, which is good, since it is a technical directory and mainly mustn't be committed.

*/.gradle
*/build/
*/!gradle/wrapper/gradle-wrapper.jar
*.class

.idea
*.iws
Expand All @@ -9,4 +11,16 @@

#pattern for excluding generated proto files from git
**/api/messages/
**/api/events/
**/api/events/

# Docker volumes
artifactory/volume/

# Auto-generated
.project
.classpath
org.eclipse.buildship.core.prefs

# Other
api-gateway-service/bin/main/application.yml
eureka-service-discovery/bin/main/application.yml
16 changes: 16 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
services:
- docker

env:
# Update if building docker-compose-services.yml breaks
- ARTIFACTORY_IP=172.17.0.1

before_install:
- docker-compose -f docker-compose-storage.yml up -d
# Deploy expected configuration to Artifactory
- docker-compose -f docker-compose-storage.yml run --rm api-deployer bash -c 'while ! /setup.sh | grep successfully; do echo "Still waiting..."; sleep 1; done'

script:
- docker-compose -f docker-compose.yml -f docker-compose-services.yml pull
- docker-compose -f docker-compose-storage.yml run --rm api-deployer /api-deployer.sh
- docker-compose -f docker-compose.yml -f docker-compose-services.yml build
22 changes: 21 additions & 1 deletion accounting-service/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,24 @@
FROM gradle:5.4.1 AS builder

ARG ARTIFACTORY_URL
ARG ARTIFACTORY_USER
ARG ARTIFACTORY_PASSWORD
ARG ARTIFACTORY_REPO

ENV ORG_GRADLE_PROJECT_artifactoryUrl=${ARTIFACTORY_URL}
ENV ORG_GRADLE_PROJECT_artifactoryRepo=${ARTIFACTORY_REPO}
ENV ORG_GRADLE_PROJECT_artifactoryUser=${ARTIFACTORY_USER}
# Enforce more security
ENV ORG_GRADLE_PROJECT_artifactoryPassword=${ARTIFACTORY_PASSWORD}

WORKDIR /project

COPY . /project

RUN gradle :accounting-app:build

FROM openjdk:8-jre-alpine
COPY ./accounting-app/build/libs/accounting-service-app-0.1-SNAPSHOT.jar /accounting-service-app-0.1-SNAPSHOT.jar
COPY --from=builder /project/accounting-app/build/libs/accounting-service-app-0.1-SNAPSHOT.jar /accounting-service-app-0.1-SNAPSHOT.jar

EXPOSE 8093
ENTRYPOINT ["java", "-jar", "accounting-service-app-0.1-SNAPSHOT.jar", "--spring.profiles.active=docker"]
57 changes: 40 additions & 17 deletions accounting-service/accounting-api/build.gradle
Original file line number Diff line number Diff line change
@@ -1,29 +1,17 @@
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:2.1.4.RELEASE")
}
plugins {
id "com.jfrog.artifactory" version "4.9.8"
id 'maven-publish'
id 'idea'
id 'io.spring.dependency-management'
}


apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'io.spring.dependency-management'

group 'com.microservices.accounting.api'
version = apiVersion

jar {
archiveBaseName = "accounting-api"
}

repositories {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why don't we need this anymore?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because repositories are declared once in top of multi-module project. Instead of duplicating things in each sub-project separately. And handled by Artifactory to abuse caching as much as possible.

mavenLocal()
mavenCentral()
}

dependencies {
compile 'org.springframework.cloud:spring-cloud-openfeign-core'
compile 'javax.validation:validation-api:2.0.1.Final'
Expand All @@ -42,3 +30,38 @@ uploadArchives {
mavenLocal()
}
}

publishing {
publications {
mavenJava(MavenPublication) {
artifactId "${project.name}"
groupId = group
version = project.version
from components.java
}
}
}

artifactory {
contextUrl = "${artifactoryUrl}" //The base Artifactory URL if not overridden by the publisher/resolver
publish {
repository {
repoKey = "${artifactoryRepo}"
username = "${artifactoryUser}"
password = "${artifactoryPassword}"
maven = true
}
defaults {
publications('mavenJava')
publishArtifacts = true
}
}
resolve {
repository {
repoKey = "${artifactoryRepo}"
username = "${artifactoryUser}"
password = "${artifactoryPassword}"
maven = true
}
}
}
15 changes: 0 additions & 15 deletions accounting-service/accounting-app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,13 +1,3 @@
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'org.springframework.boot:spring-boot-gradle-plugin:2.1.4.RELEASE'
}
}

apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
Expand All @@ -20,11 +10,6 @@ bootJar {

sourceCompatibility = 1.8

repositories {
mavenLocal()
mavenCentral()
}

dependencies {
compile "com.microservices.accounting.api:accounting-api:${accountingApiVersion}"
compile 'org.springframework.boot:spring-boot-starter-web'
Expand Down
21 changes: 21 additions & 0 deletions accounting-service/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
plugins {
id 'java'
id "org.springframework.boot" version "2.1.4.RELEASE"
}

allprojects {
repositories {
maven {
url "${artifactoryUrl}/${artifactoryRepo}" // The Artifactory (preferably virtual) repository to resolve from
credentials { // Optional resolver credentials (leave out to use anonymous resolution)
username = "${artifactoryUser}" // Artifactory user name
password = "${artifactoryPassword}" // Password or API Key
}
}
}
apply plugin: "java"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please move plugin declaration at the top of scope

dependencies {
//Check for the latest version here: http://plugins.gradle.org/plugin/com.jfrog.artifactory
implementation "org.jfrog.buildinfo:build-info-extractor-gradle:4+"
}
}
13 changes: 13 additions & 0 deletions api-deployer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM gradle:5.4.1

COPY ./api-deployer.sh /api-deployer.sh
COPY ./config.yml /artifactory.yml
COPY ./repo-setup.sh /setup.sh

RUN chmod +x /api-deployer.sh /setup.sh

RUN apt-get update && apt-get install -y vim

VOLUME [ "/project" ]

WORKDIR /project
32 changes: 32 additions & 0 deletions api-deployer/api-deployer.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/usr/bin/env bash

set -e
set -x

API_PROJECTS="
laundry-management-service/laundrymanagement-api
order-management-service/ordermanagement-api
taskcoordinator/taskcoordinator-api
tariff-management-service/tariffmanagement-api
accounting-service/accounting-api
user-management-service/usermanagement-api
"

WORKDIR="${PWD}"
TMPDIR="$(mktemp -d)"

echo "Copy project into ${TMPDIR}..." 1>&2
cp -r "${WORKDIR}/." "${TMPDIR}"

cd "${TMPDIR}"

for project in ${API_PROJECTS}; do
cd "${project}"
gradle build
gradle artifactoryPublish
cd "${TMPDIR}"
done

cd "${WORKDIR}"

rm -rf "${TMPDIR}"
Loading