2016-05-10 8 views
1

Spotify Maven Docker pluginを使用すると、Dockerコンテナに追加するリソースのファイルアクセス許可をどのように変更できますか?たとえば、次のMaven Dockerプラグインの定義では、Mavenにスクリプトwait-for-file.shを実行可能にするように指示するにはどうすればよいですか?Spotify Maven Dockerプラグインを使用して、Dockerコンテナに追加するリソースのファイルパーミッションを変更するにはどうすればよいですか?

<plugin> 
     <groupId>com.spotify</groupId> 
     <artifactId>docker-maven-plugin</artifactId> 
     <version>0.4.9</version> 
     <configuration> 
      <imageName>opes/${project.artifactId}</imageName> 
      <imageTags> 
       <imageTag>${project.version}</imageTag> 
       <imageTag>latest</imageTag> 
      </imageTags>      
      <baseImage>opes/tomcat</baseImage> 
      <maintainer>Derek Mahar &lt;[email protected]&gt;</maintainer> 
      <resources> 
       <resource> 
        <targetPath>/usr/local/tomcat/webapps</targetPath> 
        <directory>${project.build.directory}</directory> 
        <include>${project.build.finalName}.war</include> 
       </resource> 
       <resource> 
        <targetPath>/</targetPath> 
        <directory>src/main/docker</directory> 
        <include>wait-for-file.sh</include> 
       </resource> 
      </resources> 
     </configuration> 
    </plugin> 

答えて

0

を助け、SpotifyはMavenのドッカープラグインは明示的にドッカーコンテナにそのコピーしたファイルのパーミッションを変更するコマンドを提供していません。

ただし、Fabric8 Maven Docker pluginはこのようなコマンドを提供していますが、Spotifyのプラグインよりもさらに多くの機能を備えています。

はここに私のソリューションです:pom.xmlから

src/main/docker/assembly.xml

<plugin> 
     <groupId>io.fabric8</groupId> 
     <artifactId>docker-maven-plugin</artifactId> 
     <version>0.15.1</version> 
     <configuration> 
      <images> 
       <image> 
        <name>opes/${project.artifactId}</name> 
        <build> 
         <tags> 
          <tag>latest</tag> 
          <tag>${project.version}</tag> 
         </tags> 
         <from>opes/tomcat</from> 
         <maintainer>Derek Mahar &lt;[email protected]&gt;</maintainer> 
         <assembly> 
          <mode>tgz</mode> 
          <basedir>/</basedir> 
          <descriptor>assembly.xml</descriptor> 
         </assembly> 
        </build>       
       </image> 
      </images> 
     </configuration> 
    </plugin> 

内容:あなたは好奇心旺盛だ場合

<?xml version="1.0" encoding="UTF-8"?> 
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2" 
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
      xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd"> 
    <id>platinum-oms</id> 
    <files> 
     <file> 
      <source>${project.build.directory}/${project.build.finalName}.war</source> 
      <outputDirectory>usr/local/tomcat/webapps</outputDirectory> 
     </file> 
     <file> 
      <source>src/main/docker/wait-for-file.sh</source> 
      <outputDirectory>/</outputDirectory> 
      <fileMode>544</fileMode> 
     </file> 
    </files> 
</assembly> 

Fabric8はそのDocker Maven Plugin ShootoutにいくつかのMavenドッカープラグインを比較します。

0

私はmavenがユーザーの権限でリソースをコピーする必要があります。

try maven-antrun-plugin。 例:

<plugin> 
<groupId>org.apache.maven.plugins</groupId> 
<artifactId>maven-antrun-plugin</artifactId> 
<version>1.8</version> 
<executions> 
    <execution> 
     <id>permission</id> 
     <phase> <!-- a lifecycle phase --></phase> 
     <goals> 
      <goal>run</goal> 
     </goals> 
     <configuration> 
      <target> 
       <chmod file="/wait-for-file.sh" perm="755"/> 
      </target> 
     </configuration> 
     </execution> 
</executions> 
</plugin> 

希望、これは私の知る限り

+0

私はこのアプローチを使用することを考えましたが、 'docker-maven-plugin'の前にMavenが' maven-antrun-plugin'を実行することをどのように確認できますか? –

+0

これに応じて相を設定する必要があります –

関連する問題