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. 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.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