I am trying to run my Spring Boot application on Digitalocean App Platform with docker. I want to configure auto-deployment via github, however, I keep getting the same error.
Keep in mind that my Spring Boot app runs locally and in production on Heroku. It also works with my local docker. So, it is not an issue with the project, but configuration.
Here is my Dockerfile:
_# Use the official gradle image as the base image
_FROM gradle:7.4.0-jdk17 AS _build
_
_# Set the working directory in the container
_WORKDIR /app
_# Copy the build files to the container
_COPY ./build.gradle .
COPY ./src ./src
_# Build the application using Gradle
_RUN gradle build --no-daemon
_# Create a new stage for the final image
_FROM eclipse-temurin:17-jdk-alpine
_# Set the working directory in the container
_WORKDIR /app
_# Copy the built JAR file from the previous stage
_COPY --from=_build_ /app/build/libs/*.jar app.jar
_# Configure the container to run the Spring Boot application
_ENTRYPOINT ["java", "-jar", "/app/app.jar"]
And here is the error I keep getting:
[2023-07-14 21:40:08] │ ✔ cloned repo to /.app_platform_workspace
[2023-07-14 21:40:08] ╰────────────────────────────────────────╼
[2023-07-14 21:40:08]
[2023-07-14 21:40:08] › configuring build-time app environment variables:
[2023-07-14 21:40:08] serviceAccountEmail mysqlPassword mysqlHost gptKey
[2023-07-14 21:40:08] ╭──────────── dockerfile build ───────────╼
[2023-07-14 21:40:08] │ › using dockerfile /.app_platform_workspace/Dockerfile
[2023-07-14 21:40:08] │ › using build context /.app_platform_workspace//
[2023-07-14 21:40:08] │
[2023-07-14 21:40:09] │ INFO[0000] Resolved base name gradle:7.4.0-jdk17 to build
[2023-07-14 21:40:09] │ INFO[0000] Retrieving image manifest gradle:7.4.0-jdk17
[2023-07-14 21:40:09] │ INFO[0000] Retrieving image library/gradle:7.4.0-jdk17 from registry mirror <registry-uri-0>
[2023-07-14 21:40:10] │ INFO[0001] Retrieving image manifest gradle:7.4.0-jdk17
[2023-07-14 21:40:10] │ INFO[0001] Returning cached image manifest
[2023-07-14 21:40:10] │ INFO[0001] Retrieving image manifest eclipse-temurin:17-jdk-alpine
[2023-07-14 21:40:10] │ INFO[0001] Retrieving image library/eclipse-temurin:17-jdk-alpine from registry mirror <registry-uri-1>
[2023-07-14 21:40:11] │ INFO[0002] Retrieving image manifest eclipse-temurin:17-jdk-alpine
[2023-07-14 21:40:11] │ INFO[0002] Returning cached image manifest
[2023-07-14 21:40:11] │ INFO[0002] Built cross stage deps: map[0:[/app/build/libs/*.jar]]
[2023-07-14 21:40:11] │ INFO[0002] Retrieving image manifest gradle:7.4.0-jdk17
[2023-07-14 21:40:11] │ INFO[0002] Returning cached image manifest
[2023-07-14 21:40:11] │ INFO[0002] Retrieving image manifest gradle:7.4.0-jdk17
[2023-07-14 21:40:11] │ INFO[0002] Returning cached image manifest
[2023-07-14 21:40:11] │ INFO[0002] Executing 0 build triggers
[2023-07-14 21:40:11] │ INFO[0002] Building stage 'gradle:7.4.0-jdk17' [idx: '0', base-idx: '-1']
[2023-07-14 21:40:11] │ INFO[0002] Checking for cached layer <registry-uri-2>
[2023-07-14 21:40:11] │ INFO[0002] Using caching version of cmd: RUN gradle build --no-daemon
[2023-07-14 21:40:11] │ INFO[0002] Unpacking rootfs as cmd COPY ./build.gradle . requires it.
[2023-07-14 21:40:28] │ INFO[0019] Initializing snapshotter ...
[2023-07-14 21:40:28] │ INFO[0019] Taking snapshot of full filesystem...
[2023-07-14 21:40:32] │ INFO[0024] WORKDIR /app
[2023-07-14 21:40:32] │ INFO[0024] Cmd: workdir
[2023-07-14 21:40:32] │ INFO[0024] Changed working directory to /app
[2023-07-14 21:40:32] │ INFO[0024] Creating directory /app
[2023-07-14 21:40:32] │ INFO[0024] Taking snapshot of files...
[2023-07-14 21:40:32] │ INFO[0024] COPY ./build.gradle .
[2023-07-14 21:40:32] │ INFO[0024] Taking snapshot of files...
[2023-07-14 21:40:32] │ INFO[0024] COPY ./src ./src
[2023-07-14 21:40:32] │ INFO[0024] Taking snapshot of files...
[2023-07-14 21:40:33] │ INFO[0024] RUN gradle build --no-daemon
[2023-07-14 21:40:33] │ INFO[0024] Found cached layer, extracting to filesystem
[2023-07-14 21:40:41] │ INFO[0032] Saving file app/build/libs/app-plain.jar for later use
[2023-07-14 21:40:41] │ INFO[0032] Saving file app/build/libs/app.jar for later use
[2023-07-14 21:40:41] │ INFO[0032] Deleting filesystem...
[2023-07-14 21:40:41] │ INFO[0033] Retrieving image manifest eclipse-temurin:17-jdk-alpine
[2023-07-14 21:40:41] │ INFO[0033] Returning cached image manifest
[2023-07-14 21:40:41] │ INFO[0033] Retrieving image manifest eclipse-temurin:17-jdk-alpine
[2023-07-14 21:40:41] │ INFO[0033] Returning cached image manifest
[2023-07-14 21:40:41] │ INFO[0033] Executing 0 build triggers
[2023-07-14 21:40:41] │ INFO[0033] Building stage 'eclipse-temurin:17-jdk-alpine' [idx: '1', base-idx: '-1']
[2023-07-14 21:40:41] │ INFO[0033] Unpacking rootfs as cmd COPY --from=build /app/build/libs/*.jar app.jar requires it.
[2023-07-14 21:40:46] │ INFO[0037] Initializing snapshotter ...
[2023-07-14 21:40:46] │ INFO[0037] Taking snapshot of full filesystem...
[2023-07-14 21:40:47] │ INFO[0039] WORKDIR /app
[2023-07-14 21:40:47] │ INFO[0039] Cmd: workdir
[2023-07-14 21:40:47] │ INFO[0039] Changed working directory to /app
[2023-07-14 21:40:47] │ INFO[0039] Creating directory /app
[2023-07-14 21:40:47] │ INFO[0039] Taking snapshot of files...
[2023-07-14 21:40:47] │ INFO[0039] COPY --from=build /app/build/libs/*.jar app.jar
[2023-07-14 21:40:47] │ INFO[0039] Resolving srcs [/app/build/libs/*.jar]...
[2023-07-14 21:40:47] │ error building image: error building stage: failed to execute command: resolving src: when specifying multiple sources in a COPY command, destination must be a directory and end in '/'
[2023-07-14 21:40:47] │
[2023-07-14 21:40:47] │ command exited with code 1
[2023-07-14 21:40:47] │
[2023-07-14 21:40:48] │ ✘ build failed
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
Enter your email to get $200 in credit for your first 60 days with DigitalOcean.
New accounts only. By submitting your email you agree to our Privacy Policy.
Hi there,
I believe that the error is related to the following line in your Dockerfile:
The error message is telling you that when using a wildcard (
*
) in aCOPY
command, the destination must be a directory and end with a/
.Since you seem to be copying a single JAR file, you can update this line to copy that specific file. If your build produces a single JAR file, you can identify the file and update the
COPY
command to copy that specific file. Here’s how you might change theCOPY
command:Make sure to replace
app.jar
with the actual name of your JAR file if it’s different.Alternatively, if you want to copy all JAR files from that directory, you could make sure the destination is a directory by appending a
/
:This would copy all JAR files into the
/app/
directory in the image.After making these changes, try to rebuild and redeploy your application.
Hope that this helps!
Best,
Bobby