-
Notifications
You must be signed in to change notification settings - Fork 5
Refactoring building and deployment of Docker services #60
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
base: dev
Are you sure you want to change the base?
Changes from all commits
91dc86a
af0b83a
ca2d75a
253ee69
d2d21fb
12c3bb7
ff2349d
eeb23fa
5bbd0b9
95e2ba2
acbed46
ddc42b2
ffc3994
96e6ec7
e7ae9c8
89c1eb4
a7b583b
c2c0e41
a2d9d7d
38874d5
be7d0b7
2709400
79da0f1
960d0e4
af78fdd
91ce636
e63b20c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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 |
| 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"] |
| 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" | ||
AlexTalker marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| 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 { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why don't we need this anymore?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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' | ||
|
|
@@ -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 | ||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| plugins { | ||
| id 'java' | ||
AlexTalker marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| 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" | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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+" | ||
| } | ||
| } | ||
| 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 |
| 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}" |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If running
gradlefrom 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.