Skip to content

Question : taking advantage of docker caching while building MySqlContainter. #1713

@bhchandra

Description

@bhchandra

Issue:
I am having a little difficulty in figuring out how to take advantage of docker-caching to improve the speed of using test-containers.

Here is my simple use-case. When executing a test which uses MySQLContainer provided by TestContainers:

  1. The container boots up and executes the init script init_mysql.sql every time for setting up database schema. This step can be cached.
MySQLContainer mySQLContainer = new MySQLContainer()
                .withDatabaseName("test_database")
                .withInitScript("mysql-container/init_mysql.sql")
                .withUsername("test")
                .withPassword("test")
                .start();
  1. After the init script is executed and the container is ready, a java.sql.connection is created to the database and some of the tables are populated with data. This step can also be cached, by somehow included it during the creation of docker image.

All of this takes more ~1m30sec to 2m for the container to be ready for testing.

Question:
How can above code/process be restructured so that it can advantage of docker-caching feature to enable faster testing time ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions