Giter VIP home page Giter VIP logo

docker-maven-comparison's Introduction

Using Docker from Maven and Maven from Docker

Docker plus Maven

Codefresh status: Codefresh build status

This repository holds the code mentioned in the Codefresh blog post "Using Docker from Maven and Maven from Docker"

It consists of 4 individual projects mentioned in the article

  1. A Java project that uses the Maven spotify plugin
  2. A Java project that uses the Fabric8 Maven plugin (also runs integration tests)
  3. A Java project with a Multi-stage dockerfile that runs Maven from within Docker
  4. The same multi-stage Java projects with a YAML build file for Codefresh

Instructions for each project

Maven Spotify plugin

To build the project

cd 01-using-spotify-plugin
mvn package

This command will create a Docker image

Maven Fabric8 plugin

To build the project and run integration tests

cd 02-using-fabric8-plugin
mvn verify

This command will

  1. compile and the code create a Docker image
  2. launch the docker image and run integration tests against it

Multi-stage build

To build the project and run unit tests

cd 03-multistage
docker build -t my-java-app .

This command will

  1. Download a Maven docker image and use it to compile the code and run unit tests
  2. Keep the WAR file produced it will place it in a Tomcat Docker image

Multi-stage build (with Codefresh)

Create a Codefresh account and use the provided build yaml file.

version: '1.0'
steps:
  build_image:
    type: build
    description: Building the image...
    image_name: docker-maven-comparison
    working_directory: ./04-codefresh
    tag: develop
  build_image_with_tests:
    type: build
    description: Building the Test image...
    image_name: maven-integration-tests
    working_directory: ./04-codefresh
    dockerfile: Dockerfile.testing
  integration_tests:
    type: composition
    title: Launching QA environment
    description: Temporary test environment
    working_directory: ${{main_clone}}
    composition:
      version: '2'
      services:
        app:
          image: ${{build_image}}
          ports:
           - 8080
    composition_candidates:
      test_service: 
        image: ${{build_image_with_tests}}
        links:
          - app
        command: bash -c '/usr/bin/wait-for-it.sh -t 20 app:8080 -- mvn verify -Dserver.host=app'

Once build this Codefresh YAML will

  1. Create a multi-stage Docker image with the war file (based on Tomcat) also running unit tests
  2. Create a Maven image that holds the integration tests
  3. Launch the tomcat image and run the integration tests against it (using wait-for-it.sh as well)

docker-maven-comparison's People

Contributors

kostis-codefresh avatar

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.