Coder Social home page Coder Social logo

gradle-require-docker-plugin's Introduction

Gradle RequireDocker plugin

Build Status codecov GitHub Release Gradle Plugins Release license Semantic Release

I am looking for help to develop this plugin. I have a lot of ideas, but I don't have enough time to implement them all. If you are interested, feel free to open an issue or a discussion to talk about it. Also, I will be happy to add you to the list of contributors. Thank you!

Integrate docker containers into your workflow. Require Docker containers to be running before executing a Gradle task and shutdown after.

With this plugin, you can require a Postgres container to be running before executing a Flyway migration and a JOOQ code generation or integration tests tasks. Plugin also maintains containers lifecycle, so you don't need to worry about stopping and removing containers after.

plugins {
    id("io.github.meiblorn.require-docker") version "x.y.z"
}

requireDocker {
    val jooq by requireDocker.specs.creating {
        val postgres by contaienrs.creating {
            image("postgres:latest")
            portBindings("5432:5432")
            envVars(
                "POSTGRES_PASSWORD" to "postgres",
                "POSTGRES_USER" to "postgres",
                "POSTGRES_DB" to "postgres",
            )
        }
    }
}

// Create Flyway migrations task
// This task creates schema and tables in the database
val jooqFlywayMigrate by tasks.creating {
    url = "jdbc:postgresql://localhost:5432/postgres"
    user = "postgres"
    password = "postgres"
}

val generateJooq by tasks.getting {
    // Declare a dependency on the jooqFlywayMigrate task
    // NOTE: JOOQ requires the database schema 
    //       to be created before generating the code
    dependsOn(jooqFlywayMigrate)
}

// Enforce containers to be running before 
// executing jooqFlywayMigrate and generateJooq tasks
requireDocker.spec("jooq") {
    requiredBy(jooqFlywayMigrate)
    requiredBy(generateJooq)
}

TODO:

  • Publish plugin to Gradle Plugin Portal
  • Add test coverage
  • Add GitHub Actions workflow
  • Add badges to README.md
  • Add more samples
  • Clean up code
    • Move Kotlin extensions to separate Gradle source set
    • Build internal task graph and then process it in a single place instead of iterating specs and containers in nested loops
    • Utilise dependency injection features of Gradle to simplify code
  • Cover with unit tests
  • Cover with integration tests
    • Check Docker client
    • Check Bmuschko's Gradle plugin conflicts
    • Check Spring Boot Gradle plugin conflicts
    • Check Micronaut Gradle plugin conflicts
  • Add java docs
  • Add docs (preferably using docusaurus)

License

RequireDocker plugin is licensed under the MIT License. See LICENSE for more information.

Project heavily relies on Bmuschko's Docker plugin.

Inspired by Avast's Docker Compose plugin and Monosoul's JOOQ plugin.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.