How to run Micronaut App with OAuth2 in Docker

  docker, java, micronaut

I’m trying to run Micronaut App in Docker.
If I run micronaut via gradle on local machine like gradlew run everything is fine.
But if I built an image and run it with docker-compose I get error

Caused by: io.micronaut.context.exceptions.NoSuchBeanException: No bean of type [io.micronaut.security.oauth2.configuration.OauthClientConfiguration] exists for the given qualifier: @Named('fb'). Make sure the bean is not disabled by bean requirements (enable trace logging for 'io.micronaut.context.condition' to check) and if the bean is enabled then ensure the class is declared a bean and annotation processing is enabled (for Java and Kotlin the 'micronaut-inject-java' dependency should be configured as an annotation processor).

Dockerfile:

WORKDIR /app
COPY . /app
RUN ./gradlew dockerBuild
RUN ./gradlew build -x test
FROM openjdk:14-alpine
COPY --from=build /app/build/libs/server-*-all.jar server.jar
EXPOSE 8080
CMD ["java", "-Dcom.sun.management.jmxremote", "-Xmx128m", "-jar", "server.jar"]

Source: Docker Questions

LEAVE A COMMENT