-
Notifications
You must be signed in to change notification settings - Fork 77
Expand file tree
/
Copy pathdocker.ts
More file actions
51 lines (42 loc) · 1.46 KB
/
docker.ts
File metadata and controls
51 lines (42 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import { config as dotEnvConfig } from 'dotenv';
import * as path from 'path';
import type {
StartedTestContainer,
StartedDockerComposeEnvironment,
} from 'testcontainers';
import { DockerComposeEnvironment } from 'testcontainers';
dotEnvConfig();
export type Containers = {
postGresContainer: StartedTestContainer;
l1_node: StartedTestContainer;
fuel_node: StartedTestContainer;
block_committer: StartedTestContainer;
};
const PROJECT_ROOT = path.resolve(__dirname, '../../../');
let environment: StartedDockerComposeEnvironment;
// responsible for starting all containers
export async function startContainers() {
// building images externally
console.log('Setting up environment using docker compose...');
environment = await new DockerComposeEnvironment(
path.resolve(PROJECT_ROOT, 'docker'),
'docker-compose.yml'
)
.withBuild()
.up();
console.log('Environment setup done...');
const postGresContainer = environment.getContainer('db-1');
const l1_node: StartedTestContainer = environment.getContainer('l1_chain-1');
const fuel_node: StartedTestContainer =
environment.getContainer('fuel_core-1');
const block_committer: StartedTestContainer = environment.getContainer(
'fuel_block_commiter-1'
);
return { postGresContainer, l1_node, fuel_node, block_committer };
}
export async function stopEnvironment(): Promise<void> {
console.log('Stopping environment...');
if (environment) {
await environment.down();
}
}