Hello, I currently have this directory setup: ```w...
# help
s
Hello, I currently have this directory setup:
Copy code
wiremock/
    ├── 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!
l
Could you create a docker compose file in each of the
stubs
directories?
Or a single docker compose file at the top level with multiple services in mapping the different
dir1
and
dir2
directories?
s
Thanks Lee, I have resolved it with these: Dockerfile
Copy code
# 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"]
🙌 1
docker-entrypoint.sh
Copy code
#!/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
🙌 1