Change project to run spring-boot locally and kafka,zoo and mongo in docker-compose
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -1,2 +1,4 @@
|
||||
/.idea
|
||||
/zk-single-kafka-single
|
||||
/data0
|
||||
/data1
|
||||
21
Dockerfile
21
Dockerfile
@@ -1,21 +0,0 @@
|
||||
FROM maven:3.6.3-openjdk-8-slim AS build
|
||||
COPY demo-command/src /usr/src/demo-cqrs/demo-command/src
|
||||
COPY demo-command/pom.xml /usr/src/demo-cqrs/demo-command
|
||||
COPY demo-query/src /usr/src/demo-cqrs/demo-query/src
|
||||
COPY demo-query/pom.xml /usr/src/demo-cqrs/demo-query
|
||||
COPY pom.xml /usr/src/demo-cqrs
|
||||
RUN mvn -f /usr/src/demo-cqrs/pom.xml clean package
|
||||
|
||||
FROM openjdk:8-alpine AS demo-command
|
||||
RUN addgroup -S spring && adduser -S spring -G spring
|
||||
USER spring:spring
|
||||
COPY --from=build /usr/src/demo-cqrs/demo-command/target/demo-command-0.0.1-SNAPSHOT.jar /usr/app/demo-command-0.0.1-SNAPSHOT.jar
|
||||
EXPOSE 8081
|
||||
ENTRYPOINT ["java","-jar","/usr/app/demo-command-0.0.1-SNAPSHOT.jar"]
|
||||
|
||||
FROM openjdk:8-alpine AS demo-query
|
||||
RUN addgroup -S spring && adduser -S spring -G spring
|
||||
USER spring:spring
|
||||
COPY --from=build /usr/src/demo-cqrs/demo-query/target/demo-query-0.0.1-SNAPSHOT.jar /usr/app/demo-query-0.0.1-SNAPSHOT.jar
|
||||
EXPOSE 8082
|
||||
ENTRYPOINT ["java","-jar","/usr/app/demo-query-0.0.1-SNAPSHOT.jar"]
|
||||
2
data0/WiredTiger
Normal file
2
data0/WiredTiger
Normal file
@@ -0,0 +1,2 @@
|
||||
WiredTiger
|
||||
WiredTiger 10.0.0: (March 18, 2020)
|
||||
1
data0/WiredTiger.lock
Normal file
1
data0/WiredTiger.lock
Normal file
@@ -0,0 +1 @@
|
||||
WiredTiger lock file
|
||||
6
data0/WiredTiger.turtle
Normal file
6
data0/WiredTiger.turtle
Normal file
@@ -0,0 +1,6 @@
|
||||
WiredTiger version string
|
||||
WiredTiger 10.0.0: (March 18, 2020)
|
||||
WiredTiger version
|
||||
major=10,minor=0,patch=0
|
||||
file:WiredTiger.wt
|
||||
access_pattern_hint=none,allocation_size=4KB,app_metadata=,assert=(commit_timestamp=none,durable_timestamp=none,read_timestamp=none),block_allocation=best,block_compressor=,cache_resident=false,checksum=uncompressed,collator=,columns=,dictionary=0,encryption=(keyid=,name=),format=btree,huffman_value=,id=0,ignore_in_memory_cache_size=false,internal_item_max=0,internal_key_max=0,internal_key_truncate=true,internal_page_max=4KB,key_format=S,key_gap=10,leaf_item_max=0,leaf_key_max=0,leaf_page_max=32KB,leaf_value_max=0,log=(enabled=true),memory_page_image_max=0,memory_page_max=5MB,os_cache_dirty_max=0,os_cache_max=0,prefix_compression=false,prefix_compression_min=4,split_deepen_min_child=0,split_deepen_per_child=0,split_pct=90,value_format=S,version=(major=1,minor=1),checkpoint=(WiredTigerCheckpoint.45=(addr="018381e4539bcb7f8481e41f4fdcd18581e4d2e42e9a808080e3010fc0e23fc0",order=45,time=1612453682,size=28672,newest_start_durable_ts=0,oldest_start_ts=0,newest_txn=23,newest_stop_durable_ts=0,newest_stop_ts=-1,newest_stop_txn=-11,prepare=0,write_gen=120,run_write_gen=98)),checkpoint_backup_info=,checkpoint_lsn=(8,19072)
|
||||
BIN
data0/WiredTiger.wt
Normal file
BIN
data0/WiredTiger.wt
Normal file
Binary file not shown.
BIN
data0/WiredTigerHS.wt
Normal file
BIN
data0/WiredTigerHS.wt
Normal file
Binary file not shown.
BIN
data0/_mdb_catalog.wt
Normal file
BIN
data0/_mdb_catalog.wt
Normal file
Binary file not shown.
BIN
data0/collection-0--4349258851694291604.wt
Normal file
BIN
data0/collection-0--4349258851694291604.wt
Normal file
Binary file not shown.
BIN
data0/collection-10--4349258851694291604.wt
Normal file
BIN
data0/collection-10--4349258851694291604.wt
Normal file
Binary file not shown.
BIN
data0/collection-2--4349258851694291604.wt
Normal file
BIN
data0/collection-2--4349258851694291604.wt
Normal file
Binary file not shown.
BIN
data0/collection-4--4349258851694291604.wt
Normal file
BIN
data0/collection-4--4349258851694291604.wt
Normal file
Binary file not shown.
BIN
data0/collection-7--4349258851694291604.wt
Normal file
BIN
data0/collection-7--4349258851694291604.wt
Normal file
Binary file not shown.
BIN
data0/diagnostic.data/metrics.2021-02-04T15-04-45Z-00000
Normal file
BIN
data0/diagnostic.data/metrics.2021-02-04T15-04-45Z-00000
Normal file
Binary file not shown.
BIN
data0/diagnostic.data/metrics.2021-02-04T15-11-15Z-00000
Normal file
BIN
data0/diagnostic.data/metrics.2021-02-04T15-11-15Z-00000
Normal file
Binary file not shown.
BIN
data0/diagnostic.data/metrics.2021-02-04T15-18-33Z-00000
Normal file
BIN
data0/diagnostic.data/metrics.2021-02-04T15-18-33Z-00000
Normal file
Binary file not shown.
BIN
data0/diagnostic.data/metrics.2021-02-04T15-22-05Z-00000
Normal file
BIN
data0/diagnostic.data/metrics.2021-02-04T15-22-05Z-00000
Normal file
Binary file not shown.
BIN
data0/diagnostic.data/metrics.2021-02-04T15-28-16Z-00000
Normal file
BIN
data0/diagnostic.data/metrics.2021-02-04T15-28-16Z-00000
Normal file
Binary file not shown.
BIN
data0/diagnostic.data/metrics.2021-02-04T15-33-02Z-00000
Normal file
BIN
data0/diagnostic.data/metrics.2021-02-04T15-33-02Z-00000
Normal file
Binary file not shown.
BIN
data0/diagnostic.data/metrics.interim
Normal file
BIN
data0/diagnostic.data/metrics.interim
Normal file
Binary file not shown.
BIN
data0/index-1--4349258851694291604.wt
Normal file
BIN
data0/index-1--4349258851694291604.wt
Normal file
Binary file not shown.
BIN
data0/index-11--4349258851694291604.wt
Normal file
BIN
data0/index-11--4349258851694291604.wt
Normal file
Binary file not shown.
BIN
data0/index-3--4349258851694291604.wt
Normal file
BIN
data0/index-3--4349258851694291604.wt
Normal file
Binary file not shown.
BIN
data0/index-5--4349258851694291604.wt
Normal file
BIN
data0/index-5--4349258851694291604.wt
Normal file
Binary file not shown.
BIN
data0/index-6--4349258851694291604.wt
Normal file
BIN
data0/index-6--4349258851694291604.wt
Normal file
Binary file not shown.
BIN
data0/index-8--4349258851694291604.wt
Normal file
BIN
data0/index-8--4349258851694291604.wt
Normal file
Binary file not shown.
BIN
data0/index-9--4349258851694291604.wt
Normal file
BIN
data0/index-9--4349258851694291604.wt
Normal file
Binary file not shown.
BIN
data0/journal/WiredTigerPreplog.0000000001
Normal file
BIN
data0/journal/WiredTigerPreplog.0000000001
Normal file
Binary file not shown.
BIN
data0/sizeStorer.wt
Normal file
BIN
data0/sizeStorer.wt
Normal file
Binary file not shown.
BIN
data0/storage.bson
Normal file
BIN
data0/storage.bson
Normal file
Binary file not shown.
2
data1/WiredTiger
Normal file
2
data1/WiredTiger
Normal file
@@ -0,0 +1,2 @@
|
||||
WiredTiger
|
||||
WiredTiger 10.0.0: (March 18, 2020)
|
||||
1
data1/WiredTiger.lock
Normal file
1
data1/WiredTiger.lock
Normal file
@@ -0,0 +1 @@
|
||||
WiredTiger lock file
|
||||
6
data1/WiredTiger.turtle
Normal file
6
data1/WiredTiger.turtle
Normal file
@@ -0,0 +1,6 @@
|
||||
WiredTiger version string
|
||||
WiredTiger 10.0.0: (March 18, 2020)
|
||||
WiredTiger version
|
||||
major=10,minor=0,patch=0
|
||||
file:WiredTiger.wt
|
||||
access_pattern_hint=none,allocation_size=4KB,app_metadata=,assert=(commit_timestamp=none,durable_timestamp=none,read_timestamp=none),block_allocation=best,block_compressor=,cache_resident=false,checksum=uncompressed,collator=,columns=,dictionary=0,encryption=(keyid=,name=),format=btree,huffman_value=,id=0,ignore_in_memory_cache_size=false,internal_item_max=0,internal_key_max=0,internal_key_truncate=true,internal_page_max=4KB,key_format=S,key_gap=10,leaf_item_max=0,leaf_key_max=0,leaf_page_max=32KB,leaf_value_max=0,log=(enabled=true),memory_page_image_max=0,memory_page_max=5MB,os_cache_dirty_max=0,os_cache_max=0,prefix_compression=false,prefix_compression_min=4,split_deepen_min_child=0,split_deepen_per_child=0,split_pct=90,value_format=S,version=(major=1,minor=1),checkpoint=(WiredTigerCheckpoint.45=(addr="018381e4b7f568b08481e41f4fdcd18581e48de68736808080e3010fc0e23fc0",order=45,time=1612453684,size=28672,newest_start_durable_ts=0,oldest_start_ts=0,newest_txn=21,newest_stop_durable_ts=0,newest_stop_ts=-1,newest_stop_txn=-11,prepare=0,write_gen=120,run_write_gen=98)),checkpoint_backup_info=,checkpoint_lsn=(8,17920)
|
||||
BIN
data1/WiredTiger.wt
Normal file
BIN
data1/WiredTiger.wt
Normal file
Binary file not shown.
BIN
data1/WiredTigerHS.wt
Normal file
BIN
data1/WiredTigerHS.wt
Normal file
Binary file not shown.
BIN
data1/_mdb_catalog.wt
Normal file
BIN
data1/_mdb_catalog.wt
Normal file
Binary file not shown.
BIN
data1/collection-0-2005600236197793345.wt
Normal file
BIN
data1/collection-0-2005600236197793345.wt
Normal file
Binary file not shown.
BIN
data1/collection-10-2005600236197793345.wt
Normal file
BIN
data1/collection-10-2005600236197793345.wt
Normal file
Binary file not shown.
BIN
data1/collection-2-2005600236197793345.wt
Normal file
BIN
data1/collection-2-2005600236197793345.wt
Normal file
Binary file not shown.
BIN
data1/collection-4-2005600236197793345.wt
Normal file
BIN
data1/collection-4-2005600236197793345.wt
Normal file
Binary file not shown.
BIN
data1/collection-7-2005600236197793345.wt
Normal file
BIN
data1/collection-7-2005600236197793345.wt
Normal file
Binary file not shown.
BIN
data1/diagnostic.data/metrics.2021-02-04T15-04-45Z-00000
Normal file
BIN
data1/diagnostic.data/metrics.2021-02-04T15-04-45Z-00000
Normal file
Binary file not shown.
BIN
data1/diagnostic.data/metrics.2021-02-04T15-11-16Z-00000
Normal file
BIN
data1/diagnostic.data/metrics.2021-02-04T15-11-16Z-00000
Normal file
Binary file not shown.
BIN
data1/diagnostic.data/metrics.2021-02-04T15-18-33Z-00000
Normal file
BIN
data1/diagnostic.data/metrics.2021-02-04T15-18-33Z-00000
Normal file
Binary file not shown.
BIN
data1/diagnostic.data/metrics.2021-02-04T15-22-05Z-00000
Normal file
BIN
data1/diagnostic.data/metrics.2021-02-04T15-22-05Z-00000
Normal file
Binary file not shown.
BIN
data1/diagnostic.data/metrics.2021-02-04T15-28-16Z-00000
Normal file
BIN
data1/diagnostic.data/metrics.2021-02-04T15-28-16Z-00000
Normal file
Binary file not shown.
BIN
data1/diagnostic.data/metrics.2021-02-04T15-33-02Z-00000
Normal file
BIN
data1/diagnostic.data/metrics.2021-02-04T15-33-02Z-00000
Normal file
Binary file not shown.
BIN
data1/diagnostic.data/metrics.interim
Normal file
BIN
data1/diagnostic.data/metrics.interim
Normal file
Binary file not shown.
BIN
data1/index-1-2005600236197793345.wt
Normal file
BIN
data1/index-1-2005600236197793345.wt
Normal file
Binary file not shown.
BIN
data1/index-11-2005600236197793345.wt
Normal file
BIN
data1/index-11-2005600236197793345.wt
Normal file
Binary file not shown.
BIN
data1/index-3-2005600236197793345.wt
Normal file
BIN
data1/index-3-2005600236197793345.wt
Normal file
Binary file not shown.
BIN
data1/index-5-2005600236197793345.wt
Normal file
BIN
data1/index-5-2005600236197793345.wt
Normal file
Binary file not shown.
BIN
data1/index-6-2005600236197793345.wt
Normal file
BIN
data1/index-6-2005600236197793345.wt
Normal file
Binary file not shown.
BIN
data1/index-8-2005600236197793345.wt
Normal file
BIN
data1/index-8-2005600236197793345.wt
Normal file
Binary file not shown.
BIN
data1/index-9-2005600236197793345.wt
Normal file
BIN
data1/index-9-2005600236197793345.wt
Normal file
Binary file not shown.
BIN
data1/sizeStorer.wt
Normal file
BIN
data1/sizeStorer.wt
Normal file
Binary file not shown.
BIN
data1/storage.bson
Normal file
BIN
data1/storage.bson
Normal file
Binary file not shown.
@@ -3,6 +3,13 @@
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.data</groupId>
|
||||
<artifactId>spring-data-mongodb</artifactId>
|
||||
<version>3.1.2</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<parent>
|
||||
<groupId>es.dbiosag</groupId>
|
||||
|
||||
@@ -1,27 +1,20 @@
|
||||
package es.dbiosag.command.domain.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import javax.persistence.*;
|
||||
import org.springframework.data.annotation.Id;
|
||||
|
||||
@Data
|
||||
@Entity
|
||||
@Table(name = "PHONES")
|
||||
@Builder
|
||||
public class Phone {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy= GenerationType.AUTO)
|
||||
@Column(name = "ID_PHONE")
|
||||
private Integer id;
|
||||
@Column(name = "NAME")
|
||||
@JsonIgnore
|
||||
private String id;
|
||||
private String name;
|
||||
@Column(name = "MODEL")
|
||||
private String model;
|
||||
@Column(name = "COLOR")
|
||||
private String color;
|
||||
@Column(name = "PRICE")
|
||||
private Double price;
|
||||
@Column(name = "CREATION_DATE")
|
||||
private String creationDate;
|
||||
}
|
||||
|
||||
@@ -11,8 +11,6 @@ import lombok.val;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.transaction.Transactional;
|
||||
|
||||
@Service
|
||||
@Log4j2
|
||||
public class CreateUserService {
|
||||
@@ -24,7 +22,6 @@ public class CreateUserService {
|
||||
@Autowired
|
||||
private KafkaPhoneCreatedEventSourcing kafkaPhoneCreatedEventSourcing;
|
||||
|
||||
@Transactional
|
||||
public PhoneCreatedEvent create(CreatePhoneRequest request) {
|
||||
log.info("Creating new phone");
|
||||
val phone = phoneConverter.createPhoneRequestRequestToPhone(request);
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package es.dbiosag.command.infrasturcture.repository;
|
||||
|
||||
import es.dbiosag.command.domain.model.Phone;
|
||||
import org.springframework.data.repository.CrudRepository;
|
||||
import org.springframework.data.mongodb.repository.MongoRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public interface PhoneRepository extends CrudRepository<Phone, Integer> {
|
||||
public interface PhoneRepository extends MongoRepository<Phone, Integer> {
|
||||
}
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
DROP TABLE IF EXISTS phones;
|
||||
|
||||
CREATE TABLE phones (
|
||||
id_phone INT AUTO_INCREMENT PRIMARY KEY,
|
||||
creation_date VARCHAR(250) NOT NULL,
|
||||
name VARCHAR(250) NOT NULL,
|
||||
model VARCHAR(250) NOT NULL,
|
||||
price VARCHAR(250) NOT NULL,
|
||||
color VARCHAR(250) NOT NULL
|
||||
);
|
||||
@@ -1,19 +1,16 @@
|
||||
server:
|
||||
port: 8081
|
||||
spring:
|
||||
datasource:
|
||||
driverClassName: org.h2.Driver
|
||||
password: 1234
|
||||
url: jdbc:h2:mem:commanddb
|
||||
username: sa
|
||||
jpa:
|
||||
database-platform: org.hibernate.dialect.H2Dialect
|
||||
h2:
|
||||
console:
|
||||
enabled: true
|
||||
|
||||
data:
|
||||
mongodb:
|
||||
authentication-database: examples
|
||||
database: examples
|
||||
username: api_user
|
||||
password: NdEep0XLpMNKUmgQVa81oDCx7mrSRodh0Z79qdX3
|
||||
host: localhost
|
||||
port: 30000
|
||||
kafka:
|
||||
bootstrap-servers: kafka1:9092
|
||||
bootstrap-servers: localhost:29092
|
||||
consumer:
|
||||
group-id: test-consumer-group
|
||||
message:
|
||||
|
||||
@@ -1,27 +1,19 @@
|
||||
package es.dbiosag.query.domain.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.persistence.*;
|
||||
import org.springframework.data.annotation.Id;
|
||||
|
||||
@Data
|
||||
@Entity
|
||||
@Table(name = "PHONES")
|
||||
public class Phone {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy= GenerationType.AUTO)
|
||||
@Column(name = "ID_PHONE")
|
||||
private Integer id;
|
||||
@Column(name = "NAME")
|
||||
@JsonIgnore
|
||||
private String id;
|
||||
private String name;
|
||||
@Column(name = "MODEL")
|
||||
private String model;
|
||||
@Column(name = "COLOR")
|
||||
private String color;
|
||||
@Column(name = "PRICE")
|
||||
private Double price;
|
||||
@Column(name = "CREATION_DATE")
|
||||
private String creationDate;
|
||||
|
||||
public Phone(){ }
|
||||
|
||||
@@ -9,8 +9,6 @@ import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
@Service
|
||||
@Log4j2
|
||||
public class FindPhoneService {
|
||||
@@ -21,12 +19,9 @@ public class FindPhoneService {
|
||||
private PhoneConverter phoneConverter;
|
||||
|
||||
public PhoneResponse findByName(String name) throws PhoneNotFoundException {
|
||||
Optional<Phone> phone = phoneRepository.findByName(name);
|
||||
if(!phone.isPresent()) {
|
||||
throw new PhoneNotFoundException(name, "Phone not found");
|
||||
}
|
||||
Phone phone = phoneRepository.findByName(name).orElseThrow(() -> new PhoneNotFoundException(name, "Phone not found"));
|
||||
log.info("Find phone: {}", phone);
|
||||
return phoneConverter.phoneToPhoneResponse(phone.get());
|
||||
return phoneConverter.phoneToPhoneResponse(phone);
|
||||
}
|
||||
|
||||
public void createPhone(Phone p) {
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
package es.dbiosag.query.infrastructure.repository;
|
||||
|
||||
import es.dbiosag.query.domain.model.Phone;
|
||||
import org.springframework.data.repository.CrudRepository;
|
||||
import org.springframework.data.mongodb.repository.MongoRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
|
||||
@Repository
|
||||
public interface PhoneRepository extends CrudRepository<Phone, Integer> {
|
||||
public interface PhoneRepository extends MongoRepository<Phone, Integer> {
|
||||
|
||||
Optional<Phone> findByName(String name);
|
||||
}
|
||||
|
||||
@@ -1,19 +1,16 @@
|
||||
server:
|
||||
port: 8082
|
||||
spring:
|
||||
datasource:
|
||||
driverClassName: org.h2.Driver
|
||||
password: 1234
|
||||
url: jdbc:h2:mem:querydb
|
||||
username: sa
|
||||
jpa:
|
||||
database-platform: org.hibernate.dialect.H2Dialect
|
||||
h2:
|
||||
console:
|
||||
enabled: true
|
||||
|
||||
data:
|
||||
mongodb:
|
||||
authentication-database: examples
|
||||
database: examples
|
||||
username: api_user
|
||||
password: NdEep0XLpMNKUmgQVa81oDCx7mrSRodh0Z79qdX3
|
||||
host: localhost
|
||||
port: 30001
|
||||
kafka:
|
||||
bootstrap-servers: kafka1:9092
|
||||
bootstrap-servers: localhost:29092
|
||||
consumer:
|
||||
group-id: test-consumer-group
|
||||
message:
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
DROP TABLE IF EXISTS phones;
|
||||
|
||||
CREATE TABLE phones (
|
||||
id_phone INT AUTO_INCREMENT PRIMARY KEY,
|
||||
creation_date VARCHAR(250) NOT NULL,
|
||||
name VARCHAR(250) NOT NULL,
|
||||
model VARCHAR(250) NOT NULL,
|
||||
price VARCHAR(250) NOT NULL,
|
||||
color VARCHAR(250) NOT NULL
|
||||
);
|
||||
@@ -7,7 +7,7 @@ services:
|
||||
ports:
|
||||
- "2181:2181"
|
||||
networks:
|
||||
- kafka_net
|
||||
- my_network
|
||||
environment:
|
||||
ZOO_MY_ID: 1
|
||||
ZOO_PORT: 2181
|
||||
@@ -16,6 +16,40 @@ services:
|
||||
- ./zk-single-kafka-single/zoo1/data:/data
|
||||
- ./zk-single-kafka-single/zoo1/datalog:/datalog
|
||||
|
||||
mongo-command:
|
||||
image: mongo:latest
|
||||
container_name: mongo-command
|
||||
hostname: mongo-command
|
||||
environment:
|
||||
MONGO_INITDB_ROOT_USERNAME: root
|
||||
MONGO_INITDB_ROOT_PASSWORD: secret
|
||||
MONGO_INITDB_DATABASE: examples
|
||||
command: ["--bind_ip_all"]
|
||||
ports:
|
||||
- "30000:27017"
|
||||
networks:
|
||||
- my_network
|
||||
volumes:
|
||||
- ./init-mongo.js:/docker-entrypoint-initdb.d/mongo-init.js:ro
|
||||
- ./data0:/data/db
|
||||
|
||||
mongo-query:
|
||||
image: mongo:latest
|
||||
container_name: mongo-query
|
||||
hostname: mongo-query
|
||||
environment:
|
||||
MONGO_INITDB_ROOT_USERNAME: root
|
||||
MONGO_INITDB_ROOT_PASSWORD: secret
|
||||
MONGO_INITDB_DATABASE: examples
|
||||
command: ["--bind_ip_all"]
|
||||
ports:
|
||||
- "30001:27017"
|
||||
networks:
|
||||
- my_network
|
||||
volumes:
|
||||
- ./init-mongo.js:/docker-entrypoint-initdb.d/mongo-init.js:ro
|
||||
- ./data1:/data/db
|
||||
|
||||
kafka1:
|
||||
image: confluentinc/cp-kafka:5.5.1
|
||||
hostname: kafka1
|
||||
@@ -36,55 +70,13 @@ services:
|
||||
depends_on:
|
||||
- zoo1
|
||||
networks:
|
||||
- kafka_net
|
||||
- my_network
|
||||
healthcheck:
|
||||
test: [ "CMD", "nc", "-vz", "localhost", "9092" ]
|
||||
interval: 30s
|
||||
timeout: 10s
|
||||
retries: 3
|
||||
|
||||
demo-command:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
image: demo-command
|
||||
hostname: demo-command
|
||||
ports:
|
||||
- "8081:8081"
|
||||
depends_on:
|
||||
kafka1:
|
||||
condition: service_healthy
|
||||
networks:
|
||||
- kafka_net
|
||||
|
||||
demo-query-1:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
image: demo-query
|
||||
hostname: demo-query-1
|
||||
ports:
|
||||
- "8082:8082"
|
||||
depends_on:
|
||||
kafka1:
|
||||
condition: service_healthy
|
||||
networks:
|
||||
- kafka_net
|
||||
|
||||
# demo-query-2:
|
||||
# build:
|
||||
# context: demo-query
|
||||
# dockerfile: Dockerfile
|
||||
# image: demo-query
|
||||
# hostname: demo-query-2
|
||||
# ports:
|
||||
# - "8083:8082"
|
||||
# depends_on:
|
||||
# kafka1:
|
||||
# condition: service_healthy
|
||||
# networks:
|
||||
# - kafka_net
|
||||
|
||||
networks:
|
||||
kafka_net:
|
||||
my_network:
|
||||
driver: bridge
|
||||
|
||||
8
init-mongo.js
Normal file
8
init-mongo.js
Normal file
@@ -0,0 +1,8 @@
|
||||
db.createCollection('examples');
|
||||
db.createUser(
|
||||
{
|
||||
user: 'api_user',
|
||||
pwd: 'NdEep0XLpMNKUmgQVa81oDCx7mrSRodh0Z79qdX3',
|
||||
roles: [{ role: 'readWrite', db: 'examples' }],
|
||||
},
|
||||
);
|
||||
Reference in New Issue
Block a user