I'm doing a Dockerfile to construct a Gradle program at Cloud, I'm having an issue at the command RUN mv build/libs/ComponentName-?.?.?.jar build/libs/app.jar
that says that the directory build/libs/app.jar
doesn't exist.
I already looking in internet trying to find solutions and all said that is basically a Syntax problem but not really what I need, I'm new in all of this of Docker so I'm not sure what to do.
This is the dockerfile block:
FROM maven:3.8.5-openjdk-17 as builder
RUN mkdir /app
WORKDIR /app
ARG ARTIFACTORY_USER
ARG ARTIFACTORY_PASSWORD
COPY . /app
RUN ./gradlew build
RUN mv build/libs/Component-Name-?.?.?.jar build/libs/app.jar
RUN ls -l build/libs
FROM registry.access.redhat.com/ubi9/openjdk-17-runtime:latest
USER 0
RUN mkdir /app
RUN chown -R 185:0 /app
RUN microdnf update -y
USER 185
WORKDIR /app
ARG APP_NAME=Component-Name-k8s
COPY --from=builder /app/build/libs/app.jar /app
# Start service
EXPOSE 8093
ENTRYPOINT java -jar app.jar
And this is the error that I'm recieving:
ERROR: process "/bin/sh -c mv build/libs/Component-Name-?.?.?.jar build/libs/app.jar" did not complete successfully: exit code: 1
------
> [builder 6/7] RUN mv build/libs/Component-Name-?.?.?.jar build/libs/app.jar:
target 'build/libs/app.jar' is not a directory
------
WARNING: No output specified with docker-container driver. Build result will only remain in the build cache. To push result image into registry use --push or to load image into docker use --load
Dockerfile:8
--------------------
6 | COPY . /app
7 | RUN ./gradlew build
8 | >>> RUN mv build/libs/Component-Name-?.?.?.jar build/libs/app.jar
9 | RUN ls -l build/libs
10 |
--------------------
ERROR: failed to solve: process "/bin/sh -c mv build/libs/Component-Name-?.?.?.jar build/libs/app.jar" did not complete successfully: exit code: 1
You probably have multiple files that match build/libs/Component-Name-?.?.?.jar
.
In that case, you give 3 or more arguments to mv
.
If you give 3 or more arguments to mv
, the last argument has to be an existing diretory into which all other arguments are moved.
To make it work with wildcards, make sure to only match one file, for example by deleting build/libs/Component-Name-?.?.?.jar
before running the build, or similar.