Skip to content

Commit

Permalink
Merge pull request #451 from ian4h/add-mysql-driver
Browse files Browse the repository at this point in the history
Add mysql support by bundling the mysql driver
  • Loading branch information
saig0 authored Oct 13, 2022
2 parents e2cc5b2 + 69bc7ca commit dd6301d
Show file tree
Hide file tree
Showing 5 changed files with 104 additions and 0 deletions.
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 @@ -140,6 +140,11 @@
<artifactId>postgresql</artifactId>
</dependency>

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

<!-- js libs -->

<dependency>
Expand Down Expand Up @@ -201,6 +206,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

0 comments on commit dd6301d

Please sign in to comment.