Skip to content

Commit 0535f75

Browse files
Merge branch 'main' into pr/digital88/926
2 parents d71d67b + 5810da8 commit 0535f75

File tree

90 files changed

+1656
-1264
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

90 files changed

+1656
-1264
lines changed

.eslintignore

Lines changed: 0 additions & 1 deletion
This file was deleted.

.eslintrc.js

Lines changed: 0 additions & 10 deletions
This file was deleted.

.prettierrc

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
{
2-
"printWidth": 120,
3-
"plugins": [
4-
"prettier-plugin-organize-imports"
5-
]
6-
}
2+
"printWidth": 120,
3+
"trailingComma": "es5",
4+
"plugins": ["prettier-plugin-organize-imports"]
5+
}

docs/configuration.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,15 @@ Configuration of the Docker daemon:
3232

3333
Configuration of Testcontainers and its behaviours:
3434

35-
| Variable | Example | Description |
36-
| ------------------------------------- | ------------------------- | ---------------------------------------- |
37-
| TESTCONTAINERS_HOST_OVERRIDE | tcp://docker:2375 | Docker's host on which ports are exposed |
38-
| TESTCONTAINERS_DOCKER_SOCKET_OVERRIDE | /var/run/docker.sock | Path to Docker's socket used by ryuk |
39-
| TESTCONTAINERS_RYUK_PRIVILEGED | true | Run ryuk as a privileged container |
40-
| TESTCONTAINERS_RYUK_DISABLED | true | Disable ryuk |
41-
| TESTCONTAINERS_RYUK_PORT | 65515 | Set ryuk host port (not recommended) |
42-
| TESTCONTAINERS_SSHD_PORT | 65515 | Set SSHd host port (not recommended) |
43-
| TESTCONTAINERS_HUB_IMAGE_NAME_PREFIX | mycompany.com/registry | Set default image registry |
44-
| RYUK_CONTAINER_IMAGE | testcontainers/ryuk:0.5.1 | Custom image for ryuk |
45-
| SSHD_CONTAINER_IMAGE | testcontainers/sshd:1.1.0 | Custom image for SSHd |
46-
| TESTCONTAINERS_REUSE_ENABLE | true | Enable reusable containers |
35+
| Variable | Example | Description |
36+
| ------------------------------------- | -------------------------- | ---------------------------------------- |
37+
| TESTCONTAINERS_HOST_OVERRIDE | tcp://docker:2375 | Docker's host on which ports are exposed |
38+
| TESTCONTAINERS_DOCKER_SOCKET_OVERRIDE | /var/run/docker.sock | Path to Docker's socket used by ryuk |
39+
| TESTCONTAINERS_RYUK_PRIVILEGED | true | Run ryuk as a privileged container |
40+
| TESTCONTAINERS_RYUK_DISABLED | true | Disable ryuk |
41+
| TESTCONTAINERS_RYUK_PORT | 65515 | Set ryuk host port (not recommended) |
42+
| TESTCONTAINERS_SSHD_PORT | 65515 | Set SSHd host port (not recommended) |
43+
| TESTCONTAINERS_HUB_IMAGE_NAME_PREFIX | mycompany.com/registry | Set default image registry |
44+
| RYUK_CONTAINER_IMAGE | testcontainers/ryuk:0.11.0 | Custom image for ryuk |
45+
| SSHD_CONTAINER_IMAGE | testcontainers/sshd:1.1.0 | Custom image for SSHd |
46+
| TESTCONTAINERS_REUSE_ENABLE | true | Enable reusable containers |

docs/features/containers.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,10 @@ const container = await new GenericContainer("alpine")
133133
content: "hello world",
134134
target: "/remote/file2.txt"
135135
}])
136+
.withCopyArchivesToContainer([{
137+
tar: nodeReadable,
138+
target: "/some/nested/remotedir"
139+
}])
136140
.start();
137141
```
138142

@@ -153,6 +157,7 @@ container.copyContentToContainer([{
153157
content: "hello world",
154158
target: "/remote/file2.txt"
155159
}])
160+
container.copyArchiveToContainer(nodeReadable, "/some/nested/remotedir");
156161
```
157162

