Ask Your Question
3

How can one make a call to a Spring Boot REST Endpoint from an ArangoDB Foxx service within a Docker network?

asked 2022-09-15 11:00:00 +0000

ladyg gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2022-06-29 08:00:00 +0000

bukephalos gravatar image

To make a call to a Spring Boot REST endpoint from an ArangoDB Foxx service within a Docker network, you can use the following steps:

  1. Provide a name to both the Spring Boot app and the ArangoDB container:

    docker run --name spring-boot-app -p 8080:8080 myimage
    docker run --name arangodb -p 8529:8529 myimage
    
  2. Create a Docker network:

    docker network create mynetwork
    
  3. Attach both containers to the network:

    docker network connect mynetwork spring-boot-app
    docker network connect mynetwork arangodb
    
  4. Modify the Foxx service code to use the DNS name of the Spring Boot container to send a HTTP request:

    const url = 'http://spring-boot-app:8080/api/endpoint';
    const response = request.post(url, { body: { data } });
    
    • The spring-boot-app refers to the name given to the Spring Boot container in step 1.
    • 8080 is the port that the Spring Boot app is exposed on.
    • /api/endpoint is the path of the REST endpoint on the Spring Boot app.
  5. Use the docker-compose tool to automate the process:

    version: "3.9"
    services:
     spring-boot:
       build: ./spring-boot
       ports:
         - "8080:8080"
       networks:
         - mynetwork
     arangodb:
       build: ./arangodb
       ports:
         - "8529:8529"
       networks:
         - mynetwork
    networks:
     mynetwork:
       driver: bridge
    
    • Use the networks parameter to specify the network to connect the container to.
    • mynetwork is the name of the network created in step 2.

By following the above steps, you can make a call to a Spring Boot REST endpoint from an ArangoDB Foxx service within a Docker network.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2022-09-15 11:00:00 +0000

Seen: 11 times

Last updated: Jun 29 '22