Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/content/docs/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,15 @@ The zero-arg run is in-memory. To persist across restarts, use Compose or a **na
identical on every OS:

```bash
docker compose up # stubs live in ./mappings, next to you
docker run -p 8080:8080 -v mockifyr-data:/work/mappings ghcr.io/omercelikdev/mockifyr # named volume
docker compose up # stubs live in ./mappings, next to you
docker run -p 8080:8080 -v mockifyr-data:/work ghcr.io/omercelikdev/mockifyr # named volume
```

Mount **`/work`**, not just `/work/mappings` — the file store also keeps
[environment configuration](/environments/), response body files and gRPC descriptors under `/work`,
and a mappings-only mount silently loses those when the container is recreated. See
[Persistence → Docker](/persistence/#docker) for the full layout and a .NET Aspire example.

### Preload stub files from your host

To load a folder of WireMock `*.json` files, bind-mount it. Only the path syntax differs per shell:
Expand Down
37 changes: 29 additions & 8 deletions src/content/docs/persistence.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ whether you run in-memory or against PostgreSQL.
| Redis | `--redis <connstr>` | Hash `mockifyr:stubs:{tenant}` keyed by stub id |

```bash
docker run -p 8080:8080 -v "$PWD/mappings:/work/mappings" ghcr.io/omercelikdev/mockifyr
docker run -p 8080:8080 -v mockifyr-data:/work ghcr.io/omercelikdev/mockifyr
docker compose -f docker-compose.postgres.yml up
docker compose -f docker-compose.redis.yml up
```
Expand Down Expand Up @@ -71,25 +71,46 @@ admin mutation persists — there is no way to create a stub that is deliberatel

## Docker

The image bakes `--root-dir /work`, so stubs load from and persist to `/work/mappings`. Mount something
there and they survive:
The image bakes `--root-dir /work`, so everything in the table above lives under `/work` — stubs in
`/work/mappings`, environments in `/work/environments`, and so on. Mount a volume at **`/work`** and
all of it survives restarts *and* container recreation:

```bash
# bind mount — stubs live in ./mappings on your host
docker run -p 8080:8080 -v "$PWD/mappings:/work/mappings" ghcr.io/omercelikdev/mockifyr
# named volume — stubs, environments, __files and grpc descriptors all survive
docker run -p 8080:8080 -v mockifyr-data:/work ghcr.io/omercelikdev/mockifyr

# named volume — Docker manages the storage
docker run -p 8080:8080 -v mockifyr-data:/work/mappings ghcr.io/omercelikdev/mockifyr
# plus a bind overlay for the stubs you edit by hand — they live in ./mappings on your host
docker run -p 8080:8080 -v mockifyr-data:/work -v "$PWD/mappings:/work/mappings" ghcr.io/omercelikdev/mockifyr
```

:::caution
Mounting **only** `/work/mappings` keeps your stubs but silently loses the environment
configuration — and `__files/`, `grpc/` — every time the container is recreated.
:::

The repository ships three Compose files:

| File | What it sets up |
|------|-----------------|
| `docker-compose.yml` | Bind mount |
| `docker-compose.yml` | Named volume at `/work` + `./mappings` bind overlay |
| `docker-compose.postgres.yml` | PostgreSQL service, `--change-feed`, healthchecks, named volume |
| `docker-compose.redis.yml` | Redis service, `--change-feed`, healthchecks, named volume |

### .NET Aspire

Aspire **recreates containers on every app-host run**, so a file-backed Mockifyr without a volume
resets each run — imported stubs and environment configuration included. Mount a named volume at
`/work` (and optionally keep the container alive between runs):

```csharp
var mockifyr = builder.AddContainer("mockifyr", "ghcr.io/omercelikdev/mockifyr")
.WithHttpEndpoint(port: 8080, targetPort: 8080)
.WithVolume("mockifyr-data", "/work") // survives restarts and recreation
.WithLifetime(ContainerLifetime.Persistent); // optional: reuse the container across runs
```

Or hand persistence to a durable datastore instead: `.WithArgs("--postgres", connectionString)`.

## Git sync

Git sync is layered on top of the **root-dir working copy** — it commits, pushes and pulls the same
Expand Down