Tanzu Build Service(TBS) を利用してみる - その2

Tanzu Kubernetes Grid 上に Tanzu Build Service をインストールする」では、ソースコードは--local-path で指定したビルド済のアプリケーションを利用しましたが、今回はGitHub 上にあるサンプルアプリケーションを利用し、ソースコードのビルド、コンテナイメージの作成をTBS を利用し実施してみます。

また、GitHub のソースコードの変更(Commit) を検知し、自動で新たなコンテナイメージが作成される事を確認していきます


前提

  • TBS が利用出来る事

手順


TBS を利用し、コンテナイメージを作成する(エラー)

登録されているコンテナイメージを一度削除します。
$ kp image delete spring-petclinic -n demo
Image "spring-petclinic" deleted

TBS を利用して、コンテナイメージを作成します。
下記の通り、ERROR: failed to chown volumes: chown /cache: operation not permitted というエラーメッセージと共に、コンテナイメージのビルドが失敗しました。。。--local-path で指定した際は問題無かったのですが。。。
$ kp image create spring-petclinic --tag harbor2.<MYDOMAIN>/tanzu/spring-petclinic --git https://github.com/itot555/spring-petclinic.git --git-revision main -n demo --wait
Creating Image...
Image "spring-petclinic" created
===> PREPARE
Build reason(s): CONFIG
CONFIG:
	resources: {}
	- source: {}
	+ source:
	+   git:
	+     revision: 3cd28d565cd1efdd3bc55ccc9822fcd865a67c44
	+     url: https://github.com/itot555/spring-petclinic.git
Loading secret for "harbor2.<MYDOMAIN>" from secret "lab-harbor2" at location "/var/build-secrets/lab-harbor2"
Cloning "https://github.com/itot555/spring-petclinic.git" @ "3cd28d565cd1efdd3bc55ccc9822fcd865a67c44"...
Successfully cloned "https://github.com/itot555/spring-petclinic.git" @ "3cd28d565cd1efdd3bc55ccc9822fcd865a67c44" in path "/workspace"
===> DETECT
7 of 33 buildpacks participating
paketo-buildpacks/ca-certificates   2.1.0
paketo-buildpacks/bellsoft-liberica 7.0.1
paketo-buildpacks/maven             5.0.0
paketo-buildpacks/executable-jar    5.0.0
paketo-buildpacks/apache-tomcat     5.1.0
paketo-buildpacks/dist-zip          4.0.0
paketo-buildpacks/spring-boot       4.1.0
===> ANALYZE
ERROR: failed to chown volumes: chown /cache: operation not permitted
Error: update to image failed

TKG v1.2.1 on vSphere 環境で利用する場合、StorageClass を変更する

vSphere におけるTKG v1.2.1 でのKnown Issue にヒットしている様です。ドキュメントにある通り、vsphere-csi-controller を修正します。Workload Cluster は既に作成されている状態であるため、以下の方法で修正します。
$ kubectl patch deployment -n kube-system vsphere-csi-controller --type=json -p='[{"op": "add", "path": "/spec/template/spec/containers/4/args/-", "value": "--default-fstype=ext4"}]'
deployment.apps/vsphere-csi-controller patched
$ kubectl delete pod -n kube-system -l app=vsphere-csi-controller
pod "vsphere-csi-controller-6c677cb64d-kh55j" deleted
pod "vsphere-csi-controller-867d69bc6f-x64tv" deleted

TBS を利用し、コンテナイメージを作成する(リベンジ)

一度イメージを削除した上で、改めてTBS でイメージを作成します。
--local-path ではなく、今回はGitHub にあるアプリケーションを用いて、TBS を利用しコンテナイメージを作成します。
$ kp image create spring-petclinic --tag harbor2.<MYDOMAIN>/tanzu/spring-petclinic --git https://github.com/itot555/spring-petclinic.git --git-revision main -n demo --wait
Creating Image...
Image "spring-petclinic" created
===> PREPARE
Build reason(s): CONFIG
CONFIG:
	resources: {}
	- source: {}
	+ source:
	+   git:
	+     revision: 3cd28d565cd1efdd3bc55ccc9822fcd865a67c44
	+     url: https://github.com/itot555/spring-petclinic.git
