File tree 2 files changed +48
-0
lines changed
src/main/java/com/alexecollins/docker/mojo
2 files changed +48
-0
lines changed Original file line number Diff line number Diff line change 8
8
* ` start ` - start the containers in order and ensures they are running
9
9
* ` stop ` - stop all running containers for the project
10
10
* ` deploy ` - push containers to Docker repository
11
+ * ` copy ` - copy resources from a Docker container
11
12
* ` save ` - save images to file, optionally deploy to Maven repository
12
13
13
14
Pre-requisites
@@ -215,3 +216,12 @@ healthChecks:
215
216
```
216
217
217
218
This can be turned off by set ` exposeContainerIp ` to ` false ` in ` conf.yml `
219
+
220
+ Copy resources from a docker container
221
+ ---
222
+
223
+ The copy command allows you to extract resources from your docker container, allowing you to use docker as a build engine from within maven.
224
+ The resources to copy are specified by ` source ` and the location to copy to by ` dest ` . If ` source ` is a directory then the directory
225
+ contents will be copied. ` dest ` can be a file or directory, if a directory then the resource names will be preserved.
226
+
227
+
Original file line number Diff line number Diff line change
1
+ package com .alexecollins .docker .mojo ;
2
+
3
+ import com .alexecollins .docker .orchestration .DockerOrchestrator ;
4
+ import org .apache .maven .plugins .annotations .LifecyclePhase ;
5
+ import org .apache .maven .plugins .annotations .Mojo ;
6
+ import org .apache .maven .plugins .annotations .Parameter ;
7
+
8
+ /**
9
+ * Copy resources from the containers.
10
+ */
11
+ @ Mojo (name = "copy" , defaultPhase = LifecyclePhase .PACKAGE )
12
+ public class CopyMojo extends AbstractDockerMojo {
13
+ /**
14
+ * Resource to copy out of the docker container.
15
+ */
16
+ @ Parameter (property = "docker.source" )
17
+ private String resource ;
18
+
19
+ /**
20
+ * Resource to copy out of the docker container.
21
+ */
22
+ @ Parameter (property = "docker.dest" )
23
+ private String dest ;
24
+
25
+ public String getSource () {
26
+ return resource ;
27
+ }
28
+
29
+ public String getDest () {
30
+ return dest ;
31
+ }
32
+
33
+ @ Override
34
+ protected void doExecute (DockerOrchestrator orchestrator ) throws Exception {
35
+ getLog ().info ("Copying " + getSource () + " to " + getDest ());
36
+ orchestrator .copy (getSource (), getDest ());
37
+ }
38
+ }
You can’t perform that action at this time.
0 commit comments