Code Monkey home page Code Monkey logo

Comments (4)

ThomasVitale avatar ThomasVitale commented on July 30, 2024

Hi @lucamoroldo, could you check if host.docker.internal can be resolved to an IP address in your WSL2 environment?

$ host host.docker.internal
host.docker.internal has address 127.0.0.1

That hostname should be configured automatically when installing Docker Desktop. And it should result in the following configuration in the /etc/hosts file within your WSL2 environment.

127.0.0.1    host.docker.internal

If it's not there, could you try adding that manually (vim /etc/hosts) and then try again running Edge Service?

from cloud-native-spring-in-action.

ThomasVitale avatar ThomasVitale commented on July 30, 2024

Since there hasn't been any activity in the past few months, I'm closing this issue, but feel free to open a new one should you still have some issues about the network setup. Thanks!

from cloud-native-spring-in-action.

ongiant avatar ongiant commented on July 30, 2024

@lucamoroldo Have you solved that problem? I met the same problem too. Anyone could help me?

from cloud-native-spring-in-action.

ongiant avatar ongiant commented on July 30, 2024

Solution:

Environment

  • docker engine (not docker desktop) version: 24.0.7
  • OS: Manjaro Linux
  • Steps

    1. You should add host.docker.internal to /etc/hosts. Your /etc/hosts file on your host machine should looks like this:
      
      127.0.0.1  localhost  host.docker.internal
      

      rather than this:

      
      127.0.0.1 localhost
      127.0.0.1 host.docker.internal
      
    2. Add host.docker.internal to no_proxy and NO_PROXY environment varaible (~/.bashrc or ~/.zshrc on host machine).
    3. Add host.docker.internal to proxy Exceptions in your host Chrome browser. It should look like host.docker.internal,*.yahoo.com
    4. Your final docker-compose.yml file should look like this (Note the addition of host.docker.internal:host-gateway in the extra_hosts section for both catalog_service and edge-service):
      docker-compose.yml
      
      version: '3.8'
      services:
        catalog-service:
          depends_on:
            - fluent-bit
            - polar-keycloak
            - polar-postgres
            - tempo
          image: catalog-service
          container_name: catalog-service
          ports:
            - '9001:9001'
            - '8001:8001'
          environment:
            - BPL_JVM_THREAD_COUNT=50
            - BPL_DEBUG_ENABLED=true
            - BPL_DEBUG_PORT=8001
            - >-
              JAVA_TOOL_OPTIONS=-javaagent:/workspace/BOOT-INF/lib/opentelemetry-javaagent-1.32.0.jar
            - OTEL_SERVICE_NAME=catalog-service
            - 'OTEL_EXPORTER_OTLP_ENDPOINT=http://tempo:4317'
            - OTEL_METRICS_EXPORTER=none
            - 'SPRING_CLOUD_CONFIG_URI=http://config-service:8888'
            - >-
              SPRING_DATASOURCE_URL=jdbc:postgresql://polar-postgres:5432/polardb_catalog
            - SPRING_PROFILES_ACTIVE=testdata
            - >-
              SPRING_SECURITY_OAUTH2_RESOURCESERVER_JWT_ISSUER_URI=http://host.docker.internal:8080/realms/PolarBookshop
          extra_hosts:
            - 'host.docker.internal:host-gateway'
          logging:
            driver: fluentd
            options:
              fluentd-address: '127.0.0.1:24224'
        edge-service:
          depends_on:
            - fluent-bit
            - polar-keycloak
            - polar-redis
            - polar-ui
            - tempo
          image: edge-service
          container_name: edge-service
          ports:
            - '9000:9000'
            - '8000:8000'
          environment:
            - BPL_DEBUG_ENABLED=true
            - BPL_DEBUG_PORT=8000
            - 'CATALOG_SERVICE_URL=http://catalog-service:9001'
            - >-
              JAVA_TOOL_OPTIONS=-javaagent:/workspace/BOOT-INF/lib/opentelemetry-javaagent-1.32.0.jar
            - OTEL_SERVICE_NAME=edge-service
            - 'OTEL_EXPORTER_OTLP_ENDPOINT=http://tempo:4317'
            - OTEL_METRICS_EXPORTER=none
            - 'ORDER_SERVICE_URL=http://order-service:9002'
            - 'SPA_URL=http://polar-ui:9004'
            - 'SPRING_CLOUD_CONFIG_URI=http://config-service:8888'
            - SPRING_REDIS_HOST=polar-redis
            - >-
              SPRING_SECURITY_OAUTH2_CLIENT_PROVIDER_KEYCLOAK_ISSUER_URI=http://host.docker.internal:8080/realms/PolarBookshop
          extra_hosts:
            - 'host.docker.internal:host-gateway'
          logging:
            driver: fluentd
            options:
              fluentd-address: '127.0.0.1:24224'
        polar-keycloak:
          image: 'quay.io/keycloak/keycloak:23.0'
          container_name: polar-keycloak
          command: start-dev --import-realm
          volumes:
            - './keycloak:/opt/keycloak/data/import'
          environment:
            - KEYCLOAK_ADMIN=user
            - KEYCLOAK_ADMIN_PASSWORD=password
          ports:
            - '8080:8080'
      

    In the end

    • I believe the setting SPRING_SECURITY_OAUTH2_CLIENT_PROVIDER_KEYCLOAK_ISSUER_URI=http://host.docker.internal:8080/realms/PolarBookshop is passed from the back-end Spring Boot application to the front-end. This will prompt the browser to redirect to http://host.docker.internal:8080/realms/PolarBookshop when you click the login button on the webpage. Is it right?

    from cloud-native-spring-in-action.

    Related Issues (20)

    Recommend Projects

    • React photo React

      A declarative, efficient, and flexible JavaScript library for building user interfaces.

    • Vue.js photo Vue.js

      🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

    • Typescript photo Typescript

      TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

    • TensorFlow photo TensorFlow

      An Open Source Machine Learning Framework for Everyone

    • Django photo Django

      The Web framework for perfectionists with deadlines.

    • D3 photo D3

      Bring data to life with SVG, Canvas and HTML. 📊📈🎉

    Recommend Topics

    • javascript

      JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

    • web

      Some thing interesting about web. New door for the world.

    • server

      A server is a program made to process requests and deliver data to clients.

    • Machine learning

      Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

    • Game

      Some thing interesting about game, make everyone happy.

    Recommend Org

    • Facebook photo Facebook

      We are working to build community through open source technology. NB: members must have two-factor auth.

    • Microsoft photo Microsoft

      Open source projects and samples from Microsoft.

    • Google photo Google

      Google ❤️ Open Source for everyone.

    • D3 photo D3

      Data-Driven Documents codes.