• [Docker] Leverage a Docker Maven plugin


        <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
    ``
  • 相关阅读:
    dirname basename 截取路径中的目录以及文件名
    Singleton 单例模板
    人生最后一个10年-白银时代
    自动填充英文字母序列
    关于最近使用文档的几个技巧
    关于最近使用文档的几个技巧
    The King of Excel Geek 0.1版本
    Tkinter 学习
    test
    检测电话号码的python程序(一)
  • 原文地址:https://www.cnblogs.com/Answer1215/p/14199443.html
Copyright © 2020-2023  润新知