0

Testing the cloud-build

Part of my cloudbuild.yaml

  - name: 'gcr.io/cloud-builders/mvn'
    args: ['dockerfile:build']

dockerfile:build perfectly works in bitbucket pipeline, no problem. I use

 <plugin>
                <groupId>com.spotify</groupId>
                <artifactId>dockerfile-maven-plugin</artifactId>
                <version>${dockerfile-maven-version}</version>
                <executions>
                    <execution>
                        <id>default</id>
                        <goals>
                            <goal>build</goal>
                            <goal>push</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <repository>gcr.io/my-project-id/${project.artifactId}</repository>
                    <tag>${project.version}</tag>
                    <buildArgs>
                        <JAR_FILE>${project.build.finalName}.jar</JAR_FILE>
                    </buildArgs>
                </configuration>
            </plugin>

But with the cloud-build for this single step I get the error:

[INFO] Step 14/15 : ARG JAR_FILE
[INFO] 
[INFO] ---> Using cache
[INFO] ---> 55793de4bb9f
[INFO] [INFO] Step 15/15 : ADD target/${JAR_FILE} /usr/share/$SERVCE_FOLDER_NAME/app.jar
[INFO] 
[ERROR] ADD failed: stat /mnt/cache/docker/tmp/docker-builder589658449/target/myappname-0.0.1-SNAPSHOT.jar: no such file or directory

(the JAR_FILE is passed from the maven dockerfile plugin

no such file or directory

Why?.. In the end of the day I juse call dockerfile:build and expect it to be the same as it is when I build it from another pipeline.

My Dockerfile:

FROM openjdk:8-jdk

ENV GOOGLE_APPLICATION_CREDENTIALS=/app/credentials.json

ARG ACTIVE_PROFILES=dev
ENV ACTIVE_PROFILES=$ACTIVE_PROFILES
ARG CREDENTIALS
ARG SERVCE_FOLDER_NAME=myappname-service
ENV SERVCE_FOLDER_NAME=$SERVCE_FOLDER_NAME

#ENTRYPOINT ["/usr/bin/java", "-jar", "/usr/share/$SERVCE_FOLDER_NAME/app.jar"]

ENTRYPOINT ["./entrypoint.sh" ]

WORKDIR /app

EXPOSE 8080

COPY ./.gcloud/credentials.json credentials.json
COPY entrypoint.sh .

#Add Maven dependencies (not shaded into the artifact; Docker-cached)
#ADD target/lib           /usr/share/$SERVCE_FOLDER_NAME/lib

ARG JAR_FILE
ADD target/${JAR_FILE} /usr/share/$SERVCE_FOLDER_NAME/app.jar

EntryPoint script is (that is what is mentioned on step 15/15 in the log):

java -Djava.security.egd=file:/dev/./urandom -jar /usr/share/$SERVCE_FOLDER_NAME/app.jar --spring.profiles.active=$ACTIVE_PROFILES

(I did try to pass hard-coded values to $SERVCE_FOLDER_NAME, $ACTIVE_PROFILES - same [it works in bitbucket pipeline])

ses
  • 13,174
  • 31
  • 123
  • 226

1 Answers1

0

A few things come to mind,

guille
  • 551
  • 4
  • 7