Skip to content

Commit

Permalink
docs: improves description of Docker bundle steps.
Browse files Browse the repository at this point in the history
  • Loading branch information
outofcoffee committed Nov 17, 2023
1 parent 52ce398 commit c4ccde4
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 10 deletions.
29 changes: 29 additions & 0 deletions docs/deployment_patterns.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,35 @@ $ zip -ur imposter-awslambda.zip config

The `imposter-bundle.zip` file can be [deployed to AWS Lambda](./run_imposter_aws_lambda.md) as normal.

#### Creating a container image bundle

When [deploying using containers](./run_imposter_docker.md), you can add the configuration files into the container image itself.

Let's assume your configuration sits in a directory called `config`.

Here is an example Dockerfile:

```dockerfile
FROM outofcoffee/imposter as imposter

# your custom config
COPY config /opt/imposter/config
```

Build it:

```shell
$ docker build --tag example/mocks .
```

The container image (`example/mocks` in this example), can be [run with Docker](./run_imposter_docker.md) as normal.

```shell
$ docker run --rm -it example/mocks
```

> See [the Docker example project](https://github.com/outofcoffee/imposter/tree/main/examples/docker) for a working example.
## Further reading

- See [Benchmarks](./benchmarks.md) for representative performance tests, including test set up and configuration.
2 changes: 1 addition & 1 deletion examples/docker-healthcheck/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM outofcoffee/imposter as imposter
FROM outofcoffee/imposter

# docker healthcheck using embedded CLI
HEALTHCHECK --interval=5s --timeout=5s --start-period=5s --retries=3 CMD imposter list -qx
12 changes: 12 additions & 0 deletions examples/docker-shell/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM outofcoffee/imposter as imposter

FROM eclipse-temurin:11.0.16_8-jre-focal
COPY --from=imposter /opt/imposter/lib /opt/imposter/lib

# your custom config
COPY config /opt/imposter/config

# optional docker healthcheck
HEALTHCHECK --interval=5s --timeout=5s --start-period=5s --retries=3 CMD curl -f http://localhost:8080/system/status || exit 1

ENTRYPOINT ["java", "-classpath", "/opt/imposter/lib/*", "io.gatehill.imposter.cmd.ImposterLauncher", "--configDir", "/opt/imposter/config"]
20 changes: 20 additions & 0 deletions examples/docker-shell/config/imposter-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
plugin: rest

resources:
- path: "/users"
method: "GET"
response:
statusCode: 200
headers:
Content-Type: "application/json"
content: |
[
{
"id": 1,
"name": "Ada"
},
{
"id": 2,
"name": "Grace"
}
]
8 changes: 8 additions & 0 deletions examples/docker-shell/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
services:
mock-server:
image: mock-server
build: .
ports:
- "8080:8080"
volumes:
- ./config:/opt/imposter/config:ro
10 changes: 1 addition & 9 deletions examples/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,4 @@
FROM outofcoffee/imposter as imposter

FROM eclipse-temurin:11.0.16_8-jre-focal
COPY --from=imposter /opt/imposter/lib /opt/imposter/lib
FROM outofcoffee/imposter

# your custom config
COPY config /opt/imposter/config

# optional docker healthcheck
HEALTHCHECK --interval=5s --timeout=5s --start-period=5s --retries=3 CMD curl -f http://localhost:8080/system/status || exit 1

ENTRYPOINT ["java", "-classpath", "/opt/imposter/lib/*", "io.gatehill.imposter.cmd.ImposterLauncher", "--configDir", "/opt/imposter/config"]

0 comments on commit c4ccde4

Please sign in to comment.