-
Using
- Importing Services & APIs
- Comparison to alternatives
- OpenAPI Mocking and Testing
- Swagger Mocking and Testing
- AsyncAPI Mocking and Testing
- Postman usage for Microcks
- gRPC Mocking and Testing
- GraphQL Mocking and Testing
- SoapUI Mocking and Testing
- Http Archive usage for Microcks
- Using exposed mocks
- Getting direct API
- Testing with Microcks
- Advanced topics
- Organizing repository
- Templating mock responses
- Dispatcher & dispatching rules
- Microcks APIMetadata
- Monitoring & Observability
- Installing
- Automating
- Administrating
- Guides
External Dependencies
🗓️ Last updated on October 26, 2023 | 2 | Improve this pageIntroduction
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
- Put your Jar files into a dedicated folder (i.e. ./lib)
- 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
- Restart and see the Jar files appended to the application classpath.
- You can directly use the Java or Groovy classes from your Jar in a SCRIPT
Pure Kubernetes method
- Put your Jar files into a dedicated folder (i.e. ./lib)
- 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
- Build, tag and push your docker image in your registry of choice
- Reference this docker image in either values.yml for Helm or MicrocksInstall CR for Operator
- Redeploy and see the Jar files appended to the application classpath on pod startup
- 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