argo workflow流水线适配一个git工程多个启动工程

110 阅读1分钟

基于argo workflow的流水线默认使用根路径下的Dockerfile文件进行编译docker镜像。一个git工程假如有两个启动工程如何支持部署呢?

方案1

流水线添加指定Dockerfile文件路径进行docker build的参数

方案2

在编译过程,根据不同的profile-id,拷贝不同的Dockerfile文件到根路径下。参考blog.csdn.net/zengxx1989/…

  <profiles>
        <profile>
            <id>aaaaaa</id>
            <build>
                <plugins>
                    <plugin>
                        <artifactId>maven-antrun-plugin</artifactId>
                        <executions>
                            <execution>
                                <phase>package</phase>
                                <goals>
                                    <goal>run</goal>
                                </goals>
                                <configuration>
                                    <tasks>
                                        <copy file="src/main/resources/Dockerfile-aaaaaa" tofile="../Dockerfile"/>
                                    </tasks>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>bbbbbb</id>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <artifactId>maven-antrun-plugin</artifactId>
                        <executions>
                            <execution>
                                <phase>package</phase>
                                <goals>
                                    <goal>run</goal>
                                </goals>
                                <configuration>
                                    <tasks>
                                        <copy file="src/main/resources/Dockerfile-bbbbbb" tofile="../Dockerfile"/>
                                    </tasks>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

 

需要适配mvn编译参数,同样是需要流水线进行适配

mvn -DskipTests -Paaaaaaaa package

mvn -DskipTests -Pbbbbbbbb package