[Docker] Leverage a Docker Maven plugin

技术文章 11个月前 完美者
1,148 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

版权声明:完美者 发表于 2021-01-01 12:13:15。
转载请注明:[Docker] Leverage a Docker Maven plugin | 完美导航

暂无评论

暂无评论...