DevOps/Docker

COPY ${JAR_FILE} app.jarWhen using COPY with more than one source file, the destination must be a directory and end with a /

잔망루피 2023. 5. 5. 01:10
반응형
COPY ${JAR_FILE} app.jarWhen using COPY with more than one source file, the destination must be a directory and end with a /

깃헙 액션의 CD 워크플로우를 실행하던 중에 다음과 같은 에러가 떴다.

하나 이상의 source 파일이 있을 시 destination이 {폴더명}/이 되어야 한다는 의미다.

build/libs에는 jar 파일이 2개가 있었다.

내가 원하는 건 *-SNAPSHOT.jar뿐이다.

 

FROM openjdk:11

ARG JAR_FILE=./build/libs/*-SNAPSHOT.jar
COPY ${JAR_FILE} app.jar

EXPOSE 8000
ENTRYPOINT ["java", "-jar","/app.jar"]

위와 같이 Dockerfile에서 ARG JAR_FILE=./build/libs/*.jar ➡️ ARG JAR_FILE=./build/libs/*-SNAPSHOT.jar로 수정

아니면, 아래와 같이 *-plain.jar 파일이 생성되지 않도록 설정할 수 있다.

// gradle을 사용할 경우 build.gradle에 추가
tasks.named("jar") {
	enabled = false
}

 

 

 


참고 👇

https://docs.docker.com/engine/reference/builder/#copy

 

Dockerfile reference

 

docs.docker.com

 

https://docs.spring.io/spring-boot/docs/current/gradle-plugin/reference/htmlsingle/#packaging-executable.and-plain-archives

 

Spring Boot Gradle Plugin Reference Guide

To manage dependencies in your Spring Boot application, you can either apply the io.spring.dependency-management plugin or use Gradle’s native bom support. The primary benefit of the former is that it offers property-based customization of managed versio

docs.spring.io

 

 

반응형

'DevOps > Docker' 카테고리의 다른 글

[Error] Unable to access jarfile home/ubuntu/{jar파일명}.jar  (0) 2024.01.07
Ubuntu에 Docker 설치  (1) 2024.01.07
[Error] docker endpoint for "default" not found  (0) 2023.05.02
Docker  (0) 2023.04.19
Docker Compose  (0) 2022.05.05