I'm working on converting my project's use of Flyway from a gradle task using the Flyway plugin to a gradle task using docker-compose. Currently we have a seperate Ignite compose file that starts the Ignite database, and we are using this task to run the Flyway migrations. I think I've run into an issue where Flyway refuses to recognize the ignite-core file I've copied into the docker container, and I'm at an impasse about how to proceed. I'm still pretty new to Docker and Flyway, so any help would be appreciated!
I am receiving a "org.flyway.core.api.FLywayException: Unable to instantiate JDBC driver: /flyway/drivers/ignite-core-2.9.1.jar", which seems to boil down to a ClassNotFoundException for that file. However, just before the error occurs Flyway claims it is adding /flyway/drivers/ignite-core-2.9.1.core to the classpath.
Flyway Claiming it Added ignite-core to the Classpath
From my understanding, if it is truly finding this file and adding it to the class path my JDBC driver should work. Ignite documentation says "To start using the driver, just add "the file" to your application's classpath."
Things I've tried:
- Manually specifying the driver using -driver in the docker-compose command for flyway (That's what depicted here).
- Manually specifying the classpath using the -CP option in the docker-compose command.
- Using a slightly updated ignite version: ignite-core-2.11.1.jar
- updating the URL to use localhost instead of 127.0.0.1, as well tried the docker container's name
- Adding the core file to the /flyway/jars/ directory.
- Updating permissions of the core file to 777
Some debugging I've done:
- Having the Dockerfile list out all files in that directory. Confirmed the core file is there.
- Confirmed both ignite-core-2.9.1 and ignite-core-2.11.1 have the JDBC thin client.
Here's the gradle commands:
task migrateIgnite(type:Exec){
group = 'Database'
description = 'Migrate Ignite'
environment "IGNITE_CONFIG_HOST_PATH", "${project.buildDir}/docker/config/ignite"
environment "IGNITE_TCP_DISCOVERY_ADDRESS", getIgniteDiscoveryAddrresses()
environment "DB_URL", "jdbc:ignite:thin//127.0.0.1:10800..10809/"
environment "DB_USER", "USER"
environment "DB_PASSWORD", "PASSWORD"
executable = 'docker-compose'
workingDir = "$projectDir/build/docker"
args = ['-f', "$projectDir/build/docker/docker-compose-flyway.yml", 'run', 'dbname']
}
task buildDBMigrations(type: Exec) {
group = 'Database'
description = 'Compile database files via Flyway.'
environment "DB_URL", "jdbc:ignite:thin//127.0.0.1:10800..10809/"
environment "DB_USER", "USER"
environment "DB_PASSWORD", "PASSWORD"
// Build the flyway migrations
executable = 'docker-compose'
workingDir = "$projectDir/build/docker"
args = ['-f', "$projectDir/build/docker/docker-compose-flyway.yml", 'build', 'dbname']
}
The Docker Compose File: (foo-bared a bit at request of management)
Version: '3.4'
services:
dbname:
image: the-ignite-image
command: -X -user=${DB_USER} -password=${DB_PASSWORD} -url=${DB_URL} -driver=/flyway/drivers/ignite-core-2.9.1.jar migrate
build:
context: ~/database/flywaydb
dockerfile: ~/database/flywaydb/Dockerfile
args:
docker_repo: ${DOCKER_REPO}
db_type: ignite
environment:
FLYWAY_LOCATIONS: filesystem:/software/migrations/dbname/
CONFIG_URI: /opt/ignite/apache-ignite/config/ignite-config.xml
IGNITE_TCP_DISCOVERY_ADDRESSES: ${ACME_IGNITE_TCP_DISCOVERY_ADDRESSES:-127.0.0.1}
JVM_OPTS: -Djava.net.preferIPv4Stack=true
volumes:
- ${IGNITE_CONFIG_HOST_PATH}:/opt/ignite/apache-ignite/config
hostname: the-ignite-image
container_name: the-ignite-image
networks:
project_network:
external: true
default:
external:
name: project_network
The Dockerfile (slimmed down a bit for readability)
ARG docker_repo
FROM ${docker_repo}/flyway:6.4.2
ENV FLYWAYDB_HOME "/flyway"
ARG db_type
WORKDIR /software
USER root
# Grab the Ignite JDBC CLient
ADD --chown=flyway:flyway ignite-dependencies/ /flyway/drivers/
RUN ls /flyway/drivers/
#Conf files
ADD --chown=flyway:flyway conf/ /software/conf
#Common-DB Files
ADD --chown=flyway:flyway common-migrations/dbname /software/migrations/dbname
# Database specific files
ADD --chown=flyway:flyway ${db_type}-migrations/dbname /software/migrations/dbname
#Scripts
ADD --chown=flyway:flyway populateDatabase.sh /software/
USER flyway
The Core file starts its life in ignite-dependencies/ before being copied into /flyway/drivers/ in when I build. I run the build command followed by the migrate command.
Anyone have any insight as to why Flyway can't find the core file?