Loading secret for "harbor2.<MYDOMAIN>" from secret "lab-harbor2" at location "/var/build-secrets/lab-harbor2"
Cloning "https://github.com/itot555/spring-petclinic.git" @ "3cd28d565cd1efdd3bc55ccc9822fcd865a67c44"...
Successfully cloned "https://github.com/itot555/spring-petclinic.git" @ "3cd28d565cd1efdd3bc55ccc9822fcd865a67c44" in path "/workspace"
===> DETECT
7 of 33 buildpacks participating
paketo-buildpacks/ca-certificates   2.1.0
paketo-buildpacks/bellsoft-liberica 7.0.1
paketo-buildpacks/maven             5.0.0
paketo-buildpacks/executable-jar    5.0.0
paketo-buildpacks/apache-tomcat     5.1.0
paketo-buildpacks/dist-zip          4.0.0
paketo-buildpacks/spring-boot       4.1.0
===> ANALYZE
Restoring metadata for "paketo-buildpacks/ca-certificates:helper" from app image
Restoring metadata for "paketo-buildpacks/bellsoft-liberica:jvmkill" from app image
Restoring metadata for "paketo-buildpacks/bellsoft-liberica:helper" from app image
Restoring metadata for "paketo-buildpacks/bellsoft-liberica:java-security-properties" from app image
Restoring metadata for "paketo-buildpacks/bellsoft-liberica:jre" from app image
Restoring metadata for "paketo-buildpacks/executable-jar:class-path" from app image
Restoring metadata for "paketo-buildpacks/spring-boot:helper" from app image
Restoring metadata for "paketo-buildpacks/spring-boot:spring-cloud-bindings" from app image
Restoring metadata for "paketo-buildpacks/spring-boot:web-application-type" from app image
===> RESTORE
===> BUILD

Paketo CA Certificates Buildpack 2.1.0
  https://github.com/paketo-buildpacks/ca-certificates
  Launch Helper: Contributing to layer
    Creating /layers/paketo-buildpacks_ca-certificates/helper/exec.d/ca-certificates-helper

Paketo BellSoft Liberica Buildpack 7.0.1
  https://github.com/paketo-buildpacks/bellsoft-liberica
  Build Configuration:
    $BP_JVM_VERSION              11              the Java version
  Launch Configuration:
    $BPL_JVM_HEAD_ROOM           0               the headroom in memory calculation
    $BPL_JVM_LOADED_CLASS_COUNT  35% of classes  the number of loaded classes in memory calculation
    $BPL_JVM_THREAD_COUNT        250             the number of threads in memory calculation
    $JAVA_TOOL_OPTIONS                           the JVM launch flags
  BellSoft Liberica JDK 11.0.10: Contributing to layer
    Reusing cached download from buildpack
    Expanding to /layers/paketo-buildpacks_bellsoft-liberica/jdk
    Adding 129 container CA certificates to JVM truststore
    Writing env.build/JAVA_HOME.override
    Writing env.build/JDK_HOME.override
  BellSoft Liberica JRE 11.0.10: Contributing to layer
    Reusing cached download from buildpack
    Expanding to /layers/paketo-buildpacks_bellsoft-liberica/jre
    Adding 129 container CA certificates to JVM truststore
    Writing env.launch/BPI_APPLICATION_PATH.default
    Writing env.launch/BPI_JVM_CACERTS.default
    Writing env.launch/BPI_JVM_CLASS_COUNT.default
    Writing env.launch/BPI_JVM_SECURITY_PROVIDERS.default
    Writing env.launch/JAVA_HOME.default
    Writing env.launch/MALLOC_ARENA_MAX.default
  Launch Helper: Contributing to layer
    Creating /layers/paketo-buildpacks_bellsoft-liberica/helper/exec.d/active-processor-count
    Creating /layers/paketo-buildpacks_bellsoft-liberica/helper/exec.d/java-opts
    Creating /layers/paketo-buildpacks_bellsoft-liberica/helper/exec.d/link-local-dns
    Creating /layers/paketo-buildpacks_bellsoft-liberica/helper/exec.d/memory-calculator
    Creating /layers/paketo-buildpacks_bellsoft-liberica/helper/exec.d/openssl-certificate-loader
    Creating /layers/paketo-buildpacks_bellsoft-liberica/helper/exec.d/security-providers-configurer
    Creating /layers/paketo-buildpacks_bellsoft-liberica/helper/exec.d/security-providers-classpath-9
  JVMKill Agent 1.16.0: Reusing cached layer
  Java Security Properties: Contributing to layer
    Writing env.launch/JAVA_SECURITY_PROPERTIES.default
    Writing env.launch/JAVA_TOOL_OPTIONS.append
    Writing env.launch/JAVA_TOOL_OPTIONS.delim


