Skip to content

Reference architecture: Focus on docker flow for dev phase

Notifications You must be signed in to change notification settings

li-tian-33/Microservice-Dockerflow

Repository files navigation

Java Microservice Docker Flow

Reference architecture: Try to research best dev experience of docker flow in dev phase. Get all benefits docker brings, avoid the disadvantage of debug container instance.

  • Add smart remote debug configuration to seamless debug in docker container, just like debug normal java process.
  • By using jvm built-in support of JAVA_TOOL_OPTIONS options in docker-compose.yaml, so no need to modify dockerfile to support remote debug, use the exact same dockerfile for both production and local environment.

Run:

Just run docker-compose up, all demo service will be startup.

Debug:

  • By add the below JAVA_TOOL_OPTIONS in the docker environment section of the docker-compose.yaml file to support remote debug in container.
  employee-service:
    build:
      context: ./employee
    environment:
      - JAVA_TOOL_OPTIONS=-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5006
    ports:
      - 9090:9090
      - 5006:5006
    depends_on:
      - config-center
  • Setup up remote debug in IDE: By using remote debug configuration, the debug process will automatically run mvn package, re-build docker image and re-create docker instance for the service and then automatically attach to the new container instance for debug.

Demo setting

  1. Set Before launch to add mvn package command.
  2. Set Docker-compose to run below command in root source directory, e.g. use employee-service as example
docker-compose up --build -d --no-deps employee-service
  1. Update remote debug port to match the exposed port in docker-compose.yaml.

Notes:

Because of the time factor, Department,Organization services are not added docker or docker-compose support.

About

Reference architecture: Focus on docker flow for dev phase

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published