You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Point out the classpath-relative directory where the application files reside
171
-
.withDirectoryBinding("cartridge")
172
-
.withRouterHost("localhost") // Optional, "localhost" is default
173
-
.withRouterPort(3301) // Binary port, optional, 3301 is default
174
-
.withAPIPort(8801) // Cartridge HTTP API port, optional, 8081 is default
175
-
.withRouterUsername("admin") // Specify the actual username, default is "admin"
176
-
.withRouterPassword("testapp-cluster-cookie") // Specify the actual password, see the "cluster_cookie" parameter
177
-
// in the cartridge.cfg({...}) call in your application.
178
-
// Usually it can be found in the init.lua module
179
-
.withReuse(true); // allows to reuse the container build once for faster testing
170
+
// Tarantool URI, optional. Default is "localhost"
171
+
.withRouterHost("localhost")
172
+
// Binary port, optional. Default is 3301
173
+
.withRouterPort(3301)
174
+
// Cartridge HTTP API port, optional, 8081 is default
175
+
.withAPIPort(8801)
176
+
// Specify the actual username, default is "admin"
177
+
.withRouterUsername("admin")
178
+
// Specify the actual password, see the "cluster_cookie" parameter
179
+
// in the cartridge.cfg({...}) call in your application.
180
+
// Usually it can be found in the init.lua module
181
+
.withRouterPassword("secret-cluster-cookie")
182
+
// allows to reuse the container build once for faster testing
183
+
.withReuse(true);
180
184
181
185
// Use the created container in tests
182
186
publicvoidtestFoo() {
@@ -193,6 +197,41 @@ public class SomeOtherTest {
193
197
}
194
198
```
195
199
200
+
##### Environment variables of cartridge container and build arguments:
201
+
###### Build arguments:
202
+
203
+
This section describes the Docker image build arguments and environment variables inside the container. It is worth
204
+
nothing that almost all build arguments listed here are passed into environment variables of the same name. At the
205
+
moment, the following arguments are available to build the image:
206
+
207
+
- `CARTRIDGE_SRC_DIR` - directory on the host machine that contains all the .lua scripts needed to initialize and run
208
+
cartridge. Defaults is `cartridge`.**Only as a build argument.**
209
+
- `TARANTOOL_WORKDIR` - a directory where all data will be stored: snapshots, wal logs and cartridge config files.
210
+
Defaults is `/app`.Converts to an environment variable. It is not recommended to override via the `withEnv(...)` method.
211
+
- `TARANTOOL_RUNDIR` - a directory where PID and socket files are stored. Defaults is `/tmp/run`.Converts to an
212
+
environment variable. It is not recommended to override via the `withEnv(...)` method.
213
+
- `TARANTOOL_DATADIR` - a directory containing the instances working directories. Defaults is `/tmp/data`.Converts to
214
+
an environment variable. It is not recommended to override via the `withEnv(...)` method.
215
+
- `TARANTOOL_LOGDIR` - the directory where log files are stored. Defaults is `/tmp/log`.Converts to an environment
216
+
- variable. It is not recommended to override via the `withEnv(...)` method.
217
+
- `TARANTOOL_INSTANCES_FILE` - path to the configuration file. Defaults is `./instances.yml`.Converts to an environment
218
+
variable. It is not recommended to override via the `withEnv(...)` method.
219
+
- `START_DELAY` - the time after which cartridge will actually run after the container has started. Converts to an
220
+
environment variable. It is not recommended to override via the `withEnv(...)` method.
221
+
222
+
You can set the Docker image build arguments using a map, which is passed as an input argument to the constructor when
223
+
creating a container in Java code. See example: https://github.com/tarantool/testcontainers-java-tarantool/blob/355d1e985bd10beca83bc7ca77f919a288709419/src/test/java/org/testcontainers/containers/TarantoolCartridgeBootstrapFromLuaWithFixedPortsTest.java#L111-L119
224
+
225
+
###### Environment variables:
226
+
227
+
To set an environment variable, use the `withEnv(...)` method of testcontainers API. Full list of variables the
228
+
environments used in cartridge can be found here [link](https://www.tarantool.io/ru/doc/2.11/book/cartridge/cartridge_api/modules/cartridge/#cfg-opts-box-opts).
229
+
230
+
***Note:***As shown in the previous section, some build arguments are converted to environment variables and used to
231
+
cartridge build at the image build stage.
232
+
233
+
An example of how to set the `TARANTOOL_CLUSTER_COOKIE` parameter: https://github.com/tarantool/testcontainers-java-tarantool/blob/355d1e985bd10beca83bc7ca77f919a288709419/src/test/java/org/testcontainers/containers/TarantoolCartridgeBootstrapFromLuaWithFixedPortsTest.java#L57-L82
0 commit comments