Added docker build and compose file
This commit is contained in:
5
account/account-web/docker/Dockerfile
Normal file
5
account/account-web/docker/Dockerfile
Normal file
@@ -0,0 +1,5 @@
|
||||
FROM anapsix/alpine-java:8
|
||||
VOLUME /tmp
|
||||
ADD account-web-0.0.1-SNAPSHOT.jar app.jar
|
||||
RUN bash -c 'touch /app.jar'
|
||||
ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar"]
|
||||
@@ -74,6 +74,31 @@
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>com.spotify</groupId>
|
||||
<artifactId>docker-maven-plugin</artifactId>
|
||||
<version>0.4.13</version>
|
||||
<configuration>
|
||||
<imageName>${project.artifactId}</imageName>
|
||||
<dockerDirectory>${project.basedir}/docker</dockerDirectory>
|
||||
<resources>
|
||||
<resource>
|
||||
<targetPath>/</targetPath>
|
||||
<directory>${project.build.directory}</directory>
|
||||
<include>${project.build.finalName}.jar</include>
|
||||
</resource>
|
||||
</resources>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>build-image</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>build</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
|
||||
@@ -1,46 +1,42 @@
|
||||
spring:
|
||||
profiles:
|
||||
active: development
|
||||
cloud:
|
||||
stream:
|
||||
bindings:
|
||||
output:
|
||||
destination: account
|
||||
contentType: 'application/json'
|
||||
server:
|
||||
port: 0
|
||||
events:
|
||||
worker: http://account-worker/v1/events
|
||||
---
|
||||
spring:
|
||||
profiles: development
|
||||
cloud:
|
||||
stream:
|
||||
bindings:
|
||||
output:
|
||||
destination: account
|
||||
contentType: 'application/json'
|
||||
server:
|
||||
port: 0
|
||||
events:
|
||||
worker: http://account-worker/v1/events
|
||||
---
|
||||
spring:
|
||||
profiles: docker
|
||||
rabbitmq:
|
||||
host: ${DOCKER_IP:192.168.99.100}
|
||||
port: 5672
|
||||
eureka:
|
||||
client:
|
||||
service-url:
|
||||
defaultZone: http://${DOCKER_IP:192.168.99.100}:8761/eureka
|
||||
registryFetchIntervalSeconds: 5
|
||||
instance:
|
||||
hostname: ${DOCKER_IP:192.168.99.100}
|
||||
leaseRenewalIntervalInSeconds: 5
|
||||
---
|
||||
spring:
|
||||
profiles: test
|
||||
cloud:
|
||||
stream:
|
||||
bindings:
|
||||
output:
|
||||
destination: account
|
||||
contentType: 'application/json'
|
||||
server:
|
||||
port: 0
|
||||
events:
|
||||
worker: http://account-worker/v1/events
|
||||
eureka:
|
||||
client:
|
||||
enabled: false
|
||||
---
|
||||
spring:
|
||||
profiles: cloud
|
||||
cloud:
|
||||
stream:
|
||||
bindings:
|
||||
output:
|
||||
destination: account
|
||||
contentType: 'application/json'
|
||||
events:
|
||||
worker: http://account-worker/v1/events
|
||||
eureka:
|
||||
instance:
|
||||
hostname: ${vcap.application.uris[0]:localhost}
|
||||
|
||||
5
account/account-worker/docker/Dockerfile
Normal file
5
account/account-worker/docker/Dockerfile
Normal file
@@ -0,0 +1,5 @@
|
||||
FROM anapsix/alpine-java:8
|
||||
VOLUME /tmp
|
||||
ADD account-worker-0.0.1-SNAPSHOT.jar app.jar
|
||||
RUN bash -c 'touch /app.jar'
|
||||
ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar"]
|
||||
@@ -92,6 +92,31 @@
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>com.spotify</groupId>
|
||||
<artifactId>docker-maven-plugin</artifactId>
|
||||
<version>0.4.13</version>
|
||||
<configuration>
|
||||
<imageName>${project.artifactId}</imageName>
|
||||
<dockerDirectory>${project.basedir}/docker</dockerDirectory>
|
||||
<resources>
|
||||
<resource>
|
||||
<targetPath>/</targetPath>
|
||||
<directory>${project.build.directory}</directory>
|
||||
<include>${project.build.finalName}.jar</include>
|
||||
</resource>
|
||||
</resources>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>build-image</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>build</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ import org.springframework.statemachine.StateMachine;
|
||||
*/
|
||||
@EnableAutoConfiguration
|
||||
@EnableBinding(Sink.class)
|
||||
@Profile({ "cloud", "development" })
|
||||
@Profile({ "cloud", "development", "docker" })
|
||||
public class AccountEventStream {
|
||||
|
||||
private EventService eventService;
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
spring:
|
||||
profiles:
|
||||
active: development
|
||||
---
|
||||
spring:
|
||||
profiles: development
|
||||
cloud:
|
||||
stream:
|
||||
bindings:
|
||||
@@ -13,8 +10,6 @@ spring:
|
||||
contentType: 'application/json'
|
||||
consumer:
|
||||
durableSubscription: true
|
||||
jackson:
|
||||
default-property-inclusion: non_null
|
||||
server:
|
||||
port: 0
|
||||
amazon:
|
||||
@@ -22,23 +17,31 @@ amazon:
|
||||
access-key-id: replace
|
||||
access-key-secret: replace
|
||||
---
|
||||
spring:
|
||||
profiles: development
|
||||
---
|
||||
spring:
|
||||
profiles: test
|
||||
eureka:
|
||||
client:
|
||||
enabled: false
|
||||
---
|
||||
spring:
|
||||
profiles: docker
|
||||
rabbitmq:
|
||||
host: ${DOCKER_IP:192.168.99.100}
|
||||
port: 5672
|
||||
eureka:
|
||||
client:
|
||||
service-url:
|
||||
defaultZone: http://${DOCKER_IP:192.168.99.100}:8761/eureka
|
||||
registryFetchIntervalSeconds: 5
|
||||
instance:
|
||||
hostname: ${DOCKER_IP:192.168.99.100}
|
||||
leaseRenewalIntervalInSeconds: 5
|
||||
---
|
||||
spring:
|
||||
profiles: cloud
|
||||
cloud:
|
||||
stream:
|
||||
bindings:
|
||||
input:
|
||||
destination: account
|
||||
group: account-group
|
||||
contentType: 'application/json'
|
||||
consumer:
|
||||
durableSubscription: true
|
||||
amazon:
|
||||
aws:
|
||||
access-key-id: ${AMAZON_AWS_ACCESS_KEY_ID:replace}
|
||||
|
||||
68
docker-compose.yml
Normal file
68
docker-compose.yml
Normal file
@@ -0,0 +1,68 @@
|
||||
mysql:
|
||||
image: mysql:latest
|
||||
ports:
|
||||
- 3306:3306
|
||||
environment:
|
||||
- MYSQL_ROOT_PASSWORD=dbpass
|
||||
- MYSQL_DATABASE=dev]
|
||||
net: host
|
||||
rabbit:
|
||||
container_name: rabbit
|
||||
image: rabbitmq:3-management
|
||||
net: host
|
||||
account-web:
|
||||
image: account-web
|
||||
environment:
|
||||
- SPRING_PROFILES_ACTIVE=docker
|
||||
- DOCKER_IP=$DOCKER_IP
|
||||
net: host
|
||||
account-worker:
|
||||
image: account-worker
|
||||
environment:
|
||||
- SPRING_PROFILES_ACTIVE=docker
|
||||
- DOCKER_IP=$DOCKER_IP
|
||||
net: host
|
||||
order-web:
|
||||
image: order-web
|
||||
environment:
|
||||
- SPRING_PROFILES_ACTIVE=docker
|
||||
- DOCKER_IP=$DOCKER_IP
|
||||
net: host
|
||||
order-worker:
|
||||
image: order-worker
|
||||
environment:
|
||||
- SPRING_PROFILES_ACTIVE=docker
|
||||
- DOCKER_IP=$DOCKER_IP
|
||||
net: host
|
||||
payment-web:
|
||||
image: payment-web
|
||||
environment:
|
||||
- SPRING_PROFILES_ACTIVE=docker
|
||||
- DOCKER_IP=$DOCKER_IP
|
||||
net: host
|
||||
payment-worker:
|
||||
image: payment-worker
|
||||
environment:
|
||||
- SPRING_PROFILES_ACTIVE=docker
|
||||
- DOCKER_IP=$DOCKER_IP
|
||||
net: host
|
||||
warehouse-web:
|
||||
image: warehouse-web
|
||||
environment:
|
||||
- SPRING_PROFILES_ACTIVE=docker
|
||||
- DOCKER_IP=$DOCKER_IP
|
||||
net: host
|
||||
warehouse-worker:
|
||||
image: warehouse-worker
|
||||
environment:
|
||||
- SPRING_PROFILES_ACTIVE=docker
|
||||
- DOCKER_IP=$DOCKER_IP
|
||||
net: host
|
||||
discovery:
|
||||
image: discovery
|
||||
ports:
|
||||
- 8761:8761
|
||||
environment:
|
||||
- SPRING_PROFILES_ACTIVE=docker
|
||||
- DOCKER_IP=$DOCKER_IP
|
||||
net: host
|
||||
5
order/order-web/docker/Dockerfile
Normal file
5
order/order-web/docker/Dockerfile
Normal file
@@ -0,0 +1,5 @@
|
||||
FROM anapsix/alpine-java:8
|
||||
VOLUME /tmp
|
||||
ADD order-web-0.0.1-SNAPSHOT.jar app.jar
|
||||
RUN bash -c 'touch /app.jar'
|
||||
ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar"]
|
||||
@@ -74,6 +74,31 @@
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>com.spotify</groupId>
|
||||
<artifactId>docker-maven-plugin</artifactId>
|
||||
<version>0.4.13</version>
|
||||
<configuration>
|
||||
<imageName>${project.artifactId}</imageName>
|
||||
<dockerDirectory>${project.basedir}/docker</dockerDirectory>
|
||||
<resources>
|
||||
<resource>
|
||||
<targetPath>/</targetPath>
|
||||
<directory>${project.build.directory}</directory>
|
||||
<include>${project.build.finalName}.jar</include>
|
||||
</resource>
|
||||
</resources>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>build-image</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>build</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
|
||||
@@ -17,6 +17,9 @@ import java.util.List;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static demo.order.domain.OrderStatus.RESERVATION_FAILED;
|
||||
import static demo.order.domain.OrderStatus.RESERVATION_SUCCEEDED;
|
||||
|
||||
/**
|
||||
* Reserves inventory for an {@link Order}.
|
||||
*
|
||||
@@ -29,8 +32,13 @@ public class CompleteReservation extends Action<Order> {
|
||||
|
||||
public Function<Order, Order> getFunction() {
|
||||
return (order) -> {
|
||||
Assert.isTrue(order.getStatus() == OrderStatus.RESERVATION_PENDING,
|
||||
"The order must be in a reservation pending state");
|
||||
if (order.getStatus() != RESERVATION_SUCCEEDED && order.getStatus() != RESERVATION_FAILED) {
|
||||
Assert.isTrue(order.getStatus() == OrderStatus.RESERVATION_PENDING,
|
||||
"The order must be in a reservation pending state");
|
||||
} else {
|
||||
// Reservation has already completed
|
||||
return order;
|
||||
}
|
||||
|
||||
OrderService orderService = order.getModule(OrderModule.class).getDefaultService();
|
||||
|
||||
@@ -50,12 +58,12 @@ public class CompleteReservation extends Action<Order> {
|
||||
|
||||
if (orderReserved && order.getStatus() == OrderStatus.RESERVATION_PENDING) {
|
||||
// Succeed the reservation and commit all inventory associated with order
|
||||
order.setStatus(OrderStatus.RESERVATION_SUCCEEDED);
|
||||
order.setStatus(RESERVATION_SUCCEEDED);
|
||||
order = orderService.update(order);
|
||||
order.sendAsyncEvent(new OrderEvent(OrderEventType.RESERVATION_SUCCEEDED, order));
|
||||
} else if (reservationFailed && order.getStatus() == OrderStatus.RESERVATION_PENDING) {
|
||||
// Fail the reservation and release all inventory associated with order
|
||||
order.setStatus(OrderStatus.RESERVATION_FAILED);
|
||||
order.setStatus(RESERVATION_FAILED);
|
||||
order = orderService.update(order);
|
||||
order.sendAsyncEvent(new OrderEvent(OrderEventType.RESERVATION_FAILED, order));
|
||||
}
|
||||
|
||||
@@ -1,48 +1,42 @@
|
||||
spring:
|
||||
profiles:
|
||||
active: development
|
||||
---
|
||||
spring:
|
||||
profiles: development
|
||||
cloud:
|
||||
stream:
|
||||
bindings:
|
||||
output:
|
||||
destination: order
|
||||
contentType: 'application/json'
|
||||
jackson:
|
||||
default-property-inclusion: non_null
|
||||
server:
|
||||
port: 0
|
||||
events:
|
||||
worker: http://order-worker/v1/events
|
||||
---
|
||||
spring:
|
||||
profiles: development
|
||||
---
|
||||
spring:
|
||||
profiles: docker
|
||||
rabbitmq:
|
||||
host: ${DOCKER_IP:192.168.99.100}
|
||||
port: 5672
|
||||
eureka:
|
||||
client:
|
||||
service-url:
|
||||
defaultZone: http://${DOCKER_IP:192.168.99.100}:8761/eureka
|
||||
registryFetchIntervalSeconds: 5
|
||||
instance:
|
||||
hostname: ${DOCKER_IP:192.168.99.100}
|
||||
leaseRenewalIntervalInSeconds: 5
|
||||
---
|
||||
spring:
|
||||
profiles: test
|
||||
cloud:
|
||||
stream:
|
||||
bindings:
|
||||
output:
|
||||
destination: order
|
||||
contentType: 'application/json'
|
||||
server:
|
||||
port: 0
|
||||
events:
|
||||
worker: http://order-worker/v1/events
|
||||
eureka:
|
||||
client:
|
||||
enabled: false
|
||||
---
|
||||
spring:
|
||||
profiles: cloud
|
||||
cloud:
|
||||
stream:
|
||||
bindings:
|
||||
output:
|
||||
destination: order
|
||||
contentType: 'application/json'
|
||||
events:
|
||||
worker: http://order-worker/v1/events
|
||||
eureka:
|
||||
instance:
|
||||
hostname: ${vcap.application.uris[0]:localhost}
|
||||
|
||||
5
order/order-worker/docker/Dockerfile
Normal file
5
order/order-worker/docker/Dockerfile
Normal file
@@ -0,0 +1,5 @@
|
||||
FROM anapsix/alpine-java:8
|
||||
VOLUME /tmp
|
||||
ADD order-worker-0.0.1-SNAPSHOT.jar app.jar
|
||||
RUN bash -c 'touch /app.jar'
|
||||
ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar"]
|
||||
@@ -92,6 +92,31 @@
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>com.spotify</groupId>
|
||||
<artifactId>docker-maven-plugin</artifactId>
|
||||
<version>0.4.13</version>
|
||||
<configuration>
|
||||
<imageName>${project.artifactId}</imageName>
|
||||
<dockerDirectory>${project.basedir}/docker</dockerDirectory>
|
||||
<resources>
|
||||
<resource>
|
||||
<targetPath>/</targetPath>
|
||||
<directory>${project.build.directory}</directory>
|
||||
<include>${project.build.finalName}.jar</include>
|
||||
</resource>
|
||||
</resources>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>build-image</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>build</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ import org.springframework.context.annotation.Profile;
|
||||
*/
|
||||
@EnableAutoConfiguration
|
||||
@EnableBinding(Sink.class)
|
||||
@Profile({"cloud", "development"})
|
||||
@Profile({"cloud", "development", "docker"})
|
||||
public class OrderEventProcessor {
|
||||
|
||||
private StateFactory stateFactory;
|
||||
|
||||
@@ -1,20 +1,15 @@
|
||||
spring:
|
||||
profiles:
|
||||
active: development
|
||||
---
|
||||
spring:
|
||||
profiles: development
|
||||
cloud:
|
||||
stream:
|
||||
bindings:
|
||||
input:
|
||||
contentType: 'application/json'
|
||||
destination: order
|
||||
group: order-group
|
||||
contentType: 'application/json'
|
||||
consumer:
|
||||
durableSubscription: true
|
||||
jackson:
|
||||
default-property-inclusion: non_null
|
||||
server:
|
||||
port: 0
|
||||
amazon:
|
||||
@@ -22,31 +17,35 @@ amazon:
|
||||
access-key-id: replace
|
||||
access-key-secret: replace
|
||||
---
|
||||
spring:
|
||||
profiles: development
|
||||
---
|
||||
spring:
|
||||
profiles: docker
|
||||
rabbitmq:
|
||||
host: ${DOCKER_IP:192.168.99.100}
|
||||
port: 5672
|
||||
eureka:
|
||||
client:
|
||||
service-url:
|
||||
defaultZone: http://${DOCKER_IP:192.168.99.100}:8761/eureka
|
||||
registryFetchIntervalSeconds: 5
|
||||
instance:
|
||||
hostname: ${DOCKER_IP:192.168.99.100}
|
||||
leaseRenewalIntervalInSeconds: 5
|
||||
---
|
||||
spring:
|
||||
profiles: test
|
||||
eureka:
|
||||
client:
|
||||
enabled: false
|
||||
server:
|
||||
port: 0
|
||||
---
|
||||
spring:
|
||||
profiles: cloud
|
||||
cloud:
|
||||
stream:
|
||||
bindings:
|
||||
input:
|
||||
destination: order
|
||||
group: order-group
|
||||
contentType: 'application/json'
|
||||
consumer:
|
||||
durableSubscription: true
|
||||
server:
|
||||
port: 0
|
||||
amazon:
|
||||
aws:
|
||||
access-key-id: replace
|
||||
access-key-secret: replace
|
||||
access-key-id: ${AMAZON_AWS_ACCESS_KEY_ID:replace}
|
||||
access-key-secret: ${AMAZON_AWS_ACCESS_KEY_SECRET:replace}
|
||||
eureka:
|
||||
instance:
|
||||
hostname: ${vcap.application.uris[0]:localhost}
|
||||
|
||||
5
payment/payment-web/docker/Dockerfile
Normal file
5
payment/payment-web/docker/Dockerfile
Normal file
@@ -0,0 +1,5 @@
|
||||
FROM anapsix/alpine-java:8
|
||||
VOLUME /tmp
|
||||
ADD payment-web-0.0.1-SNAPSHOT.jar app.jar
|
||||
RUN bash -c 'touch /app.jar'
|
||||
ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar"]
|
||||
@@ -73,6 +73,31 @@
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>com.spotify</groupId>
|
||||
<artifactId>docker-maven-plugin</artifactId>
|
||||
<version>0.4.13</version>
|
||||
<configuration>
|
||||
<imageName>${project.artifactId}</imageName>
|
||||
<dockerDirectory>${project.basedir}/docker</dockerDirectory>
|
||||
<resources>
|
||||
<resource>
|
||||
<targetPath>/</targetPath>
|
||||
<directory>${project.build.directory}</directory>
|
||||
<include>${project.build.finalName}.jar</include>
|
||||
</resource>
|
||||
</resources>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>build-image</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>build</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
|
||||
@@ -1,46 +1,42 @@
|
||||
spring:
|
||||
profiles:
|
||||
active: development
|
||||
cloud:
|
||||
stream:
|
||||
bindings:
|
||||
output:
|
||||
contentType: 'application/json'
|
||||
destination: payment
|
||||
server:
|
||||
port: 0
|
||||
events:
|
||||
worker: http://payment-worker/v1/events
|
||||
---
|
||||
spring:
|
||||
profiles: development
|
||||
cloud:
|
||||
stream:
|
||||
bindings:
|
||||
output:
|
||||
destination: payment
|
||||
contentType: 'application/json'
|
||||
server:
|
||||
port: 0
|
||||
events:
|
||||
worker: http://payment-worker/v1/events
|
||||
---
|
||||
spring:
|
||||
profiles: docker
|
||||
rabbitmq:
|
||||
host: ${DOCKER_IP:192.168.99.100}
|
||||
port: 5672
|
||||
eureka:
|
||||
client:
|
||||
service-url:
|
||||
defaultZone: http://${DOCKER_IP:192.168.99.100}:8761/eureka
|
||||
registryFetchIntervalSeconds: 5
|
||||
instance:
|
||||
hostname: ${DOCKER_IP:192.168.99.100}
|
||||
leaseRenewalIntervalInSeconds: 5
|
||||
---
|
||||
spring:
|
||||
profiles: test
|
||||
cloud:
|
||||
stream:
|
||||
bindings:
|
||||
output:
|
||||
destination: payment
|
||||
contentType: 'application/json'
|
||||
server:
|
||||
port: 0
|
||||
events:
|
||||
worker: http://payment-worker/v1/events
|
||||
eureka:
|
||||
client:
|
||||
enabled: false
|
||||
---
|
||||
spring:
|
||||
profiles: cloud
|
||||
cloud:
|
||||
stream:
|
||||
bindings:
|
||||
output:
|
||||
destination: payment
|
||||
contentType: 'application/json'
|
||||
events:
|
||||
worker: http://payment-worker/v1/events
|
||||
eureka:
|
||||
instance:
|
||||
hostname: ${vcap.application.uris[0]:localhost}
|
||||
|
||||
5
payment/payment-worker/docker/Dockerfile
Normal file
5
payment/payment-worker/docker/Dockerfile
Normal file
@@ -0,0 +1,5 @@
|
||||
FROM anapsix/alpine-java:8
|
||||
VOLUME /tmp
|
||||
ADD payment-worker-0.0.1-SNAPSHOT.jar app.jar
|
||||
RUN bash -c 'touch /app.jar'
|
||||
ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar"]
|
||||
@@ -92,6 +92,31 @@
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>com.spotify</groupId>
|
||||
<artifactId>docker-maven-plugin</artifactId>
|
||||
<version>0.4.13</version>
|
||||
<configuration>
|
||||
<imageName>${project.artifactId}</imageName>
|
||||
<dockerDirectory>${project.basedir}/docker</dockerDirectory>
|
||||
<resources>
|
||||
<resource>
|
||||
<targetPath>/</targetPath>
|
||||
<directory>${project.build.directory}</directory>
|
||||
<include>${project.build.finalName}.jar</include>
|
||||
</resource>
|
||||
</resources>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>build-image</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>build</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ import org.springframework.statemachine.StateMachine;
|
||||
*/
|
||||
@EnableAutoConfiguration
|
||||
@EnableBinding(Sink.class)
|
||||
@Profile({ "cloud", "development" })
|
||||
@Profile({ "cloud", "development", "docker" })
|
||||
public class PaymentEventStream {
|
||||
|
||||
private EventService eventService;
|
||||
|
||||
@@ -1,16 +1,13 @@
|
||||
spring:
|
||||
profiles:
|
||||
active: development
|
||||
---
|
||||
spring:
|
||||
profiles: development
|
||||
cloud:
|
||||
stream:
|
||||
bindings:
|
||||
input:
|
||||
contentType: 'application/json'
|
||||
destination: payment
|
||||
group: payment-group
|
||||
contentType: 'application/json'
|
||||
consumer:
|
||||
durableSubscription: true
|
||||
server:
|
||||
@@ -20,6 +17,23 @@ amazon:
|
||||
access-key-id: replace
|
||||
access-key-secret: replace
|
||||
---
|
||||
spring:
|
||||
profiles: development
|
||||
---
|
||||
spring:
|
||||
profiles: docker
|
||||
rabbitmq:
|
||||
host: ${DOCKER_IP:192.168.99.100}
|
||||
port: 5672
|
||||
eureka:
|
||||
client:
|
||||
service-url:
|
||||
defaultZone: http://${DOCKER_IP:192.168.99.100}:8761/eureka
|
||||
registryFetchIntervalSeconds: 5
|
||||
instance:
|
||||
hostname: ${DOCKER_IP:192.168.99.100}
|
||||
leaseRenewalIntervalInSeconds: 5
|
||||
---
|
||||
spring:
|
||||
profiles: test
|
||||
eureka:
|
||||
@@ -28,15 +42,6 @@ eureka:
|
||||
---
|
||||
spring:
|
||||
profiles: cloud
|
||||
cloud:
|
||||
stream:
|
||||
bindings:
|
||||
input:
|
||||
destination: payment
|
||||
group: payment-group
|
||||
contentType: 'application/json'
|
||||
consumer:
|
||||
durableSubscription: true
|
||||
eureka:
|
||||
instance:
|
||||
hostname: ${vcap.application.uris[0]:localhost}
|
||||
|
||||
5
platform-services/discovery/docker/Dockerfile
Normal file
5
platform-services/discovery/docker/Dockerfile
Normal file
@@ -0,0 +1,5 @@
|
||||
FROM anapsix/alpine-java:8
|
||||
VOLUME /tmp
|
||||
ADD discovery-1.0-SNAPSHOT.jar app.jar
|
||||
RUN bash -c 'touch /app.jar'
|
||||
ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar"]
|
||||
@@ -31,6 +31,31 @@
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>com.spotify</groupId>
|
||||
<artifactId>docker-maven-plugin</artifactId>
|
||||
<version>0.4.13</version>
|
||||
<configuration>
|
||||
<imageName>${project.artifactId}</imageName>
|
||||
<dockerDirectory>${project.basedir}/docker</dockerDirectory>
|
||||
<resources>
|
||||
<resource>
|
||||
<targetPath>/</targetPath>
|
||||
<directory>${project.build.directory}</directory>
|
||||
<include>${project.build.finalName}.jar</include>
|
||||
</resource>
|
||||
</resources>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>build-image</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>build</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
server.port=8761
|
||||
spring.application.name=discovery-service
|
||||
@@ -0,0 +1,11 @@
|
||||
server:
|
||||
port: ${PORT:8761}
|
||||
spring:
|
||||
application:
|
||||
name: discovery-service
|
||||
eureka:
|
||||
client:
|
||||
registerWithEureka: false
|
||||
fetchRegistry: false
|
||||
server:
|
||||
waitTimeInMsWhenSyncEmpty: 0
|
||||
5
warehouse/warehouse-web/docker/Dockerfile
Normal file
5
warehouse/warehouse-web/docker/Dockerfile
Normal file
@@ -0,0 +1,5 @@
|
||||
FROM anapsix/alpine-java:8
|
||||
VOLUME /tmp
|
||||
ADD warehouse-web-0.0.1-SNAPSHOT.jar app.jar
|
||||
RUN bash -c 'touch /app.jar'
|
||||
ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar"]
|
||||
@@ -74,6 +74,31 @@
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>com.spotify</groupId>
|
||||
<artifactId>docker-maven-plugin</artifactId>
|
||||
<version>0.4.13</version>
|
||||
<configuration>
|
||||
<imageName>${project.artifactId}</imageName>
|
||||
<dockerDirectory>${project.basedir}/docker</dockerDirectory>
|
||||
<resources>
|
||||
<resource>
|
||||
<targetPath>/</targetPath>
|
||||
<directory>${project.build.directory}</directory>
|
||||
<include>${project.build.finalName}.jar</include>
|
||||
</resource>
|
||||
</resources>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>build-image</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>build</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
package demo.inventory.action;
|
||||
|
||||
import demo.domain.Action;
|
||||
import demo.inventory.domain.Inventory;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.function.BiConsumer;
|
||||
|
||||
/**
|
||||
* Reserves inventory for an {@link Inventory}.
|
||||
*
|
||||
* @author Kenny Bastani
|
||||
*/
|
||||
@Service
|
||||
public class AddInventory extends Action<Inventory> {
|
||||
public BiConsumer<Inventory, Long> getConsumer() {
|
||||
return (inventory, warehouseId) -> {
|
||||
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -11,7 +11,7 @@ import org.springframework.stereotype.Service;
|
||||
import java.util.function.BiFunction;
|
||||
|
||||
/**
|
||||
* Reserves inventory for an {@link Inventory}.
|
||||
* Updates the status of a {@link Inventory} entity.
|
||||
*
|
||||
* @author Kenny Bastani
|
||||
*/
|
||||
|
||||
@@ -1,52 +1,48 @@
|
||||
spring:
|
||||
profiles:
|
||||
active: development
|
||||
---
|
||||
spring:
|
||||
profiles: development
|
||||
cloud:
|
||||
stream:
|
||||
bindings:
|
||||
warehouse:
|
||||
contentType: 'application/json'
|
||||
destination: warehouse
|
||||
contentType: 'application/json'
|
||||
reservation:
|
||||
contentType: 'application/json'
|
||||
destination: reservation
|
||||
contentType: 'application/json'
|
||||
inventory:
|
||||
destination: inventory
|
||||
contentType: 'application/json'
|
||||
destination: inventory
|
||||
server:
|
||||
port: 0
|
||||
events:
|
||||
worker: http://warehouse-worker/v1/events
|
||||
---
|
||||
spring:
|
||||
profiles: development
|
||||
---
|
||||
spring:
|
||||
profiles: docker
|
||||
rabbitmq:
|
||||
host: ${DOCKER_IP:192.168.99.100}
|
||||
port: 5672
|
||||
eureka:
|
||||
client:
|
||||
service-url:
|
||||
defaultZone: http://${DOCKER_IP:192.168.99.100}:8761/eureka
|
||||
registryFetchIntervalSeconds: 5
|
||||
instance:
|
||||
hostname: ${DOCKER_IP:192.168.99.100}
|
||||
leaseRenewalIntervalInSeconds: 5
|
||||
---
|
||||
spring:
|
||||
profiles: test
|
||||
cloud:
|
||||
stream:
|
||||
bindings:
|
||||
output:
|
||||
destination: warehouse
|
||||
contentType: 'application/json'
|
||||
server:
|
||||
port: 0
|
||||
events:
|
||||
worker: http://warehouse-worker/v1/events
|
||||
eureka:
|
||||
client:
|
||||
enabled: false
|
||||
---
|
||||
spring:
|
||||
profiles: cloud
|
||||
cloud:
|
||||
stream:
|
||||
bindings:
|
||||
output:
|
||||
destination: warehouse
|
||||
contentType: 'application/json'
|
||||
events:
|
||||
worker: http://warehouse-worker/v1/events
|
||||
eureka:
|
||||
instance:
|
||||
hostname: ${vcap.application.uris[0]:localhost}
|
||||
|
||||
5
warehouse/warehouse-worker/docker/Dockerfile
Normal file
5
warehouse/warehouse-worker/docker/Dockerfile
Normal file
@@ -0,0 +1,5 @@
|
||||
FROM anapsix/alpine-java:8
|
||||
VOLUME /tmp
|
||||
ADD warehouse-worker-0.0.1-SNAPSHOT.jar app.jar
|
||||
RUN bash -c 'touch /app.jar'
|
||||
ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar"]
|
||||
@@ -92,6 +92,31 @@
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>com.spotify</groupId>
|
||||
<artifactId>docker-maven-plugin</artifactId>
|
||||
<version>0.4.13</version>
|
||||
<configuration>
|
||||
<imageName>${project.artifactId}</imageName>
|
||||
<dockerDirectory>${project.basedir}/docker</dockerDirectory>
|
||||
<resources>
|
||||
<resource>
|
||||
<targetPath>/</targetPath>
|
||||
<directory>${project.build.directory}</directory>
|
||||
<include>${project.build.finalName}.jar</include>
|
||||
</resource>
|
||||
</resources>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>build-image</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>build</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ import org.springframework.context.annotation.Profile;
|
||||
*/
|
||||
@EnableAutoConfiguration
|
||||
@EnableBinding(InventoryEventSink.class)
|
||||
@Profile({"cloud", "development"})
|
||||
@Profile({"cloud", "development", "docker"})
|
||||
public class InventoryEventProcessor {
|
||||
|
||||
private InventoryStateFactory stateFactory;
|
||||
|
||||
@@ -26,6 +26,8 @@ import java.util.EnumSet;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import static demo.order.domain.OrderStatus.RESERVATION_PENDING;
|
||||
|
||||
/**
|
||||
* A configuration adapter for describing a {@link StateMachine} factory that maps actions to functional
|
||||
* expressions. Actions are executed during transitions between a source state and a target state.
|
||||
@@ -75,7 +77,7 @@ public class ReservationStateMachineConfig extends EnumStateMachineConfigurerAda
|
||||
*/
|
||||
private ReservationEvent applyEvent(StateContext<ReservationStatus, ReservationEventType> context,
|
||||
ReservationFunction
|
||||
reservationFunction) {
|
||||
reservationFunction) {
|
||||
ReservationEvent event = null;
|
||||
log.info(String.format("Replicate event: %s", context.getMessage().getPayload()));
|
||||
|
||||
@@ -261,8 +263,14 @@ public class ReservationStateMachineConfig extends EnumStateMachineConfigurerAda
|
||||
MediaTypes.HAL_JSON
|
||||
);
|
||||
|
||||
traverson.follow("self", "order", "commands", "completeReservation")
|
||||
.toObject(Order.class);
|
||||
// Get the attached order
|
||||
Order order = traverson.follow("self", "order").toObject(Order.class);
|
||||
|
||||
// Complete the reservation if the status is still pending
|
||||
if (order.getStatus() == RESERVATION_PENDING) {
|
||||
traverson.follow("self", "order", "commands", "completeReservation")
|
||||
.toObject(Order.class);
|
||||
}
|
||||
|
||||
return traverson.follow("self")
|
||||
.toEntity(Reservation.class)
|
||||
|
||||
@@ -15,7 +15,7 @@ import org.springframework.context.annotation.Profile;
|
||||
*/
|
||||
@EnableAutoConfiguration
|
||||
@EnableBinding(ReservationEventSink.class)
|
||||
@Profile({"cloud", "development"})
|
||||
@Profile({"cloud", "development", "docker"})
|
||||
public class ReservationEventProcessor {
|
||||
|
||||
private ReservationStateFactory stateFactory;
|
||||
|
||||
@@ -15,7 +15,7 @@ import org.springframework.context.annotation.Profile;
|
||||
*/
|
||||
@EnableAutoConfiguration
|
||||
@EnableBinding(WarehouseEventSink.class)
|
||||
@Profile({"cloud", "development"})
|
||||
@Profile({"cloud", "development", "docker"})
|
||||
public class WarehouseEventProcessor {
|
||||
|
||||
private WarehouseStateFactory stateFactory;
|
||||
|
||||
@@ -5,41 +5,51 @@ spring:
|
||||
stream:
|
||||
bindings:
|
||||
warehouse:
|
||||
contentType: 'application/json'
|
||||
destination: warehouse
|
||||
group: warehouse-group
|
||||
contentType: 'application/json'
|
||||
consumer:
|
||||
durableSubscription: true
|
||||
reservation:
|
||||
contentType: 'application/json'
|
||||
destination: reservation
|
||||
group: reservation-group
|
||||
contentType: 'application/json'
|
||||
consumer:
|
||||
durableSubscription: true
|
||||
inventory:
|
||||
contentType: 'application/json'
|
||||
destination: inventory
|
||||
group: inventory-group
|
||||
contentType: 'application/json'
|
||||
consumer:
|
||||
durableSubscription: true
|
||||
server:
|
||||
port: 0
|
||||
---
|
||||
spring:
|
||||
profiles: development
|
||||
server:
|
||||
port: 0
|
||||
---
|
||||
spring:
|
||||
profiles: docker
|
||||
rabbitmq:
|
||||
host: ${DOCKER_IP:192.168.99.100}
|
||||
port: 5672
|
||||
eureka:
|
||||
client:
|
||||
service-url:
|
||||
defaultZone: http://${DOCKER_IP:192.168.99.100}:8761/eureka
|
||||
registryFetchIntervalSeconds: 5
|
||||
instance:
|
||||
hostname: ${DOCKER_IP:192.168.99.100}
|
||||
leaseRenewalIntervalInSeconds: 5
|
||||
---
|
||||
spring:
|
||||
profiles: test
|
||||
eureka:
|
||||
client:
|
||||
enabled: false
|
||||
server:
|
||||
port: 0
|
||||
---
|
||||
spring:
|
||||
profiles: cloud
|
||||
server:
|
||||
port: 0
|
||||
eureka:
|
||||
instance:
|
||||
hostname: ${vcap.application.uris[0]:localhost}
|
||||
|
||||
Reference in New Issue
Block a user