I follow the book Cloud Native Spring in Action and I encountered this error. I used the Paketo Buildpacks to build the image using ./gradlew bootBuildImage. Full source code: https://github.com/arkadisahakyan/catalog-service/
Full error message:
catalog-service | unable to determine class count
catalog-service | unable to walk /workspace
catalog-service | open /workspace/BOOT-INF/classes/db: permission denied
catalog-service | ERROR: failed to launch: exec.d: failed to execute exec.d file at path '/layers/paketo-buildpacks_bellsoft-liberica/helper/exec.d/memory-calculator': exit status 1
docker-compose.yml (runs the main Spring Boot application and the database image)
version: "3.8"
services:
catalog-service:
depends_on:
- polar-postgres
image: "ghcr.io/arkadisahakyan/catalog-service"
container_name: "catalog-service"
ports:
- 9001:9001
environment:
- BPL_JVM_THREAD_COUNT=50
- SPRING_DATASOURCE_URL=jdbc:postgresql://polar-postgres:5432/polardb_catalog
- SPRING_PROFILES_ACTIVE=testdata
polar-postgres:
image: "postgres:14.4"
container_name: "polar-postgres"
ports:
- 5432:5432
environment:
- POSTGRES_USER=user
- POSTGRES_PASSWORD=password
- POSTGRES_DB=polardb_catalog
build.gradle (all the same as in the book)
plugins {
id 'org.springframework.boot' version '2.7.18'
id 'io.spring.dependency-management' version '1.0.15.RELEASE'
id 'java'
}
group = 'com.polarbookshop'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '17'
description = 'Provides functionality for managing the books in the catalog.'
configurations {
compileOnly {
extendsFrom annotationProcessor
}
}
repositories {
mavenCentral()
}
ext {
set('springCloudVersion', "2021.0.9")
set('testcontainersVersion', "1.19.8")
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-actuator'
implementation 'org.springframework.boot:spring-boot-starter-data-jdbc'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-validation'
implementation 'org.springframework.cloud:spring-cloud-starter-config'
implementation 'org.springframework.retry:spring-retry'
implementation 'org.flywaydb:flyway-core'
runtimeOnly 'org.postgresql:postgresql'
annotationProcessor "org.springframework.boot:spring-boot-configuration-processor"
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'org.springframework.boot:spring-boot-starter-webflux'
testImplementation 'org.testcontainers:postgresql'
}
dependencyManagement {
imports {
mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
mavenBom "org.testcontainers:testcontainers-bom:${testcontainersVersion}"
}
}
bootRun {
systemProperty 'spring.profiles.active', 'testdata'
}
bootBuildImage {
builder = "docker.io/paketobuildpacks/builder-jammy-base"
imageName = "${project.name}"
environment = ["BP_JVM_VERSION": "17"]
docker {
publishRegistry {
username = project.findProperty("registryUsername")
password = project.findProperty("registryToken")
url = project.findProperty("registryUrl")
}
}
}
tasks.named('test') {
useJUnitPlatform()
}
I tried to run both the local and remote images but the error is the same. Remote package:
docker pull ghcr.io/arkadisahakyan/catalog-service:latest
What is the source of the problem and how to fix it?
WORKDIR workspacethe directory will be created at/workspacewhich usually only has access by the userrootbut you are later running the app as the userspring. So depending on how you run your docker compose, if its run as root, or not. Or you run thechowncommand in the dockerfile changing the ownershop of the folder workspace to the user spring.