Don't fork me!

Travis CI status: Build Status

1. Introduction

This project contains example of docker-compose-maven-plugin usage

mvn
mvn docker-compose:up
mvn docker-compose:down

2. Implementation

docker-compose file is located is located in src/main/docker directory

plugion configuration
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <profiles>
    <profile>
      <id>docker</id>
      <build>
        <plugins>
          <plugin>
            <groupId>com.dkanejs.maven.plugins</groupId>
            <artifactId>docker-compose-maven-plugin</artifactId>
            <version>2.4.0</version>
            <executions>
              <execution>
                <id>up</id>
                <phase>pre-integration-test</phase>
                <!--<phase>test</phase>-->
                <goals>
                  <goal>up</goal>
                </goals>
              </execution>
              <execution>
                <id>down</id>
                <phase>post-integration-test</phase>
                <!--<phase>verify</phase>-->
                <goals>
                  <goal>down</goal>
                </goals>
              </execution>
            </executions>
            <configuration>
              <composeFiles>
                <composeFile>${project.basedir}/src/main/docker/docker-compose.yaml</composeFile>
                <!--<composeFile>${project.basedir}/src/main/docker/docker-compose-override.yaml</composeFile>-->
              </composeFiles>
              <detachedMode>true</detachedMode>
              <removeVolumes>true</removeVolumes>
              <removeOrphans>true</removeOrphans>
              <removeImages>true</removeImages>
              <removeImagesType>local</removeImagesType>
              <build>true</build>
              <detail>true</detail>
              <verbose>false</verbose>
              <projectName>my-cloud</projectName>
              <!--<apiVersion>1.22</apiVersion>-->
              <!--<apiVersion>1.39</apiVersion>-->
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>
</project>

3. Test usage

build fat jar
./mvnw package
run app in docker container
./mvnw docker-compose:up -P docker
wait and test
sleep 35
open http//:127.0.0.1:3000/
stop docker
./mvnw docker-compose:down -P docker

4. Build documentation

build documentation
./mvnw process-resources