码迷,mamicode.com
首页 > 其他好文 > 详细

[Docker] Leverage a Docker Maven plugin

时间:2021-01-01 12:13:15      阅读:0      评论:0      收藏:0      [点我收藏+]

标签:utf-8   final   entry   sources   clu   active   use   force   image   

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>com.spotify</groupId>
                <artifactId>docker-maven-plugin</artifactId>
                <version>1.1.1</version>
                <configuration>
                    <imageName>explorecali-${ec-profile}</imageName>
                    <baseImage>java</baseImage>
                    <entryPoint>["java", "-Dspring.profiles.active=${ec-profile}", "-jar", "/${project.build.finalName}.jar"]</entryPoint>
                    <resources>
                        <resource>
                            <targetPath>/</targetPath>
                            <directory>${project.build.directory}</directory>
                            <include>${project.build.finalName}.jar</include>
                        </resource>
                    </resources>
                    <forceTags>true</forceTags>
                    <buildArgs>
                        <JAR_FILE>target/${project.build.finalName}.jar</JAR_FILE>
                    </buildArgs>
                </configuration>
            </plugin>

        </plugins>
    </build>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <java.version>1.8</java.version>
        <ec-profile>default</ec-profile>
    </properties>

 

#### Dockerize Explore California

##### Build jar, image, set default profile

``

mvn package -DskipTests docker:build 

``
###### container with default property set in Dockerfile
``
docker run --name ec-app-default -p 8080:8080  -d explorecali-default
``
##### Build jar, image, set mysql profile
``
mvn package -DskipTests docker:build -Dec-profile=mysql
``
##### Run Docker container with mysql profile
``
docker run    --name ec-app-mysql -p 8181:8080  --link ec-mysql:mysql -d explorecali-mysql
``
##### Build jar, image, set docker profile
``
mvn package -DskipTests docker:build -Dec-profile=docker
``
##### Run Docker container with docker profile set in Dockerfile and migration scripts on host
``
docker run --name ec-app-docker -p 8282:8080 -v ~/db/migration:/var/migration -e server=ec-mysql -e port=3306 -e dbuser=cali_user -e dbpassword=cali_pass --link ec-mysql:mysql -d explorecali-docker
``
##### Enter Docker container
``
docker exec -t -i ec-app /bin/bash
``

 

[Docker] Leverage a Docker Maven plugin

标签:utf-8   final   entry   sources   clu   active   use   force   image   

原文地址:https://www.cnblogs.com/Answer1215/p/14199443.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!