preloader

External Dependencies

🗓️ Last updated on October 26, 2023 | 2 | Improve this page

Introduction

Microcks is able to run Groovy scripts contained in your API mocks. Your scripts may need external dependencies that are not present in Microcks. In the next section, you will find two approaches depending on whether you are using docker-compose or pure Kubernetes installation to provide such dependencies for your scripts.

Docker-compose method

The solution is similar for Podman-compose

  1. Put your Jar files into a dedicated folder (i.e. ./lib)
  2. Add the following lines into your compose file for the Microcks container:
   volumes:
      - ./lib:/deployments/lib
    environment:
      - JAVA_OPTIONS=-Dloader.path=/deployments/lib
      - JAVA_MAIN_CLASS=org.springframework.boot.loader.PropertiesLauncher
      - JAVA_APP_JAR=app.jar
  1. Restart and see the Jar files appended to the application classpath.
  2. You can directly use the Java or Groovy classes from your Jar in a SCRIPT

Pure Kubernetes method

  1. Put your Jar files into a dedicated folder (i.e. ./lib)
  2. Create a new Docker file that extends the Microcks provided image and embeds your libs
FROM quay.io/microcks/microcks-uber:latest

# Copy libraries jar files
COPY lib /deployments/lib

ENV JAVA_OPTIONS=-Dloader.path=/deployments/lib
ENV JAVA_MAIN_CLASS=org.springframework.boot.loader.PropertiesLauncher
ENV JAVA_APP_JAR=app.jar
  1. Build, tag and push your docker image in your registry of choice
  2. Reference this docker image in either values.yml for Helm or MicrocksInstall CR for Operator
  3. Redeploy and see the Jar files appended to the application classpath on pod startup
  4. You can directly use the Java or Groovy classes from your Jar in a SCRIPT

Still Didn’t Find Your Answer?

Join our community and get the help you need. Engage with other members, ask questions, and share knowledge to resolve your queries and expand your understanding.

Join the community