bootBuildImage라는게 있어서 돌려보았습니다.
아래의 오류 메시지가 떴습니다. What the..ㅋㅋ
Image name must be in the form '[domainHost:port/][path/]name', with 'path' and 'name' containing only [a-z0-9][.][_][-]
bootBuildImage관련해서 아래의 사이트나 help를 통해 알아봅시다.
https://docs.spring.io/spring-boot/docs/current/gradle-plugin/reference/htmlsingle/#build-image
./gradlew help --task :bootBuildImage
./gradlew help --task :bootBuildImage
> Task :help
Detailed task information for :bootBuildImage
Path
:bootBuildImage
Type
BootBuildImage (org.springframework.boot.gradle.tasks.bundling.BootBuildImage)
Options
--applicationDirectory The directory containing application content in the image
--builder The name of the builder image to use
--cleanCache Clean caches before packaging
--no-cleanCache Disables option --cleanCache.
--createdDate The date to use as the created date of the image
--imageName The name of the image to generate
--network Connect detect and build containers to network
--publishImage Publish the built image to a registry
--no-publishImage Disables option --publishImage.
--pullPolicy The image pull policy
Available values are:
ALWAYS
IF_NOT_PRESENT
NEVER
--runImage The name of the run image to use
--securityOptions Security options that will be applied to the builder container
--rerun Causes the task to be re-run even if up-to-date.
Description
Builds an OCI image of the application using the output of the bootJar task
Group
build
BUILD SUCCESSFUL in 342ms
1 actionable task: 1 executed
./gradlew bootBuildImage --imageName test
./gradlew bootBuildImage --imageName test
> Task :bootBuildImage
Building image 'docker.io/library/test:latest'
> Pulling builder image 'docker.io/paketobuildpacks/builder-jammy-base:latest' ..................................................
> Pulled builder image 'paketobuildpacks/builder-jammy-base@sha256:7ad2a6c523605a641a3281edac228447e46f641f3063e20f7c25491895121332'
> Pulling run image 'docker.io/paketobuildpacks/run-jammy-base:latest' ..................................................
> Pulled run image 'paketobuildpacks/run-jammy-base@sha256:8431203470391fc58454b71bdb917f53c20f403892fbb447f4ea5265a8d7cf49'
> Executing lifecycle version v0.19.0
> Using build cache volume 'pack-cache-e9d5f5abcb34.build'
> Running creator
[creator] ===> ANALYZING
[creator] Image with name "docker.io/library/test:latest" not found
[creator] ===> DETECTING
[creator] 6 of 26 buildpacks participating
[creator] paketo-buildpacks/ca-certificates 3.6.8
[creator] paketo-buildpacks/bellsoft-liberica 10.5.3
[creator] paketo-buildpacks/syft 1.45.0
[creator] paketo-buildpacks/executable-jar 6.8.4
[creator] paketo-buildpacks/dist-zip 5.6.9
[creator] paketo-buildpacks/spring-boot 5.27.10
[creator] ===> RESTORING
[creator] ===> BUILDING
[creator]
[creator] Paketo Buildpack for CA Certificates 3.6.8
[creator] https://github.com/paketo-buildpacks/ca-certificates
[creator] Launch Helper: Contributing to layer
[creator] Creating /layers/paketo-buildpacks_ca-certificates/helper/exec.d/ca-certificates-helper
[creator]
[creator] Paketo Buildpack for BellSoft Liberica 10.5.3
[creator] https://github.com/paketo-buildpacks/bellsoft-liberica
[creator] Build Configuration:
[creator] $BP_JVM_JLINK_ARGS --no-man-pages --no-header-files --strip-debug --compress=1 configure custom link arguments (--output must be omitted)
[creator] $BP_JVM_JLINK_ENABLED false enables running jlink tool to generate custom JRE
[creator] $BP_JVM_TYPE JRE the JVM type - JDK or JRE
[creator] $BP_JVM_VERSION 17 the Java version
[creator] Launch Configuration:
[creator] $BPL_DEBUG_ENABLED false enables Java remote debugging support
[creator] $BPL_DEBUG_PORT 8000 configure the remote debugging port
[creator] $BPL_DEBUG_SUSPEND false configure whether to suspend execution until a debugger has attached
[creator] $BPL_HEAP_DUMP_PATH write heap dumps on error to this path
[creator] $BPL_JAVA_NMT_ENABLED true enables Java Native Memory Tracking (NMT)
[creator] $BPL_JAVA_NMT_LEVEL summary configure level of NMT, summary or detail
[creator] $BPL_JFR_ARGS configure custom Java Flight Recording (JFR) arguments
[creator] $BPL_JFR_ENABLED false enables Java Flight Recording (JFR)
[creator] $BPL_JMX_ENABLED false enables Java Management Extensions (JMX)
[creator] $BPL_JMX_PORT 5000 configure the JMX port
[creator] $BPL_JVM_HEAD_ROOM 0 the headroom in memory calculation
[creator] $BPL_JVM_LOADED_CLASS_COUNT 35% of classes the number of loaded classes in memory calculation
[creator] $BPL_JVM_THREAD_COUNT 250 the number of threads in memory calculation
[creator] $JAVA_TOOL_OPTIONS the JVM launch flags
[creator] Using Java version 21 extracted from MANIFEST.MF
[creator] BellSoft Liberica JRE 21.0.2: Contributing to layer
[creator] Downloading from https://github.com/bell-sw/Liberica/releases/download/21.0.2+14/bellsoft-jre21.0.2+14-linux-amd64.tar.gz
[creator] Verifying checksum
[creator] Expanding to /layers/paketo-buildpacks_bellsoft-liberica/jre
[creator] Adding 137 container CA certificates to JVM truststore
[creator] Writing env.launch/BPI_APPLICATION_PATH.default
[creator] Writing env.launch/BPI_JVM_CACERTS.default
[creator] Writing env.launch/BPI_JVM_CLASS_COUNT.default
[creator] Writing env.launch/BPI_JVM_SECURITY_PROVIDERS.default
[creator] Writing env.launch/JAVA_HOME.default
[creator] Writing env.launch/JAVA_TOOL_OPTIONS.append
[creator] Writing env.launch/JAVA_TOOL_OPTIONS.delim
[creator] Writing env.launch/MALLOC_ARENA_MAX.default
[creator] Launch Helper: Contributing to layer
[creator] Creating /layers/paketo-buildpacks_bellsoft-liberica/helper/exec.d/active-processor-count
[creator] Creating /layers/paketo-buildpacks_bellsoft-liberica/helper/exec.d/java-opts
[creator] Creating /layers/paketo-buildpacks_bellsoft-liberica/helper/exec.d/jvm-heap
[creator] Creating /layers/paketo-buildpacks_bellsoft-liberica/helper/exec.d/link-local-dns
[creator] Creating /layers/paketo-buildpacks_bellsoft-liberica/helper/exec.d/memory-calculator
[creator] Creating /layers/paketo-buildpacks_bellsoft-liberica/helper/exec.d/security-providers-configurer
[creator] Creating /layers/paketo-buildpacks_bellsoft-liberica/helper/exec.d/jmx
[creator] Creating /layers/paketo-buildpacks_bellsoft-liberica/helper/exec.d/jfr
[creator] Creating /layers/paketo-buildpacks_bellsoft-liberica/helper/exec.d/openssl-certificate-loader
[creator] Creating /layers/paketo-buildpacks_bellsoft-liberica/helper/exec.d/security-providers-classpath-9
[creator] Creating /layers/paketo-buildpacks_bellsoft-liberica/helper/exec.d/debug-9
[creator] Creating /layers/paketo-buildpacks_bellsoft-liberica/helper/exec.d/nmt
[creator] Java Security Properties: Contributing to layer
[creator] Writing env.launch/JAVA_SECURITY_PROPERTIES.default
[creator] Writing env.launch/JAVA_TOOL_OPTIONS.append
[creator] Writing env.launch/JAVA_TOOL_OPTIONS.delim
[creator]
[creator] Paketo Buildpack for Syft 1.45.0
[creator] https://github.com/paketo-buildpacks/syft
[creator] Downloading from https://github.com/anchore/syft/releases/download/v0.105.0/syft_0.105.0_linux_amd64.tar.gz
[creator] Verifying checksum
[creator] Writing env.build/SYFT_CHECK_FOR_APP_UPDATE.default
[creator]
[creator] Paketo Buildpack for Executable JAR 6.8.4
[creator] https://github.com/paketo-buildpacks/executable-jar
[creator] Command "packages" is deprecated, use `syft scan` instead
[creator] Class Path: Contributing to layer
[creator] Writing env/CLASSPATH.delim
[creator] Writing env/CLASSPATH.prepend
[creator] Process types:
[creator] executable-jar: java org.springframework.boot.loader.launch.JarLauncher (direct)
[creator] task: java org.springframework.boot.loader.launch.JarLauncher (direct)
[creator] web: java org.springframework.boot.loader.launch.JarLauncher (direct)
[creator]
[creator] Paketo Buildpack for Spring Boot 5.27.10
[creator] https://github.com/paketo-buildpacks/spring-boot
[creator] Build Configuration:
[creator] $BP_SPRING_CLOUD_BINDINGS_DISABLED false whether to contribute Spring Boot cloud bindings support
[creator] $BP_SPRING_CLOUD_BINDINGS_VERSION 1 default version of Spring Cloud Bindings library to contribute
[creator] Launch Configuration:
[creator] $BPL_SPRING_CLOUD_BINDINGS_DISABLED false whether to auto-configure Spring Boot environment properties from bindings
[creator] $BPL_SPRING_CLOUD_BINDINGS_ENABLED true Deprecated - whether to auto-configure Spring Boot environment properties from bindings
[creator] Creating slices from layers index
[creator] dependencies (24.5 MB)
[creator] spring-boot-loader (446.0 KB)
[creator] snapshot-dependencies (0.0 B)
[creator] application (241.3 KB)
[creator] Launch Helper: Contributing to layer
[creator] Creating /layers/paketo-buildpacks_spring-boot/helper/exec.d/spring-cloud-bindings
[creator] Spring Cloud Bindings 2.0.2: Contributing to layer
[creator] Downloading from https://repo1.maven.org/maven2/org/springframework/cloud/spring-cloud-bindings/2.0.2/spring-cloud-bindings-2.0.2.jar
[creator] Verifying checksum
[creator] Copying to /layers/paketo-buildpacks_spring-boot/spring-cloud-bindings
[creator] Web Application Type: Contributing to layer
[creator] Servlet web application detected
[creator] Writing env.launch/BPL_JVM_THREAD_COUNT.default
[creator] 4 application slices
[creator] Image labels:
[creator] org.opencontainers.image.title
[creator] org.opencontainers.image.version
[creator] org.springframework.boot.version
[creator] ===> EXPORTING
[creator] Adding layer 'paketo-buildpacks/ca-certificates:helper'
[creator] Adding layer 'paketo-buildpacks/bellsoft-liberica:helper'
[creator] Adding layer 'paketo-buildpacks/bellsoft-liberica:java-security-properties'
[creator] Adding layer 'paketo-buildpacks/bellsoft-liberica:jre'
[creator] Adding layer 'paketo-buildpacks/executable-jar:classpath'
[creator] Adding layer 'paketo-buildpacks/spring-boot:helper'
[creator] Adding layer 'paketo-buildpacks/spring-boot:spring-cloud-bindings'
[creator] Adding layer 'paketo-buildpacks/spring-boot:web-application-type'
[creator] Adding layer 'buildpacksio/lifecycle:launch.sbom'
[creator] Adding 5/5 app layer(s)
[creator] Adding layer 'buildpacksio/lifecycle:launcher'
[creator] Adding layer 'buildpacksio/lifecycle:config'
[creator] Adding layer 'buildpacksio/lifecycle:process-types'
[creator] Adding label 'io.buildpacks.lifecycle.metadata'
[creator] Adding label 'io.buildpacks.build.metadata'
[creator] Adding label 'io.buildpacks.project.metadata'
[creator] Adding label 'org.opencontainers.image.title'
[creator] Adding label 'org.opencontainers.image.version'
[creator] Adding label 'org.springframework.boot.version'
[creator] Setting default process type 'web'
[creator] Saving docker.io/library/test:latest...
[creator] *** Images (7d4be2312d3d):
[creator] docker.io/library/test:latest
[creator] Adding cache layer 'paketo-buildpacks/syft:syft'
[creator] Adding cache layer 'buildpacksio/lifecycle:cache.sbom'
Successfully built image 'docker.io/library/test:latest'
BUILD SUCCESSFUL in 1m 38s
5 actionable tasks: 1 executed, 4 up-to-date
옵션에서는 tag관련해서는 보이지가 않네요
아래처럼 ./gradlew bootBuildImage --imageName=dokcerImage:dev 를 해봤는데 Failed가 나는군요 ㅠㅠ
그래서 꼼수로 test:latest라고 되어있는 것을
dev 태그로 변경하고 싶으면..
docker tag test:latest test:dev 명령어를 통해 test:dev를 만들어줍니다.
뭔가 맘에 들진 않네요..음..걍 Dockerfile이 깔끔할려나요?? ㅋㅋ
다시 돌아와서 아래처럼 ./gradlew bootBuildImage --imageName=dokcerImage:dev 명령어에 대한 fail에 대한 오류를 봤더니
a-z ??? 소문자만 되는군요!! 오류가 나는 이유가 대문자를 넣어서 였기 때문입니다 ㅋㅋ
다시 명령어를 정비해서 날려보면!!!
./gradlew bootBuildImage --imageName bk-middleware:dev
아래와 같이 빌드가 되어 이미지가 만들어졌음을 알수 있습니다.
Successfully built image 'docker.io/library/bk-middleware:dev'
BUILD SUCCESSFUL in 44s
5 actionable tasks: 1 executed, 4 up-to-date
그런데..44 years ago는 뭘까요? ㅋㅋㅋ
그리고 매번 명령어에 --imageName을 넣어서 하기에는 너무 귀찮습니다.
build.gradle에 아래와 같이 넣어주면 그냥 bootBuildImage만 실행하면 됩니다.
bootBuildImage {
imageName = "bk-middleware:dev"
}
다시 위에서 44년 전에 만들어졌다고 뻥을 치는것을 수정해보자!
createdDate = "now"를 넣어주면 됩니다.
bootBuildImage {
imageName = "idock.daumkakao.io/teri_epi/bk-middleware:dev"
createdDate = "now"
}
결과는? About a minute age로 나오네요 ㅎㅎ
이상 springboot를 사용한다면 이제 bootBuildImage를 사용해서 image를 만들면 됩니다!
Dockerfile 빠이요!
마지막으로 처음에 그냥 bootBuildImage를 돌렸을 때 오류가 난 이유는 프로젝트이름이 대소문자로 되어있어서 오류가..났던 부분입니다.
tag 테스트도 처음에 오류가 난 이유는..대소문자 혼합된 카멜케이스로 이미지명을 지어서입니다.
대소문자에 민감한 친구이니 소문자로 해줍시다!
p.s docker run은?
docker run -d --name middleware -p 9000:8080 -it bk-middleware:dev -e JAVA_OPTS="-Dspring.profiles.active=dev"
docker container ls 를 해보면 아래와 같습니다. -p에서 노출할 포트가 9000 / 스프링부트의 포트가 8080 입니다.
접속은 localhost:9000/블라블라로 접속하면 됩니다.
끝~
'OpenSource > Spring Boot' 카테고리의 다른 글
springboot-RestClient?? (0) | 2024.04.07 |
---|---|
springboot - RestTemplate 적용 (0) | 2024.04.07 |
Field injection is not recommended (0) | 2024.03.21 |
주저리) mvc에서 controller 분리 전략 (0) | 2024.03.09 |
springboot Swagger 설정 (0) | 2024.03.08 |