Paketo Maven Buildpack 5.0.0
  https://github.com/paketo-buildpacks/maven
  Build Configuration:
    $BP_MAVEN_BUILD_ARGUMENTS  -Dmaven.test.skip=true package  the arguments to pass to Maven
    $BP_MAVEN_BUILT_ARTIFACT   target *.[jw]ar                 the built application artifact explicitly.  Supersedes $BP_MAVEN_BUILT_MODULE
    $BP_MAVEN_BUILT_MODULE                                     the module to find application artifact in
    Creating cache directory /home/cnb/.m2
  Compiled Application: Contributing to layer
    Executing mvnw --batch-mode -Dmaven.test.skip=true package
    
......(SNIP)......

[INFO] Downloaded from central: https://repo.maven.apache.org/maven2/org/tukaani/xz/1.8/xz-1.8.jar (109 kB at 195 kB/s)
[INFO] Building jar: /workspace/target/spring-petclinic-2.3.0.BUILD-SNAPSHOT.jar
[INFO]
[INFO] --- spring-boot-maven-plugin:2.3.3.RELEASE:repackage (repackage) @ spring-petclinic ---
[INFO] Replacing main artifact with repackaged archive
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  12:44 min
[INFO] Finished at: 2021-03-19T07:35:35Z
[INFO] ------------------------------------------------------------------------
  Removing source code

Paketo Executable JAR Buildpack 5.0.0
  https://github.com/paketo-buildpacks/executable-jar
  Class Path: Contributing to layer
    Writing env/CLASSPATH.delim
    Writing env/CLASSPATH.prepend
  Process types:
    executable-jar: java org.springframework.boot.loader.JarLauncher (direct)
    task:           java org.springframework.boot.loader.JarLauncher (direct)
    web:            java org.springframework.boot.loader.JarLauncher (direct)

Paketo Spring Boot Buildpack 4.1.0
  https://github.com/paketo-buildpacks/spring-boot
  Launch Helper: Contributing to layer
    Creating /layers/paketo-buildpacks_spring-boot/helper/exec.d/spring-cloud-bindings
  Spring Cloud Bindings 1.7.0: Reusing cached layer
  Web Application Type: Contributing to layer
    Servlet web application detected
    Writing env.launch/BPL_JVM_THREAD_COUNT.default
  Image labels:
    org.opencontainers.image.title
    org.opencontainers.image.version
    org.springframework.boot.spring-configuration-metadata.json
    org.springframework.boot.version
===> EXPORT
Reusing layers from image 'harbor2.<MYDOMAIN>/tanzu/spring-petclinic@sha256:ec63dc8345669ffd18eb2c9ca8c93f68f40ff486701e3cda663924ee2d0f6230'
Adding layer 'paketo-buildpacks/ca-certificates:helper'
Adding layer 'paketo-buildpacks/bellsoft-liberica:helper'
Reusing layer 'paketo-buildpacks/bellsoft-liberica:java-security-properties'
Adding layer 'paketo-buildpacks/bellsoft-liberica:jre'
Reusing layer 'paketo-buildpacks/bellsoft-liberica:jvmkill'
Adding layer 'paketo-buildpacks/executable-jar:classpath'
Adding layer 'paketo-buildpacks/spring-boot:helper'
Reusing layer 'paketo-buildpacks/spring-boot:spring-cloud-bindings'
Reusing layer 'paketo-buildpacks/spring-boot:web-application-type'
Adding 1/1 app layer(s)
Reusing layer 'launcher'
Adding layer 'config'
Reusing layer 'process-types'
Adding label 'io.buildpacks.lifecycle.metadata'
Adding label 'io.buildpacks.build.metadata'
Adding label 'io.buildpacks.project.metadata'
Adding label 'org.opencontainers.image.title'
Adding label 'org.opencontainers.image.version'
Adding label 'org.springframework.boot.spring-configuration-metadata.json'
Adding label 'org.springframework.boot.version'
Setting default process type 'web'
*** Images (sha256:616474a2f212cff60233aee8dde19439840361dd314c2f29793b4159f477ae92):
      harbor2.<MYDOMAIN>/tanzu/spring-petclinic
      harbor2.<MYDOMAIN>/tanzu/spring-petclinic:b1.20210319.071800
