Skip to content

Commit 61f1086

Browse files
committed
chore: add all servers to docker
1 parent d4f712f commit 61f1086

File tree

9 files changed

+59
-85
lines changed

9 files changed

+59
-85
lines changed

Makefile

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,19 @@ build:
77
@./gradlew build --warning-mode all
88

99
lint:
10-
@docker exec codelytv-ddd_example-java ./gradlew spotlessCheck
10+
@docker exec codely-ddd_example-java ./gradlew spotlessCheck
1111

1212
run-tests:
1313
@./gradlew test --warning-mode all
1414

1515
test:
16-
@docker exec codelytv-ddd_example-java ./gradlew test --warning-mode all
16+
@docker exec codely-ddd_example-java ./gradlew test --warning-mode all
1717

1818
run:
1919
@./gradlew :run
2020

2121
ping-mysql:
22-
@docker exec codelytv-java_ddd_example-mysql mysqladmin --user=root --password= --host "127.0.0.1" ping --silent
22+
@docker exec codely-java_ddd_example-mysql mysqladmin --user=root --password= --host "127.0.0.1" ping --silent
2323

2424
# Start the app
2525
start-mooc_backend:

apps/main/resources/.env

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,34 @@
11
# MOOC #
22
#--------------------------------#
3-
MOOC_BACKEND_SERVER_PORT=8081
3+
MOOC_BACKEND_SERVER_PORT=8030
44
# MySql
5-
MOOC_DATABASE_HOST=codelytv-java_ddd_example-mysql
5+
MOOC_DATABASE_HOST=codely-java_ddd_example-mysql
66
MOOC_DATABASE_PORT=3306
77
MOOC_DATABASE_NAME=mooc
88
MOOC_DATABASE_USER=root
99
MOOC_DATABASE_PASSWORD=
1010

1111
# BACKOFFICE #
1212
#--------------------------------#
13-
BACKOFFICE_FRONTEND_SERVER_PORT=8090
14-
BACKOFFICE_BACKEND_SERVER_PORT=8091
13+
BACKOFFICE_BACKEND_SERVER_PORT=8040
14+
BACKOFFICE_FRONTEND_SERVER_PORT=8041
1515
# MySql
16-
BACKOFFICE_DATABASE_HOST=codelytv-java_ddd_example-mysql
16+
BACKOFFICE_DATABASE_HOST=codely-java_ddd_example-mysql
1717
BACKOFFICE_DATABASE_PORT=3306
1818
BACKOFFICE_DATABASE_NAME=backoffice
1919
BACKOFFICE_DATABASE_USER=root
2020
BACKOFFICE_DATABASE_PASSWORD=
2121
# Elasticsearch
22-
BACKOFFICE_ELASTICSEARCH_HOST=codelytv-java_ddd_example-elasticsearch
22+
BACKOFFICE_ELASTICSEARCH_HOST=codely-java_ddd_example-elasticsearch
2323
BACKOFFICE_ELASTICSEARCH_PORT=9200
2424
BACKOFFICE_ELASTICSEARCH_INDEX_PREFIX=backoffice
2525

2626
# COMMON #
2727
#--------------------------------#
2828
# RabbitMQ
29-
RABBITMQ_HOST=codelytv-java_ddd_example-rabbitmq
29+
RABBITMQ_HOST=codely-java_ddd_example-rabbitmq
3030
RABBITMQ_PORT=5672
31-
RABBITMQ_LOGIN=codelytv
31+
RABBITMQ_LOGIN=codely
3232
RABBITMQ_PASSWORD=c0d3ly
3333
RABBITMQ_EXCHANGE=domain_events
3434
RABBITMQ_MAX_RETRIES=5

docker-compose.yml

+12-25
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
version: '3'
22

