Skip to content

Commit 7b644a7

Browse files
committed
Merge pull request #92 from pushtechnology/docker_copy
Support docker copy of resources
2 parents 72b49d4 + 77d71d2 commit 7b644a7

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed

USAGE.md

+10
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ Goals
88
* `start` - start the containers in order and ensures they are running
99
* `stop` - stop all running containers for the project
1010
* `deploy` - push containers to Docker repository
11+
* `copy` - copy resources from a Docker container
1112
* `save` - save images to file, optionally deploy to Maven repository
1213

1314
Pre-requisites
@@ -215,3 +216,12 @@ healthChecks:
215216
```
216217

217218
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 numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
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+
}

0 commit comments

Comments
 (0)