Adding cache layer 'paketo-buildpacks/bellsoft-liberica:jdk'
Adding cache layer 'paketo-buildpacks/maven:application'
Adding cache layer 'paketo-buildpacks/maven:cache'
===> COMPLETION
Build successful

イメージが作成された事を確認します。
$ kp build list spring-petclinic -n demo
BUILD    STATUS     IMAGE                                                                                                                    REASON
1        SUCCESS    harbor2.<MYDOMAIN>/tanzu/spring-petclinic@sha256:616474a2f212cff60233aee8dde19439840361dd314c2f29793b4159f477ae92    CONFIG


ソースコードを変更し、自動でコンテナイメージが作成する事を確認する

fork したspring-petclinic アプリを適当に更新し、commit します。
ここでは、spring-petclinic/src/main/resources/messages/messages.properties を修正し、commit しました。
TBS がcommit された事を検知し、新たにコンテナイメージをビルドします。
$ kp build list spring-petclinic -n demo
BUILD    STATUS      IMAGE                                                                                                                    REASON
1        SUCCESS     harbor2.<MYDOMAIN>/tanzu/spring-petclinic@sha256:616474a2f212cff60233aee8dde19439840361dd314c2f29793b4159f477ae92    CONFIG
2        BUILDING                                                                                                                             COMMIT

$ kp build list spring-petclinic -n demo
BUILD    STATUS     IMAGE                                                                                                                    REASON
1        SUCCESS    harbor2.<MYDOMAIN>/tanzu/spring-petclinic@sha256:616474a2f212cff60233aee8dde19439840361dd314c2f29793b4159f477ae92    CONFIG
2        SUCCESS    harbor2.<MYDOMAIN>/tanzu/spring-petclinic@sha256:b2b0c7bba33f31c29e1fa5d7d02fb7eb6dd91d17fca09fe0307d4446a4c5fcbc    COMMIT

新たにビルドされた際のログも見てみます。
$ $ kp build logs spring-petclinic -b 2 -n demo
===> PREPARE
Build reason(s): COMMIT
COMMIT:
	- 3cd28d565cd1efdd3bc55ccc9822fcd865a67c44
	+ 55b8b8b5f0a6f12edcccb8d42dc66d5ee14b1055
Loading secret for "harbor2.<MYDOMAIN>" from secret "lab-harbor2" at location "/var/build-secrets/lab-harbor2"
Cloning "https://github.com/itot555/spring-petclinic.git" @ "55b8b8b5f0a6f12edcccb8d42dc66d5ee14b1055"...
Successfully cloned "https://github.com/itot555/spring-petclinic.git" @ "55b8b8b5f0a6f12edcccb8d42dc66d5ee14b1055" in path "/workspace"
===> DETECT
7 of 33 buildpacks participating
paketo-buildpacks/ca-certificates   2.1.0
paketo-buildpacks/bellsoft-liberica 7.0.1
paketo-buildpacks/maven             5.0.0
paketo-buildpacks/executable-jar    5.0.0
paketo-buildpacks/apache-tomcat     5.1.0
paketo-buildpacks/dist-zip          4.0.0
paketo-buildpacks/spring-boot       4.1.0
===> ANALYZE
Restoring metadata for "paketo-buildpacks/ca-certificates:helper" from app image
Restoring metadata for "paketo-buildpacks/bellsoft-liberica:helper" from app image
Restoring metadata for "paketo-buildpacks/bellsoft-liberica:java-security-properties" from app image
Restoring metadata for "paketo-buildpacks/bellsoft-liberica:jre" from app image
Restoring metadata for "paketo-buildpacks/bellsoft-liberica:jvmkill" from app image
Restoring metadata for "paketo-buildpacks/bellsoft-liberica:jdk" from cache
Restoring metadata for "paketo-buildpacks/maven:cache" from cache
Restoring metadata for "paketo-buildpacks/maven:application" from cache
Restoring metadata for "paketo-buildpacks/spring-boot:helper" from app image
Restoring metadata for "paketo-buildpacks/spring-boot:spring-cloud-bindings" from app image
Restoring metadata for "paketo-buildpacks/spring-boot:web-application-type" from app image
===> RESTORE
Restoring data for "paketo-buildpacks/bellsoft-liberica:jdk" from cache
Restoring data for "paketo-buildpacks/maven:application" from cache
Restoring data for "paketo-buildpacks/maven:cache" from cache
===> BUILD