33
services:
4-
mysql:
5-
container_name: codelytv-java_ddd_example-mysql
4+
shared_mysql:
5+
container_name: codely-java_ddd_example-mysql
66
image: mysql:8
77
platform: linux/amd64
88
ports:
@@ -17,20 +17,20 @@ services:
1717
"
1818
command: ["--default-authentication-plugin=mysql_native_password"]
1919

20-
rabbitmq:
21-
container_name: codelytv-java_ddd_example-rabbitmq
20+
shared_rabbitmq:
21+
container_name: codely-java_ddd_example-rabbitmq
2222
image: 'rabbitmq:3.7-management'
2323
platform: linux/amd64
2424
restart: unless-stopped
2525
ports:
2626
- "5630:5672"
2727
- "8090:15672"
2828
environment:
29-
- RABBITMQ_DEFAULT_USER=codelytv
29+
- RABBITMQ_DEFAULT_USER=codely
3030
- RABBITMQ_DEFAULT_PASS=c0d3ly
3131

32-
elasticsearch:
33-
container_name: codelytv-java_ddd_example-elasticsearch
32+
backoffice_elasticsearch:
33+
container_name: codely-java_ddd_example-elasticsearch
3434
image: 'elasticsearch:6.8.4'
3535
platform: linux/amd64
3636
restart: unless-stopped
@@ -39,21 +39,8 @@ services:
3939
- "9200:9200"
4040
environment:
4141
- discovery.type=single-node
42-
43-
java:
44-
container_name: codelytv-ddd_example-java
45-
build:
46-
context: .
47-
dockerfile: Dockerfile
48-
restart: unless-stopped
49-
platform: linux/amd64
50-
ports:
51-
- "8030:8080"
52-
volumes:
53-
- .:/app:delegated
54-
env_file:
55-
- .env
56-
tty: true
57-
depends_on:
58-
- mysql
59-
- rabbitmq
42+
healthcheck:
43+
test: [ "CMD-SHELL", "curl --silent --fail localhost:9200/_cluster/health || exit 1" ]
44+
interval: 30s
45+
timeout: 10s
46+
retries: 5

