All Projects → spotify → Dockerfile Maven

spotify / Dockerfile Maven

Licence: apache-2.0
MATURE: A set of Maven tools for dealing with Dockerfiles

Programming Languages

java
68154 projects - #9 most used programming language
groovy
2714 projects
Dockerfile
14818 projects

Projects that are alternatives of or similar to Dockerfile Maven

Simplenet
An easy-to-use, event-driven, asynchronous network application framework compiled with Java 11.
Stars: ✭ 164 (-93.6%)
Mutual labels:  maven
Myuploader Backend
单文件上传,多文件上传,大文件上传,断点续传,文件秒传,图片上传
Stars: ✭ 177 (-93.09%)
Mutual labels:  maven
Dhis2 Core
DHIS2 Core. Written in Java. Contains the service layer and Web API.
Stars: ✭ 199 (-92.23%)
Mutual labels:  maven
Rules jvm external
Bazel rules to resolve, fetch and export Maven artifacts
Stars: ✭ 167 (-93.48%)
Mutual labels:  maven
Maven Color
A colorized Maven console
Stars: ✭ 177 (-93.09%)
Mutual labels:  maven
Jhipster4 Demo
Blog demo app with JHipster 4
Stars: ✭ 180 (-92.97%)
Mutual labels:  maven
Shop
基于SpringMVC,Spring,Hibernate的网上商城。代码已久不维护...
Stars: ✭ 162 (-93.68%)
Mutual labels:  maven
Telegrambots
Java library to create bots using Telegram Bots API
Stars: ✭ 2,728 (+6.48%)
Mutual labels:  maven
Maven Git Versioning Extension
This extension will virtually set project versions, based on current git branch or tag.
Stars: ✭ 178 (-93.05%)
Mutual labels:  maven
Micromodule
Rebuild multiple complete module structures within the module.
Stars: ✭ 192 (-92.51%)
Mutual labels:  maven
Jitpack.io
Documentation and issues of https://jitpack.io
Stars: ✭ 2,156 (-15.85%)
Mutual labels:  maven
Ksprefs
🚀⚡ Kotlin SharedPreferences wrapper & cryptographic preferences android library.
Stars: ✭ 176 (-93.13%)
Mutual labels:  maven
Sortpom
Maven plugin that helps the user sort pom.xml.
Stars: ✭ 185 (-92.78%)
Mutual labels:  maven
My Blog
🌴A simple & beautiful blogging system implemented with spring-boot & thymeleaf & mybatis My Blog 是由 SpringBoot + Mybatis + Thymeleaf 等技术实现的 Java 博客系统,页面美观、功能齐全、部署简单及完善的代码,一定会给使用者无与伦比的体验
Stars: ✭ 2,400 (-6.32%)
Mutual labels:  maven
Versions Maven Plugin
Versions Maven Plugin
Stars: ✭ 199 (-92.23%)
Mutual labels:  maven
Gatling Maven Plugin Demo
Showcase of the Gatling Plugin for Maven
Stars: ✭ 162 (-93.68%)
Mutual labels:  maven
Seconds Kill
基于 Springboot + Redis + Kafka 的秒杀系统,乐观锁 + 缓存 + 限流 + 异步,TPS 从 500 优化到 3000
Stars: ✭ 180 (-92.97%)
Mutual labels:  maven
Jkube
Successor of the deprecated Fabric8 Maven Plugin
Stars: ✭ 213 (-91.69%)
Mutual labels:  maven
Appengine Maven Repository
Free Private Maven repositories hosted on Google App-Engine, backed by Google Cloud Storage and deployed in less than 5 minutes.
Stars: ✭ 201 (-92.15%)
Mutual labels:  maven
Formatter Maven Plugin
Formatter Maven Plugin
Stars: ✭ 187 (-92.7%)
Mutual labels:  maven

Dockerfile Maven

Build Status Maven Central License

Status: mature

At this point, we're not developing or accepting new features or even fixing non-critical bugs.

This Maven plugin integrates Maven with Docker.

The design goals are:

  • Don't do anything fancy. Dockerfiles are how you build Docker projects; that's what this plugin uses. They are mandatory.
  • Make the Docker build process integrate with the Maven build process. If you bind the default phases, when you type mvn package, you get a Docker image. When you type mvn deploy, your image gets pushed.
  • Make the goals remember what you are doing. You can type mvn dockerfile:build and later mvn dockerfile:tag and later mvn dockerfile:push without problems. This also eliminates the need for something like mvn dockerfile:build -DalsoPush; instead you can just say mvn dockerfile:build dockerfile:push.
  • Integrate with the Maven build reactor. You can depend on the Docker image of one project in another project, and Maven will build the projects in the correct order. This is useful when you want to run integration tests involving multiple services.