Paketo CA Certificates Buildpack 2.1.0
  https://github.com/paketo-buildpacks/ca-certificates
  Launch Helper: Reusing cached layer

Paketo BellSoft Liberica Buildpack 7.0.1
  https://github.com/paketo-buildpacks/bellsoft-liberica
  Build Configuration:
    $BP_JVM_VERSION              11              the Java version
  Launch Configuration:
    $BPL_JVM_HEAD_ROOM           0               the headroom in memory calculation
    $BPL_JVM_LOADED_CLASS_COUNT  35% of classes  the number of loaded classes in memory calculation
    $BPL_JVM_THREAD_COUNT        250             the number of threads in memory calculation
    $JAVA_TOOL_OPTIONS                           the JVM launch flags
  BellSoft Liberica JDK 11.0.10: Reusing cached layer
  BellSoft Liberica JRE 11.0.10: Reusing cached layer
  Launch Helper: Reusing cached layer
  JVMKill Agent 1.16.0: Reusing cached layer
  Java Security Properties: Reusing cached layer

Paketo Maven Buildpack 5.0.0
  https://github.com/paketo-buildpacks/maven
  Build Configuration:
    $BP_MAVEN_BUILD_ARGUMENTS  -Dmaven.test.skip=true package  the arguments to pass to Maven
    $BP_MAVEN_BUILT_ARTIFACT   target *.[jw]ar                 the built application artifact explicitly.  Supersedes $BP_MAVEN_BUILT_MODULE
    $BP_MAVEN_BUILT_MODULE                                     the module to find application artifact in
    Creating cache directory /home/cnb/.m2
  Compiled Application: Contributing to layer
    Executing mvnw --batch-mode -Dmaven.test.skip=true package