src/mooc/main/resources/database/mooc.sql

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ CREATE TABLE IF NOT EXISTS courses_counter (
1717
ENGINE = InnoDB
1818
DEFAULT CHARSET = utf8mb4
1919
COLLATE = utf8mb4_unicode_ci;
20+
INSERT IGNORE INTO courses_counter (id, total, existing_courses) VALUES ('efbaff16-8fcd-4689-9fc9-ec545d641c46', 0, '[]');
2021

2122
CREATE TABLE IF NOT EXISTS steps (
2223
id CHAR(36) NOT NULL,

src/mooc/main/tv/codely/mooc/courses_counter/infrastructure/persistence/hibernate/CoursesCounter.hbm.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
</component>
1717

1818
<property name="existingCourses" column="existing_courses" access="field">
19-
<type name="json_string">
19+
<type name="tv.codely.shared.infrastructure.hibernate.JsonListType">
2020
<param name="list_of">tv.codely.mooc.courses.domain.CourseId</param>
2121
</type>
2222
</property>

src/mooc/main/tv/codely/mooc/courses_counter/infrastructure/persistence/hibernate/CustomTypes.hbm.xml

-8
This file was deleted.

src/shared/main/tv/codely/shared/infrastructure/bus/event/DomainEventSubscriberInformation.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,6 @@ public List<Class<? extends DomainEvent>> subscribedEvents() {
4444
}
4545

4646
public String formatRabbitMqQueueName() {
47-
return String.format("codelytv.%s.%s.%s", contextName(), moduleName(), Utils.toSnake(className()));
47+
return String.format("codely.%s.%s.%s", contextName(), moduleName(), Utils.toSnake(className()));
4848
}
4949
}

src/shared/main/tv/codely/shared/infrastructure/hibernate/HibernateConfigurationFactory.java

+11-5
Original file line numberDiff line numberDiff line change
@@ -110,13 +110,19 @@ private List<String> subdirectoriesFor(String contextName) {
110110
}
111111

112112
private String[] mappingFilesIn(String path) {
113-
String[] files = new File(path).list((current, name) -> new File(current, name).getName().contains(".hbm.xml"));
113+
List<String> fileList = new ArrayList<>();
114114

115-
if (null == files) {
116-
return new String[0];
117-
}
115+
String[] hbmFiles = new File(path).list((current, name) -> new File(current, name).getName().contains(".hbm.xml"));
116+
String[] ormFiles = new File(path).list((current, name) -> new File(current, name).getName().contains(".orm.xml"));
117+
118+
if (hbmFiles != null) {
119+
fileList.addAll(Arrays.asList(hbmFiles));
120+
}
121+
if (ormFiles != null) {
122+
fileList.addAll(Arrays.asList(ormFiles));
123+
}
118124

119-
return files;
125+
return fileList.toArray(new String[0]);
120126
}
121127

122128
private Properties hibernateProperties() {

src/shared/main/tv/codely/shared/infrastructure/hibernate/JsonListType.java

+22-34
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
import java.util.*;
2020

2121
public class JsonListType implements UserType, DynamicParameterizedType {
22-
private static final int[] SQL_TYPES = new int[]{Types.LONGVARCHAR};
2322
private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
2423
private JavaType valueType = null;
2524
private Class<?> classType = null;
@@ -44,24 +43,6 @@ public int hashCode(Object x) throws HibernateException {
4443
return Objects.hashCode(x);
4544
}
4645

47-
@Override
48-
public Object nullSafeGet(
49-
ResultSet resultSet,
50-
int i,
51-
SharedSessionContractImplementor sharedSessionContractImplementor,
52-
Object o
53-
) throws SQLException {
54-
try {
55-
String json = resultSet.getString(i);
56-
if (json == null) {
57-
return null;
58-
}
59-
return OBJECT_MAPPER.readValue(json, valueType);
60-
} catch (IOException e) {
61-
throw new SQLException("Exception deserializing JSON", e);
62-
}
63-
}
64-
6546
@Override
6647
public void nullSafeSet(
6748
PreparedStatement st,
@@ -72,21 +53,28 @@ public void nullSafeSet(
7253
nullSafeSet(st, value, index);
7354
}
7455

75-
public Object nullSafeGet(ResultSet rs, String[] names, Object owner) throws HibernateException, SQLException {
76-
String value = rs.getString(names[0]).replace("\"value\"", "").replace("{:", "").replace("}", "");
77-
Object result = null;
78-
if (valueType == null) {
79-
throw new HibernateException("Value type not set.");
80-
}
81-
if (value != null && !value.equals("")) {
82-
try {
83-
result = OBJECT_MAPPER.readValue(value, valueType);
84-
} catch (IOException e) {
85-
throw new HibernateException("Exception deserializing value " + value, e);
86-
}
87-
}
88-
return result;
89-
}
56+
@Override
57+
public Object nullSafeGet(
58+
ResultSet resultSet,
59+
int index,
60+
SharedSessionContractImplementor session,
61+
Object owner
62+
) throws HibernateException, SQLException {
63+
64+
String value = resultSet.getString(index).replace("\"value\"", "").replace("{:", "").replace("}", "");
65+
Object result = null;
66+
if (valueType == null) {
67+
throw new HibernateException("Value type not set.");
68+
}
69+
if (value != null && !value.equals("")) {
70+
try {
71+
result = OBJECT_MAPPER.readValue(value, valueType);
72+
} catch (IOException e) {
73+
throw new HibernateException("Exception deserializing value " + value, e);
74+
}
75+
}
76+
return result;
77+
}
9078

9179
public void nullSafeSet(PreparedStatement st, Object value, int index) throws HibernateException, SQLException {
9280
StringWriter sw = new StringWriter();

0 commit comments

Comments
 (0)