158163
An optional `mode` can be specified in octal for setting file permissions:
@@ -357,6 +362,29 @@ const container = await new GenericContainer("alpine").start();
357362
await container.restart();
358363
```
359364

365+
## Committing a container to an image
366+
367+
```javascript
368+
const container = await new GenericContainer("alpine").start();
369+
// Do something with the container
370+
await container.exec(["sh", "-c", `echo 'hello world' > /hello-world.txt`]);
371+
// Commit the container to an image
372+
const newImageId = await container.commit({ repo: "my-repo", tag: "my-tag" });
373+
// Use this image in a new container
374+
const containerFromCommit = await new GenericContainer(newImageId).start();
375+
```
376+
377+
By default, the image inherits the behavior of being marked for cleanup on exit. You can override this behavior using
378+
the `deleteOnExit` option:
379+
380+
```javascript
381+
const container = await new GenericContainer("alpine").start();
382+
// Do something with the container
383+
await container.exec(["sh", "-c", `echo 'hello world' > /hello-world.txt`]);
384+
// Commit the container to an image; committed image will not be cleaned up on exit
385+
const newImageId = await container.commit({ repo: "my-repo", tag: "my-tag", deleteOnExit: false });
386+
```
387+
360388
## Reusing a container
361389

362390
Enabling container re-use means that Testcontainers will not start a new container if a Testcontainers managed container with the same configuration is already running.

docs/modules/cosmosdb.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Cosmos DB Emulator Module (Linux-based)
2+
3+
[Azure Cosmos DB](https://azure.microsoft.com/en-GB/products/cosmos-db) is a globally distributed, multi-model database service provided by Microsoft.
4+
5+
## Install
6+
7+
```bash
8+
npm install @testcontainers/azurecosmosdb --save-dev
9+
```
10+
11+
## Examples
12+
<!--codeinclude-->
13+
[Connect to emulator and create a database:](../../packages/modules/azurecosmosdb/src/azure-cosmosdb-emulator-container.test.ts) inside_block:httpCreateDB
14+
<!--/codeinclude-->
15+
16+
<!--codeinclude-->
17+
[Using HTTPS:](../../packages/modules/azurecosmosdb/src/azure-cosmosdb-emulator-container.test.ts) inside_block:httpsCreateDB
18+
<!--/codeinclude-->
19+
20+
<!--codeinclude-->
21+
[Create and read items:](../../packages/modules/azurecosmosdb/src/azure-cosmosdb-emulator-container.test.ts) inside_block:createAndRead
22+
<!--/codeinclude-->
23+
24+
## Caveats
25+
### Compatibility
26+
This testcontainer uses the [linux-based](https://learn.microsoft.com/en-us/azure/cosmos-db/emulator-linux) version. In general, it:
27+
28+
- Provides better compatibility on a variety of systems
29+
- Consumes significantly less resources
30+
- Comes with much faster startup times
31+
32+
However, not all features of a full CosmosDB are implemented yet - please refer to [this overview](https://learn.microsoft.com/en-us/azure/cosmos-db/emulator-linux#feature-support) for a detailed list.

eslint.config.js

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import eslint from "@eslint/js";
2+
import json from "@eslint/json";
3+
import eslintConfigPrettier from "eslint-config-prettier/flat";
4+
import eslintPluginPrettier from "eslint-plugin-prettier/recommended";
5+
import tseslint from "typescript-eslint";
6+
7+
/** @type {import("typescript-eslint").ConfigArray} */
8+
export default [
9+
{
10+
ignores: ["**/build/"],
11+
},
12+
{
13+
ignores: ["package-lock.json"],
14+
files: ["**/*.json"],
15+
language: "json/json",
16+
...json.configs.recommended,
17+
},
18+
eslint.configs.recommended,
19+
...tseslint.configs.recommended,
20+
eslintConfigPrettier,
21+
eslintPluginPrettier,
22+
{
23+
rules: {
24+
"prettier/prettier": [
25+
"error",
26+
{
27+
trailingComma: "es5",
28+
},
29+
],
30+
"@typescript-eslint/no-empty-function": "off",
31+
"@typescript-eslint/no-unused-vars": [
32+
"error",
33+
{
34+
caughtErrors: "none",
35+
},
36+
],
37+
"no-irregular-whitespace": "off",
38+
},
39+
},
40+
];

mkdocs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ nav:
4646
- Azurite: modules/azurite.md
4747
- Cassandra: modules/cassandra.md
4848
- ChromaDB: modules/chromadb.md
49+
- CosmosDB: modules/cosmosdb.md
4950
- Couchbase: modules/couchbase.md
5051
- CockroachDB: modules/cockroachdb.md
5152
- Elasticsearch: modules/elasticsearch.md

0 commit comments

Comments
 (0)