Skip to content
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

feat: Bundle a MySQL driver #451

Merged
merged 3 commits into from
Oct 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,21 @@ For example, using PostgreSQL:

See the [docker-compose file](docker/docker-compose.yml) (profile: `postgres`) for a sample configuration with PostgreSQL.

The configuration for using MySql is similar but with an additional setting for the Hibernate naming strategy:

```
- spring.datasource.url=jdbc:mysql://db:3306/simple_monitor
- spring.datasource.username=root
- spring.datasource.password=zeebe
- spring.datasource.driverClassName=com.mysql.cj.jdbc.Driver
- spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL8Dialect
- spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl
```

* the MySql database driver is already bundled

See the [docker-compose file](docker/docker-compose.yml) (profile: `mysql`) for a sample configuration with MySql.

## Code of Conduct

This project adheres to the Contributor Covenant [Code of
Expand Down
36 changes: 36 additions & 0 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,42 @@ services:
profiles:
- postgres

simple-monitor-mysql:
container_name: zeebe-simple-monitor-mysql
image: ghcr.io/camunda-community-hub/zeebe-simple-monitor:2.4.1
environment:
- zeebe.client.broker.gateway-address=zeebe:26500
- zeebe.client.worker.hazelcast.connection=zeebe:5701
- spring.datasource.url=jdbc:mysql://mysql-zeebe-simple-monitor:3306/simple_monitor?createDatabaseIfNotExist=true
- spring.datasource.username=root
- spring.datasource.password=zeebe
- spring.datasource.driverClassName=com.mysql.cj.jdbc.Driver
- spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL8Dialect
- spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl
ports:
- "8082:8082"
depends_on:
- zeebe
- mysql-zeebe-simple-monitor
networks:
- zeebe_network
profiles:
- mysql

mysql-zeebe-simple-monitor:
image: mysql:8
restart: always
environment:
MYSQL_ROOT_PASSWORD: zeebe
volumes:
- mysql-zeebe-simple-monitor-data:/var/lib/mysql
networks:
- zeebe_network
profiles:
- mysql

volumes:
postgres-zeebe-simple-monitor-data:
driver: local
mysql-zeebe-simple-monitor-data:
driver: local
12 changes: 12 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,11 @@
<artifactId>postgresql</artifactId>
</dependency>

<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>

<!-- js libs -->

<dependency>
Expand Down Expand Up @@ -206,6 +211,13 @@
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>mysql</artifactId>
<version>1.17.3</version>
<scope>test</scope>
</dependency>

<!-- hot swapping, live reload -->
<dependency>
<groupId>org.springframework.boot</groupId>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package io.zeebe.monitor.repository;

import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.support.AnnotationConfigContextLoader;
import org.springframework.transaction.annotation.Transactional;

import static org.assertj.core.api.Assertions.assertThat;

@SpringBootTest
@ContextConfiguration(
classes = {TestContextJpaConfiguration.class},
loader = AnnotationConfigContextLoader.class)
@Transactional
@ActiveProfiles({"mysql-docker", "application-junittest.yaml"})
public class ZeebeApplicationMysqlTest {

@Autowired
private VariableRepository variableRepository;

@Test
void setup_of_mysql_should_work() {
assertThat(variableRepository).isNotNull();
}
}
13 changes: 13 additions & 0 deletions src/test/resources/application-mysql-docker.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
spring:
datasource:
url: jdbc:tc:mysql:latest:///test
username: test
password: test
jpa:
properties:
hibernate:
dialect: org.hibernate.dialect.MySQL8Dialect
naming:
physical-strategy: org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl
hibernate:
ddl-auto: create