This project adheres to the Open Code of Conduct. By participating, you are expected to honor this code.

See the changelog for a list of releases

Set-up

This plugin requires Java 7 or later and Apache Maven 3 or later (dockerfile-maven-plugin <=1.4.6 needs Maven >= 3, and for other cases, Maven >= 3.5.2). To run the integration tests or to use the plugin in practice, a working Docker set-up is needed.

Example

For more examples, see the integration test directory.

In particular, the advanced test showcases a full service consisting of two micro-services that are integration tested using helios-testing.

This configures the actual plugin to build your image with mvn package and push it with mvn deploy. Of course you can also say mvn dockerfile:build explicitly.

<plugin>
  <groupId>com.spotify</groupId>
  <artifactId>dockerfile-maven-plugin</artifactId>
  <version>${dockerfile-maven-version}</version>
  <executions>
    <execution>
      <id>default</id>
      <goals>
        <goal>build</goal>
        <goal>push</goal>
      </goals>
    </execution>
  </executions>
  <configuration>
    <repository>spotify/foobar</repository>
    <tag>${project.version}</tag>
    <buildArgs>
      <JAR_FILE>${project.build.finalName}.jar</JAR_FILE>
    </buildArgs>
  </configuration>
</plugin>

A corresponding Dockerfile could look like:

FROM openjdk:8-jre
MAINTAINER David Flemström <[email protected]>

ENTRYPOINT ["/usr/bin/java", "-jar", "/usr/share/myservice/myservice.jar"]

# Add Maven dependencies (not shaded into the artifact; Docker-cached)
ADD target/lib           /usr/share/myservice/lib
# Add the service itself
ARG JAR_FILE
ADD target/${JAR_FILE} /usr/share/myservice/myservice.jar

Important note

The most Maven-ish way to reference the build artifact would probably be to use the project.build.directory variable for referencing the 'target'-directory. However, this results in an absolute path, which is not supported by the ADD command in the Dockerfile. Any such source must be inside the context of the Docker build and therefor must be referenced by a relative path. See https://github.com/spotify/dockerfile-maven/issues/101

Do not use ${project.build.directory} as a way to reference your build directory.

What does it give me?

There are many advantages to using this plugin for your builds.

Faster build times

This plugin lets you leverage Docker cache more consistently, vastly speeding up your builds by letting you cache Maven dependencies in your image. It also encourages avoiding the maven-shade-plugin, which also greatly speeds up builds.

Consistent build lifecycle

You no longer have to say something like:

mvn package
mvn dockerfile:build
mvn verify
mvn dockerfile:push
mvn deploy

Instead, it is simply enough to say:

mvn deploy

With the basic configuration, this will make sure that the image is built and pushed at the correct times.

Depend on Docker images of other services

You can depend on the Docker information of another project, because this plugin attaches project metadata when it builds Docker images. Simply add this information to any project:

<dependency>
  <groupId>com.spotify</groupId>
  <artifactId>foobar</artifactId>
  <version>1.0-SNAPSHOT</version>
  <type>docker-info</type>
</dependency>

Now, you can read information about the Docker image of the project that you depended on:

String imageName = getResource("META-INF/docker/com.spotify/foobar/image-name");

This is great for an integration test where you want the latest version of another project's Docker image.

Note that you have to register a Maven extension in your POM (or a parent POM) in order for the docker-info type to be supported:

<build>
  <extensions>
    <extension>
      <groupId>com.spotify</groupId>
      <artifactId>dockerfile-maven-extension</artifactId>
      <version>${version}</version>
    </extension>
  </extensions>
</build>

Use other Docker tools that rely on Dockerfiles

Your project(s) look like so:

a/
  Dockerfile
  pom.xml
b/
  Dockerfile
  pom.xml

You can now use these projects with Fig or docker-compose or some other system that works with Dockerfiles. For example, a docker-compose.yml might look like:

service-a:
  build: a/
  ports:
  - '80'

service-b:
  build: b/
  links:
  - service-a

Now, docker-compose up and docker-compose build will work as expected.

Usage

See usage docs.

Authentication

See authentication docs.

Releasing

To cut the Maven release:

mvn clean [-B -Dinvoker.skip -DskipTests -Darguments='-Dinvoker.skip -DskipTests'] \
  -Dgpg.keyname=<key ID used for signing artifacts> \
  release:clean release:prepare release:perform

We use gren to create Releases in Github:

gren release
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].