Skip to content

How to create Docker Images of test suites

dstenger edited this page May 29, 2019 · 18 revisions

Create Dockerfile

Create Dockerfile for target test suite and push it to src/docker/Dockerfile.

FROM tomcat:7.0-jre8

# add TEAM Engine webapp
ADD maven/dependency/teamengine-web-*.war /root/
RUN cd /root/ && unzip -q teamengine-web-*.war -d /usr/local/tomcat/webapps/teamengine

# add TEAM Engine common libs
ADD maven/dependency/teamengine-web-*-common-libs.zip /root/
RUN cd /root/ && unzip -q teamengine-web-*-common-libs.zip -d /usr/local/tomcat/lib

# add TEAM Engine console
ADD maven/dependency/teamengine-console-*-base.zip /root/
RUN cd /root/ && unzip -q teamengine-console-*-base.zip -d /root/te_base

# set TE_BASE
ENV JAVA_OPTS="-Xms1024m -Xmx2048m -DTE_BASE=/root/te_base"

# add ETS
ADD maven/[TEST_SUITE_ID]-*-ctl.zip /root/
RUN cd /root/ && unzip -q [TEST_SUITE_ID]-*-ctl.zip -d /root/te_base/scripts
ADD maven/[TEST_SUITE_ID]-*-deps.zip /root/
RUN cd /root/ && unzip -q -o [TEST_SUITE_ID]-*-deps.zip -d /usr/local/tomcat/webapps/teamengine/WEB-INF/lib

# run tomcat
CMD ["catalina.sh", "run"]

Caution: All place holders ([...]) must be replaced.

Update Maven configuration

Add following to pom.xml.

...
  <properties>
    <docker.teamengine.version>[TEAMENGINE_VERSION]</docker.teamengine.version>
  </properties>
...
  <build>
    <pluginManagement>
      <plugins>
        <plugin>
          <groupId>io.fabric8</groupId>
          <artifactId>docker-maven-plugin</artifactId>
          <version>0.28.0</version>
          <configuration>
            <images>
              <image>
                <name>ogccite/${project.artifactId}</name>
                <build>
                  <dockerFileDir>${project.basedir}/src/docker</dockerFileDir>
                  <tags>
                    <tag>${project.version}-teamengine-${docker.teamengine.version}</tag>
                  </tags>
                  <assembly>
                    <inline>
                      <fileSets>
                        <fileSet>
                          <directory>${project.build.directory}</directory>
                          <outputDirectory>.</outputDirectory>
                          <includes>
                            <include>dependency/*teamengine-*.war</include>
                            <include>dependency/*teamengine-*.zip</include>
                            <include>*ets-*.zip</include>
                          </includes>
                        </fileSet>
                      </fileSets>
                    </inline>
                  </assembly>
                </build>
                <run>
                  <ports>
                    <port>8081:8080</port>
                  </ports>
                  <wait>
                    <http>
                      <url>http://localhost:8081/teamengine</url>
                    </http>
                    <time>120000</time>
                  </wait>
                </run>
              </image>
            </images>
          </configuration>
        </plugin>
        <plugin>
          <artifactId>maven-dependency-plugin</artifactId>
          <version>3.0.0</version>
          <configuration>
            <artifactItems>
              <artifactItem>
                <groupId>org.opengis.cite.teamengine</groupId>
                <artifactId>teamengine-web</artifactId>
                <version>${docker.teamengine.version}</version>
                <type>war</type>
              </artifactItem>
              <artifactItem>
                <groupId>org.opengis.cite.teamengine</groupId>
                <artifactId>teamengine-web</artifactId>
                <version>${docker.teamengine.version}</version>
                <classifier>common-libs</classifier>
                <type>zip</type>
              </artifactItem>
              <artifactItem>
                <groupId>org.opengis.cite.teamengine</groupId>
                <artifactId>teamengine-console</artifactId>
                <version>${docker.teamengine.version}</version>
                <classifier>base</classifier>
                <type>zip</type>
              </artifactItem>
            </artifactItems>
          </configuration>
        </plugin>
      </plugins>
    </pluginManagement>
  </build>
...
  <profiles>
    <profile>
      <id>docker</id>
      <build>
        <plugins>
          <plugin>
            <groupId>io.fabric8</groupId>
            <artifactId>docker-maven-plugin</artifactId>
            <executions>
              <execution>
                <id>build</id>
                <goals>
                  <goal>build</goal>
                </goals>
              </execution>
              <execution>
                <id>push</id>
                <goals>
                  <goal>push</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <artifactId>maven-dependency-plugin</artifactId>
            <executions>
              <execution>
                <goals>
                  <goal>copy</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>
...

Caution: All place holders ([...]) must be replaced.

Create Docker Image and create and start Docker Container

Requirements

  • Maven, Java and Git must be installed.
  • Docker must be installed and must be executable by user running the build.
  • Target test suite must be cloned.

Build Docker Image

Command (executed in main directory of target test suite):

mvn clean install -Pdocker

Result: Docker Image with Name ogccite/[TEST_SUITE_ID] is created.

Build Docker Image and create and start Docker Container

Command (executed in main directory of target test suite):

mvn clean install docker:run -Pdocker

Result: Test suite can be accessed via http://localhost:8081/teamengine.

You can’t perform that action at this time.