[INFO] Scanning for projects...
[INFO]
[INFO] ------------< org.springframework.samples:spring-petclinic >------------
[INFO] Building petclinic 2.3.0.BUILD-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- spring-javaformat-maven-plugin:0.0.25:validate (default) @ spring-petclinic ---
[INFO]
[INFO] --- maven-checkstyle-plugin:3.1.1:check (nohttp-checkstyle-validation) @ spring-petclinic ---
[INFO] You have 0 Checkstyle violations.
[INFO]
[INFO] --- jacoco-maven-plugin:0.8.5:prepare-agent (default) @ spring-petclinic ---
[INFO] argLine set to -javaagent:/home/cnb/.m2/repository/org/jacoco/org.jacoco.agent/0.8.5/org.jacoco.agent-0.8.5-runtime.jar=destfile=/workspace/target/jacoco.exec
[INFO]
[INFO] --- git-commit-id-plugin:3.0.1:revision (default) @ spring-petclinic ---
[INFO] dotGitDirectory /workspace/.git
[INFO] Collected git.build.user.name with value
[INFO] Collected git.build.user.email with value
[INFO] Collected git.branch with value 55b8b8b5f0a6f12edcccb8d42dc66d5ee14b1055
[INFO] --always = true
[INFO] --dirty = -dirty
[INFO] --abbrev = 7
[INFO] Tag refs [[Ref[refs/tags/1.5.x=c36452a2c34443ae26b4ecbba4f149906af14717]]]
[INFO] Created map: [{}]
[INFO] evalCommit is [55b8b8b5f0a6f12edcccb8d42dc66d5ee14b1055]
[INFO] Collected git.commit.id.describe with value 55b8b8b
[INFO] Collected git.commit.id.describe-short with value 55b8b8b
[INFO] Collected git.commit.id with value 55b8b8b5f0a6f12edcccb8d42dc66d5ee14b1055
[INFO] Collected git.commit.id.abbrev with value 55b8b8b
[INFO] Collected git.dirty with value false
[INFO] Collected git.commit.user.name with value Tadashi Ito
[INFO] Collected git.commit.user.email with value 10068148+itot555@users.noreply.github.com
[INFO] Collected git.commit.message.full with value Update messages.properties
[INFO] Collected git.commit.message.short with value Update messages.properties
[INFO] Collected git.commit.time with value 2021-03-19T08:13:24+0000
[INFO] Collected git.remote.origin.url with value https://github.com/itot555/spring-petclinic.git
[INFO] Collected git.tags with value
[INFO] evalCommit is [55b8b8b5f0a6f12edcccb8d42dc66d5ee14b1055]
[INFO] Tag refs [[Ref[refs/tags/1.5.x=c36452a2c34443ae26b4ecbba4f149906af14717]]]
[INFO] Created map: [{}]
[INFO] Collected git.closest.tag.name with value
[INFO] evalCommit is [55b8b8b5f0a6f12edcccb8d42dc66d5ee14b1055]
[INFO] Tag refs [[Ref[refs/tags/1.5.x=c36452a2c34443ae26b4ecbba4f149906af14717]]]
[INFO] Created map: [{}]
[INFO] Collected git.closest.tag.commit.count with value
[INFO] Collected git.total.commit.count with value 730
[INFO] Collected git.local.branch.ahead with value NO_REMOTE
[INFO] Collected git.local.branch.behind with value NO_REMOTE
[INFO] Collected git.build.time with value 2021-03-19T08:14:39+0000
[INFO] Collected git.build.version with value 2.3.0.BUILD-SNAPSHOT
[INFO] Collected git.build.host with value spring-petclinic-build-2-8vwzt-build-pod
[INFO] including property git.tags in results
[INFO] including property git.closest.tag.commit.count in results
[INFO] including property git.build.version in results
[INFO] including property git.commit.user.name in results
[INFO] including property git.commit.id.abbrev in results
[INFO] including property git.branch in results
[INFO] including property git.build.host in results
[INFO] including property git.commit.id.describe-short in results
[INFO] including property git.total.commit.count in results
[INFO] including property git.commit.id.describe in results
[INFO] including property git.build.user.email in results
[INFO] including property git.commit.id in results
[INFO] including property git.commit.message.short in results
[INFO] including property git.commit.user.email in results
[INFO] including property git.closest.tag.name in results
[INFO] including property git.local.branch.ahead in results
[INFO] including property git.commit.time in results
[INFO] including property git.local.branch.behind in results
[INFO] including property git.build.time in results
[INFO] including property git.build.user.name in results
[INFO] including property git.dirty in results
[INFO] including property git.commit.message.full in results
[INFO] including property git.remote.origin.url in results
[INFO] Writing properties file to [/workspace/target/classes/git.properties] (for module petclinic)...
[INFO]
[INFO] --- spring-boot-maven-plugin:2.3.3.RELEASE:build-info (default) @ spring-petclinic ---
[INFO]
[INFO] --- wro4j-maven-plugin:1.8.0:run (default) @ spring-petclinic ---
[INFO] /workspace/src/main/less
[INFO] Executing the mojo:
[INFO] Wro4j Model path: /workspace/src/main/wro/wro.xml
[INFO] targetGroups: null
[INFO] minimize: true
[INFO] ignoreMissingResources: null
[INFO] parallelProcessing: false
[INFO] buildDirectory: /workspace/target
[INFO] destinationFolder: /workspace/target
[INFO] cssDestinationFolder: /workspace/target/classes/static/resources/css
[INFO] The following groups will be processed: [petclinic]
[INFO] folder: /workspace/target/classes/static/resources/css
[INFO] processing group: petclinic.css
[WARNING] Less warnings are:
[WARNING] 10:1 Cannot link source map. Css result location is not know and could not be deduced from input less source..
[INFO] file size: petclinic.css -> 152399 bytes
[INFO] /workspace/target/classes/static/resources/css/petclinic.css (152399 bytes)
[INFO] folder: /workspace/target
[INFO] processing group: petclinic.js
[INFO]
[INFO] --- maven-resources-plugin:3.1.0:resources (default-resources) @ spring-petclinic ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 2 resources
[INFO] Copying 39 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) @ spring-petclinic ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 25 source files to /workspace/target/classes
[INFO]
[INFO] --- maven-resources-plugin:3.1.0:testResources (default-testResources) @ spring-petclinic ---
[INFO] Not copying test resources
[INFO]
[INFO] --- maven-compiler-plugin:3.8.1:testCompile (default-testCompile) @ spring-petclinic ---
[INFO] Not compiling test sources
[INFO]
[INFO] --- maven-surefire-plugin:2.22.2:test (default-test) @ spring-petclinic ---
[INFO] Tests are skipped.
[INFO]
[INFO] --- jacoco-maven-plugin:0.8.5:report (report) @ spring-petclinic ---
[INFO] Skipping JaCoCo execution due to missing execution data file.
[INFO]
[INFO] --- maven-jar-plugin:3.2.0:jar (default-jar) @ spring-petclinic ---
[INFO] Building jar: /workspace/target/spring-petclinic-2.3.0.BUILD-SNAPSHOT.jar
[INFO]
[INFO] --- spring-boot-maven-plugin:2.3.3.RELEASE:repackage (repackage) @ spring-petclinic ---
[INFO] Replacing main artifact with repackaged archive
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  8.813 s
[INFO] Finished at: 2021-03-19T08:14:44Z
[INFO] ------------------------------------------------------------------------
  Removing source code

