Skip to content

Commit

Permalink
Updated docker config, git-commit-id plugin config.
Browse files Browse the repository at this point in the history
  • Loading branch information
sivaprasadreddy committed Apr 16, 2020
1 parent f0fb495 commit 22a26a1
Show file tree
Hide file tree
Showing 19 changed files with 112 additions and 16 deletions.
14 changes: 10 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# spring-boot-microservices-series
Code for SpringBoot MicroServices Blog Series
Code for [SpringBoot MicroServices Blog Series](https://sivalabs.in/2018/03/microservices-using-springboot-spring-cloud-part-1-overview/)

## How to run?

Expand All @@ -9,15 +9,21 @@ Code for SpringBoot MicroServices Blog Series

### Start infrastructure modules in docker:

`spring-boot-microservices-series> docker-compose up -d mysqldb rabbitmq setup-vault config-server service-registry hystrix-dashboard`
**The simplest way to run all the services in Docker:**

`spring-boot-microservices-series> ./run.sh start_all`

**To start only infrastructure services (mysqldb, rabbitmq, config-server, service-registry, hystrix-dashboard) in docker:**

`spring-boot-microservices-series> ./run.sh start_infra`

**Start each microservice either in local or in docker:**

**Local:** `spring-boot-microservices-series/catalog-service> ./mvnw spring-boot:run`

**Docker:** `spring-boot-microservices-series> docker-compose up -d <service> --build --force-recreate`
**Docker:** `spring-boot-microservices-series> ./run.sh start <service>`

Ex: `spring-boot-microservices-series> docker-compose up -d catalog-service --build --force-recreate`
Ex: `spring-boot-microservices-series> ./run.sh start catalog-service`


* MySQL container:
Expand Down
2 changes: 1 addition & 1 deletion catalog-service/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM frolvlad/alpine-java
FROM fabric8/java-alpine-openjdk8-jre
ADD ["target/catalog-service-0.0.1-SNAPSHOT-exec.jar", "app.jar"]
EXPOSE 8181 8787
ENV JAVA_OPTS="-Xdebug -Xrunjdwp:server=y,transport=dt_socket,address=8787,suspend=n"
Expand Down
4 changes: 4 additions & 0 deletions catalog-service/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,10 @@
<plugin>
<groupId>pl.project13.maven</groupId>
<artifactId>git-commit-id-plugin</artifactId>
<configuration>
<failOnNoGitDirectory>false</failOnNoGitDirectory>
<failOnUnableToExtractRepoInfo>false</failOnUnableToExtractRepoInfo>
</configuration>
</plugin>
</plugins>
</build>
Expand Down
2 changes: 1 addition & 1 deletion config-server/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM frolvlad/alpine-java
FROM fabric8/java-alpine-openjdk8-jre
ADD ["target/config-server-0.0.1-SNAPSHOT-exec.jar", "app.jar"]
EXPOSE 8888 8787
ENV JAVA_OPTS="-Xdebug -Xrunjdwp:server=y,transport=dt_socket,address=8787,suspend=n"
Expand Down
4 changes: 4 additions & 0 deletions config-server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@
<plugin>
<groupId>pl.project13.maven</groupId>
<artifactId>git-commit-id-plugin</artifactId>
<configuration>
<failOnNoGitDirectory>false</failOnNoGitDirectory>
<failOnUnableToExtractRepoInfo>false</failOnUnableToExtractRepoInfo>
</configuration>
</plugin>
</plugins>
</build>
Expand Down
12 changes: 8 additions & 4 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ services:
MYSQL_DATABASE: catalog

rabbitmq:
image: 'rabbitmq:3.8.3-management'
container_name: rabbitmq
image: 'rabbitmq:management'
environment:
- RABBITMQ_DEFAULT_USER=guest
- RABBITMQ_DEFAULT_PASS=guest
Expand All @@ -20,7 +20,7 @@ services:
- "15672:15672"

vault:
image: vault
image: vault:1.4.0
container_name: vault
cap_add:
- IPC_LOCK
Expand All @@ -30,7 +30,7 @@ services:
- 8200:8200

setup-vault:
image: vault
image: vault:1.4.0
container_name: setup-vault
entrypoint: /bin/sh
volumes:
Expand All @@ -47,7 +47,7 @@ services:
- vault

zipkin-server:
image: openzipkin/zipkin
image: openzipkin/zipkin:2.21
container_name: zipkin
# Environment settings are defined here https://github.com/openzipkin/zipkin/tree/1.19.0/zipkin-server#environment-variables
environment:
Expand Down Expand Up @@ -109,6 +109,7 @@ services:
- "19797:8787"
depends_on:
- config-server
- setup-vault
- mysqldb
entrypoint: /bin/sh
command: >
Expand All @@ -124,6 +125,7 @@ services:
- "29797:8787"
depends_on:
- config-server
- setup-vault
- mysqldb
entrypoint: /bin/sh
command: >
Expand All @@ -139,6 +141,7 @@ services:
- "39797:8787"
depends_on:
- config-server
- setup-vault
entrypoint: /bin/sh
command: >
-c "
Expand All @@ -153,6 +156,7 @@ services:
- "49797:8787"
depends_on:
- config-server
- setup-vault
entrypoint: /bin/sh
command: >
-c "
Expand Down
2 changes: 1 addition & 1 deletion hystrix-dashboard/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM frolvlad/alpine-java
FROM fabric8/java-alpine-openjdk8-jre
ADD ["target/hystrix-dashboard-0.0.1-SNAPSHOT-exec.jar", "app.jar"]
EXPOSE 8788 8787
ENV JAVA_OPTS="-Xdebug -Xrunjdwp:server=y,transport=dt_socket,address=8787,suspend=n"
Expand Down
4 changes: 4 additions & 0 deletions hystrix-dashboard/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@
<plugin>
<groupId>pl.project13.maven</groupId>
<artifactId>git-commit-id-plugin</artifactId>
<configuration>
<failOnNoGitDirectory>false</failOnNoGitDirectory>
<failOnUnableToExtractRepoInfo>false</failOnUnableToExtractRepoInfo>
</configuration>
</plugin>
</plugins>
</build>
Expand Down
2 changes: 1 addition & 1 deletion inventory-service/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM frolvlad/alpine-java
FROM fabric8/java-alpine-openjdk8-jre
ADD ["target/inventory-service-0.0.1-SNAPSHOT-exec.jar", "app.jar"]
EXPOSE 8282 8787
ENV JAVA_OPTS="-Xdebug -Xrunjdwp:server=y,transport=dt_socket,address=8787,suspend=n"
Expand Down
4 changes: 4 additions & 0 deletions inventory-service/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,10 @@
<plugin>
<groupId>pl.project13.maven</groupId>
<artifactId>git-commit-id-plugin</artifactId>
<configuration>
<failOnNoGitDirectory>false</failOnNoGitDirectory>
<failOnUnableToExtractRepoInfo>false</failOnUnableToExtractRepoInfo>
</configuration>
</plugin>
</plugins>
</build>
Expand Down
2 changes: 1 addition & 1 deletion oauth2-server/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM frolvlad/alpine-java
FROM fabric8/java-alpine-openjdk8-jre
ADD ["target/oauth2-server-0.0.1-SNAPSHOT-exec.jar", "app.jar"]
EXPOSE 8901 8787
ENV JAVA_OPTS="-Xdebug -Xrunjdwp:server=y,transport=dt_socket,address=8787,suspend=n"
Expand Down
4 changes: 4 additions & 0 deletions oauth2-server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@
<plugin>
<groupId>pl.project13.maven</groupId>
<artifactId>git-commit-id-plugin</artifactId>
<configuration>
<failOnNoGitDirectory>false</failOnNoGitDirectory>
<failOnUnableToExtractRepoInfo>false</failOnUnableToExtractRepoInfo>
</configuration>
</plugin>
</plugins>
</build>
Expand Down
2 changes: 1 addition & 1 deletion order-service/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM frolvlad/alpine-java
FROM fabric8/java-alpine-openjdk8-jre
ADD ["target/order-service-0.0.1-SNAPSHOT-exec.jar", "app.jar"]
EXPOSE 8383 8787
ENV JAVA_OPTS="-Xdebug -Xrunjdwp:server=y,transport=dt_socket,address=8787,suspend=n"
Expand Down
4 changes: 4 additions & 0 deletions order-service/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@
<plugin>
<groupId>pl.project13.maven</groupId>
<artifactId>git-commit-id-plugin</artifactId>
<configuration>
<failOnNoGitDirectory>false</failOnNoGitDirectory>
<failOnUnableToExtractRepoInfo>false</failOnUnableToExtractRepoInfo>
</configuration>
</plugin>
</plugins>
</build>
Expand Down
54 changes: 54 additions & 0 deletions run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#!/bin/bash

declare project_dir=$(dirname $0)
declare dc_main=${project_dir}/docker-compose.yml

function restart() {
stop_all
start_all
}

function start() {
echo "Starting $1...."
build_api
docker-compose -f ${dc_main} up --build --force-recreate -d $1
docker-compose -f ${dc_main} logs -f
}

function stop() {
echo "Stopping $1...."
docker-compose -f ${dc_main} stop
docker-compose -f ${dc_main} rm -f
}

function start_infra() {
echo "Starting mysqldb rabbitmq setup-vault config-server service-registry hystrix-dashboard...."
docker-compose -f ${dc_main} up --build --force-recreate -d mysqldb rabbitmq setup-vault config-server service-registry hystrix-dashboard
docker-compose -f ${dc_main} logs -f
}

function start_all() {
echo "Starting all services...."
build_api
docker-compose -f ${dc_main} up --build --force-recreate -d
docker-compose -f ${dc_main} logs -f
}

function stop_all() {
echo 'Stopping all services....'
docker-compose -f ${dc_main} stop
docker-compose -f ${dc_main} rm -f
}

function build_api() {
./mvnw clean package -DskipTests
}

action="start_all"

if [[ "$#" != "0" ]]
then
action=$@
fi

eval ${action}
2 changes: 1 addition & 1 deletion service-registry/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM frolvlad/alpine-java
FROM fabric8/java-alpine-openjdk8-jre
ADD ["target/service-registry-0.0.1-SNAPSHOT-exec.jar", "app.jar"]
EXPOSE 8761 8787
ENV JAVA_OPTS="-Xdebug -Xrunjdwp:server=y,transport=dt_socket,address=8787,suspend=n"
Expand Down
4 changes: 4 additions & 0 deletions service-registry/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@
<plugin>
<groupId>pl.project13.maven</groupId>
<artifactId>git-commit-id-plugin</artifactId>
<configuration>
<failOnNoGitDirectory>false</failOnNoGitDirectory>
<failOnUnableToExtractRepoInfo>false</failOnUnableToExtractRepoInfo>
</configuration>
</plugin>
</plugins>
</build>
Expand Down
2 changes: 1 addition & 1 deletion shoppingcart-ui/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM frolvlad/alpine-java
FROM fabric8/java-alpine-openjdk8-jre
ADD ["target/shoppingcart-ui-0.0.1-SNAPSHOT-exec.jar", "app.jar"]
EXPOSE 8080 8787
ENV JAVA_OPTS="-Xdebug -Xrunjdwp:server=y,transport=dt_socket,address=8787,suspend=n"
Expand Down
4 changes: 4 additions & 0 deletions shoppingcart-ui/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@
<plugin>
<groupId>pl.project13.maven</groupId>
<artifactId>git-commit-id-plugin</artifactId>
<configuration>
<failOnNoGitDirectory>false</failOnNoGitDirectory>
<failOnUnableToExtractRepoInfo>false</failOnUnableToExtractRepoInfo>
</configuration>
</plugin>
</plugins>
</build>
Expand Down

0 comments on commit 22a26a1

Please sign in to comment.