-
Notifications
You must be signed in to change notification settings - Fork 653
Open
Description
I have a scenario where the image is created by:
- Running a database image
- Running a Flyway image, creating a schema in the DB
- Committing the image using
docker commit,
which captures the state of the container into an image.
AFAICT, docker-maven-plugin doesn't have any way to do that.
So I resorted to the following. (Please disregard the granit-latest as a version, I am restricted in naming by Gitlab.)
<groupId>org.codehaus.mojo</groupId><artifactId>exec-maven-plugin</artifactId> ...
<configuration>
<executable>docker</executable>
...
<execution><id>granit-container-commit</id><goals><goal>exec</goal></goals><phase>integration-test</phase>
<configuration>
<arguments>
<argument>commit</argument><argument>--message</argument><argument>CRDB with schemas applied by Flyway.</argument>
<argument>cockroach-1</argument><argument>${nx.gitlabImagesRepo}:granit-${project.version}</argument>
</arguments>
</configuration>
</execution>
<execution><id>granit-image-tag</id><goals><goal>exec</goal></goals><phase>integration-test</phase>
<configuration>
<arguments>
<argument>tag</argument>
<argument>${nx.gitlabImagesRepo}:granit-${project.version}</argument>
<argument>${nx.gitlabImagesRepo}:granit-latest</argument>
</arguments>
</configuration>
</execution>Which is a bit cumbersome and could be replaced by a few lines of DMP.
<image>
<name>${nx.gitlabImagesRepo}</name>
<run>
...
<commit>
<tags>granit-latest</tags>
<message>...</message>
...
</commit>
</run>
</image>
...
<execution><id>granit-image-commit</id><phase>post-integration-test</phase><goals><goal>commit</goal></goals></execution>The docker:commit would look for <image>s with <run> which have <commit>, and commit the container right after stopping it.
Other things that Docker can apply when performing a commit can be taken from the <build> section: CMD|ENTRYPOINT|ENV|EXPOSE|LABEL|ONBUILD|USER|VOLUME|WORKDIR (in which case it would have to have <skip>true<skip> to avoid actually building it?)
seregamorph
Metadata
Metadata
Assignees
Labels
No labels