Paketo Executable JAR Buildpack 5.0.0
  https://github.com/paketo-buildpacks/executable-jar
  Class Path: Contributing to layer
    Writing env/CLASSPATH.delim
    Writing env/CLASSPATH.prepend
  Process types:
    executable-jar: java org.springframework.boot.loader.JarLauncher (direct)
    task:           java org.springframework.boot.loader.JarLauncher (direct)
    web:            java org.springframework.boot.loader.JarLauncher (direct)

Paketo Spring Boot Buildpack 4.1.0
  https://github.com/paketo-buildpacks/spring-boot
  Launch Helper: Reusing cached layer
  Spring Cloud Bindings 1.7.0: Reusing cached layer
  Web Application Type: Contributing to layer
    Servlet web application detected
    Writing env.launch/BPL_JVM_THREAD_COUNT.default
  Image labels:
    org.opencontainers.image.title
    org.opencontainers.image.version
    org.springframework.boot.spring-configuration-metadata.json
    org.springframework.boot.version
===> EXPORT
Reusing layers from image 'harbor2.<MYDOMAIN>/tanzu/spring-petclinic@sha256:616474a2f212cff60233aee8dde19439840361dd314c2f29793b4159f477ae92'
Reusing layer 'paketo-buildpacks/ca-certificates:helper'
Reusing layer 'paketo-buildpacks/bellsoft-liberica:helper'
Reusing layer 'paketo-buildpacks/bellsoft-liberica:java-security-properties'
Reusing layer 'paketo-buildpacks/bellsoft-liberica:jre'
Reusing layer 'paketo-buildpacks/bellsoft-liberica:jvmkill'
Reusing layer 'paketo-buildpacks/executable-jar:classpath'
Reusing layer 'paketo-buildpacks/spring-boot:helper'
Reusing layer 'paketo-buildpacks/spring-boot:spring-cloud-bindings'
Reusing layer 'paketo-buildpacks/spring-boot:web-application-type'
Adding 1/1 app layer(s)
Reusing layer 'launcher'
Reusing layer 'config'
Reusing layer 'process-types'
Adding label 'io.buildpacks.lifecycle.metadata'
Adding label 'io.buildpacks.build.metadata'
Adding label 'io.buildpacks.project.metadata'
Adding label 'org.opencontainers.image.title'
Adding label 'org.opencontainers.image.version'
Adding label 'org.springframework.boot.spring-configuration-metadata.json'
Adding label 'org.springframework.boot.version'
Setting default process type 'web'
*** Images (sha256:b2b0c7bba33f31c29e1fa5d7d02fb7eb6dd91d17fca09fe0307d4446a4c5fcbc):
      harbor2.<MYDOMAIN>/tanzu/spring-petclinic
      harbor2.<MYDOMAIN>/tanzu/spring-petclinic:b2.20210319.081357
Reusing cache layer 'paketo-buildpacks/bellsoft-liberica:jdk'
Adding cache layer 'paketo-buildpacks/maven:application'
Reusing cache layer 'paketo-buildpacks/maven:cache'
===> COMPLETION
Build successful

無事にビルドされました。

まとめ

コンテナイメージの作成時に指定したアプリケーションコードのコードリポジトリが更新された事をトリガーに、自動でコンテナイメージが作成される事を確認出来ました。TBS を利用する事でコンテナイメージを常に最新な状態に保つ事が可能になります。

このブログの人気の投稿