さくっと行かなかったから記事にするんですけども。
何がさくっと行かなかったか
タイトルでネタバレですが私がProxyの中にいたからです。
mvnコマンド自体はProxyから出れているのに、creatorとかいうフェーズでエラーになりました。
$ mvn spring-boot:build-image
### (中略)
[INFO] > Running creator
[INFO] [creator] ===> DETECTING
[INFO] [creator] 5 of 18 buildpacks participating
### (中略)
[INFO] [creator] ===> ANALYZING
[INFO] [creator] Previous image with name "docker.io/library/user-api:0.0.2-SNAPSHOT" not found
### (このnot foundは気にしなくていいらしい)
[INFO] [creator] ===> RESTORING
[INFO] [creator] ===> BUILDING
### (中略)
[INFO] [creator] BellSoft Liberica JRE 8.0.275: Contributing to layer
[INFO] [creator] Downloading from https://github.com/bell-sw/Liberica/releases/download/8u275+1/bellsoft-jre8u275+1-linux-amd64.tar.gz
[INFO] [creator] unable to invoke layer creator
[INFO] [creator] unable to get dependency jre
[INFO] [creator] unable to download https://github.com/bell-sw/Liberica/releases/download/8u275+1/bellsoft-jre8u275+1-linux-amd64.tar.gz
[INFO] [creator] unable to request https://github.com/bell-sw/Liberica/releases/download/8u275+1/bellsoft-jre8u275+1-linux-amd64.tar.gz
[INFO] [creator] Get "https://github.com/bell-sw/Liberica/releases/download/8u275+1/bellsoft-jre8u275+1-linux-amd64.tar.gz": dial tcp: lookup github.com on 192.168.65.1:53: no such host
[INFO] [creator] ERROR: failed to build: exit status 1
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 54.659 s
[INFO] Finished at: 2021-01-04T15:05:43+09:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.4.1:build-image (default-cli) on project user-api: Execution default-cli of goal org.springframework.boot:spring-boot-maven-plugin:2.4.1:build-image failed: Builder lifecycle 'creator' failed with status code 145 -> [Help 1]
[ERROR]
どうしたか
よく見るDockerのProxy周りのやつ(特に 192.168.65.1:53: no such host
の辺りが)だと思ったので調べたところ
spring-boot-maven-plugin
でPROXYを設定しないといけないようですね。
pom.xml
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<image>
<env>
<HTTP_PROXY>${env.HTTP_PROXY}</HTTP_PROXY>
<HTTPS_PROXY>${env.HTTPS_PROXY}</HTTPS_PROXY>
</env>
</image>
</configuration>
</plugin>
<!-- 中略 -->
</plugins>
</build>
※PROXYが必要なのは初回に色々DLしてくるときだけのようです。上記は環境変数化してますが、最初ベタ書きでやったのでうまく動かないかも…
ちなみに
Spring Boot 2.3以前のものを対応させようとするとバージョンアップが必要です。
javax.validation.*を使用している場合は、以下も必要です。
pom.xml
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
今回のコード
今回私が試したコード差分は以下です。
https://github.com/ymtk172/ytmp_user-api/commit/87d5048b60ca8c4aef8cd1538aef0e955638c024#diff-9c5fb3d1b7e3b0f54bc5c4182965c4fe1f9023d449017cece3005d3f90e8e4d8
Proxyのある人生に幸あれ