Sarah Javier-Sampan
07/03/2024, 2:58 PMwiremock/
├── dir1/
│ └── stubs/
│ ├── mappings
│ ├── __files
│ └── __admin
└── dir2/
└── stubs/
├── mappings
├── __files
└── __admin
I would like to ask how I can set up different directories in a Dockerfile with different ports using wiremock/wiremock:latest as image. Thanks!Lee Turner
07/04/2024, 2:58 PMstubs
directories?Lee Turner
07/04/2024, 2:59 PMdir1
and dir2
directories?Sarah Javier-Sampan
07/04/2024, 3:19 PM# Use the official WireMock image as the base image
FROM wiremock/wiremock:latest
# Set the working directory inside the container
WORKDIR /home/wiremock
# Copy stubs for different data sources into the container
COPY wiremock/dir1/stubs /home/wiremock/dir1
COPY wiremock/dir2/stubs /home/wiremock/dir2
# Copy the custom entrypoint script into the container
COPY docker-entrypoint.sh /docker-entrypoint.sh
# Make the entrypoint script executable
RUN chmod +x /docker-entrypoint.sh
# Expose the necessary ports
EXPOSE 8081 8082
# Set the custom entrypoint
ENTRYPOINT ["/docker-entrypoint.sh"]
Sarah Javier-Sampan
07/04/2024, 3:20 PM#!/bin/sh
set -e
# Function to start WireMock with templating
start_wiremock() {
local port="$1"
local root_dir="$2"
# Start WireMock with given port and root directory
echo "Starting WireMock on port $port with root directory $root_dir"
java -jar /var/wiremock/lib/wiremock-standalone.jar --port "$port" --root-dir "$root_dir" --global-response-templating --disable-gzip --verbose
}
# Start WireMock for dir1
start_wiremock 8081 "/home/wiremock/dir1" &
# Start WireMock for dir2
start_wiremock 8082 "/home/wiremock/dir2" &
# Wait for all background processes to finish
wait