Skip to content

Commit

Permalink
Update the MySQL version to 8.4.1 (#275)
Browse files Browse the repository at this point in the history
  • Loading branch information
wikumChamith authored Jul 21, 2024
1 parent f269dd3 commit e6fe616
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@

abstract class AbstractDockerMojo extends AbstractMojo {

protected static final String DEFAULT_MYSQL_CONTAINER = "openmrs-sdk-mysql-v3-2";
protected static final String DEFAULT_MYSQL_CONTAINER = "openmrs-sdk-mysql-v8-4-1";
protected static final String DEFAULT_MYSQL_EXPOSED_PORT = "3308";
protected static final String DEFAULT_MYSQL_PASSWORD = "Admin123";
protected static final String MYSQL_5_6 = "mysql:5.6";
protected static final String MYSQL_8_4_1 = "mysql:8.4.1";
protected static final String DEFAULT_MYSQL_DB_URI = "jdbc:mysql://localhost:" + DEFAULT_MYSQL_EXPOSED_PORT + "/";
private static final Logger logger = LoggerFactory.getLogger(AbstractDockerMojo.class);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public void executeTask() throws MojoExecutionException {
}

private boolean noMySqlImage(DockerClient docker) {
List<Image> mysql = docker.listImagesCmd().withImageNameFilter(MYSQL_5_6).exec();
List<Image> mysql = docker.listImagesCmd().withImageNameFilter(MYSQL_8_4_1).exec();
return mysql.size() == 0;
}

Expand All @@ -81,7 +81,7 @@ private void createMysqlContainer(DockerClient docker) {
.withPortBindings(portBinding)
.withBinds(boundVolume);

docker.createContainerCmd(MYSQL_5_6)
docker.createContainerCmd(MYSQL_8_4_1)
.withHostConfig(hostConfig)
.withName(container)
.withEnv("MYSQL_ROOT_PASSWORD="+rootPassword)
Expand All @@ -93,11 +93,11 @@ private void createMysqlContainer(DockerClient docker) {
private void pullMySqlImage(DockerClient docker) throws MojoExecutionException {
final CountDownLatch latch = new CountDownLatch(1);
docker.pullImageCmd("mysql")
.withTag("5.6")
.withTag("8.4.1")
.exec(new ResultCallback<PullResponseItem>() {
@Override
public void onStart(Closeable closeable) {
showMessage("Started downloading mysql:5.6 image ...");
showMessage("Started downloading mysql:8.4.1 image ...");
}

@Override
Expand All @@ -107,7 +107,7 @@ public void onNext(PullResponseItem object) {

@Override
public void onError(Throwable throwable) {

showMessage("Error downloading mysql:8.4.1 image : " + throwable.getMessage());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,15 @@ public class DBConnector implements AutoCloseable {

public DBConnector(String url, String user, String pass, String dbName) throws SQLException {
DriverManager.setLoginTimeout(60);
this.connection = DriverManager.getConnection(url, user, pass);
/*
* Connection attempts to a database in a newly created Docker container might fail on the first try due to the container not being fully ready
* This is to mitigate such errors.
*/
try {
this.connection = DriverManager.getConnection(url, user, pass);
} catch (SQLException e) {
this.connection = DriverManager.getConnection(url, user, pass);
}
this.dbName = dbName;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public class DefaultWizard implements Wizard {

public static final String DB_OPTION_MYSQL = "MySQL 5.6 and above (requires pre-installed MySQL 5.6 and above)";

public static final String DB_OPTION_SDK_DOCKER_MYSQL = "MySQL 5.6 and above in SDK docker container (requires pre-installed Docker)";
public static final String DB_OPTION_SDK_DOCKER_MYSQL = "MySQL 8.4.1 and above in SDK docker container (requires pre-installed Docker)";

public static final String DB_OPTION_DOCKER_MYSQL = "Existing docker container (requires pre-installed Docker)";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

public class DockerHelper {

public static final String DOCKER_DEFAULT_CONTAINER_ID = "openmrs-sdk-mysql-v3-2";
public static final String DOCKER_DEFAULT_CONTAINER_ID = "openmrs-sdk-mysql-v8-4-1";
public static final String DOCKER_MYSQL_PORT = "3308";
public static final String DOCKER_MYSQL_USERNAME = "root";
public static final String DOCKER_MYSQL_PASSWORD = "Admin123";
Expand Down

0 comments on commit e6fe616

Please sign in to comment.