i decided to use secret manager in gcp for credentials from some external API's so what i did locally to test stuff was gcloud auth application-default login, before that i downloaded gcp cli locally. While deploying app my application context aren't loading. this is a part from build :
here is test some basic context load:
@SpringBootTest
class FlightApiApplicationTests {
@Test
void contextLoads() {
}
}
and here is my docker file :
FROM gradle:7.4.1-jdk17-alpine AS TEMP_BUILD_IMAGE
ENV APP_HOME=/usr/app/
WORKDIR $APP_HOME
COPY build.gradle settings.gradle $APP_HOME
COPY gradle $APP_HOME/gradle
COPY --chown=gradle:gradle . /home/gradle/src
USER root
RUN chown -R gradle /home/gradle/src
RUN gradle build || return 0
COPY . .
RUN gradle clean build
FROM openjdk:17
ENV ARTIFACT_NAME=FlightApi-0.0.1-SNAPSHOT.jar
ENV APP_HOME=/usr/app/
WORKDIR $APP_HOME
COPY --from=TEMP_BUILD_IMAGE $APP_HOME/build/libs/$ARTIFACT_NAME .
EXPOSE 8080
ENTRYPOINT exec java -jar ${ARTIFACT_NAME}
i ll put some dependency as well in gradle :
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation "org.springframework.boot:spring-boot-starter-actuator"
//amadeus implementation
implementation 'com.google.code.gson:gson:2.9.0'
implementation "com.amadeus:amadeus-java:5.9.0"
implementation 'com.google.cloud:spring-cloud-gcp-starter-secretmanager:3.3.0'
implementation platform('com.google.cloud:libraries-bom:25.3.0')
implementation 'com.google.cloud:google-cloud-storage'
compileOnly 'org.projectlombok:lombok'
developmentOnly 'org.springframework.boot:spring-boot-devtools'
annotationProcessor 'org.projectlombok:lombok'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
//Junit
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.2'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.2'
}
Question is should i export in gradle somehow this google default credentials in dockerfile ? Or maybe shall i make some service for authenticating oauth with gcp ? Shouldn't it find automaticaly since im building it in gcp build service. I am open on any ideas, those gcp documentation are quite not understandable for me or just there is too many information about anything. I am using jdk17 this project.
CodePudding user response:
finally i found example and in my case in gcp build i had a problem with google credentials defaults so in tests that i didn't need secret manager i used this flag :
@SpringBootTest(properties = {"spring.cloud.gcp.secretmanager.enabled=false"})