Skip to content

Commit 299cb55

Browse files
committed
add additional docker options
1 parent 45920d3 commit 299cb55

File tree

2 files changed

+17
-9
lines changed

2 files changed

+17
-9
lines changed

airbyte-local-cli-nodejs/src/docker.ts

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ export async function checkSrcConnection(tmpDir: string, image: string, srcConfi
122122
*
123123
* @argument command - for testing purposes only
124124
*/
125-
export async function runSrcSync(tmpDir: string, config: FarosConfig, command?: string[]): Promise<string> {
125+
export async function runSrcSync(tmpDir: string, config: FarosConfig): Promise<string> {
126126
logger.info('Running source connector...');
127127

128128
if (!config.src?.image) {
@@ -132,7 +132,7 @@ export async function runSrcSync(tmpDir: string, config: FarosConfig, command?:
132132
try {
133133
const timestamp = Date.now();
134134
const srcContainerName = `airbyte-local-src-${timestamp}`;
135-
const cmd = command ?? [
135+
const cmd = [
136136
'read',
137137
'--config',
138138
`/configs/${SRC_CONFIG_FILENAME}`,
@@ -146,13 +146,19 @@ export async function runSrcSync(tmpDir: string, config: FarosConfig, command?:
146146
const maxMemory =
147147
config.src?.dockerOptions?.maxMemory !== undefined ? config.src.dockerOptions.maxMemory * 1024 * 1024 : undefined;
148148
const createOptions: Docker.ContainerCreateOptions = {
149+
// Default config: can be overridden by the docker options provided by users
149150
name: srcContainerName,
150151
Image: config.src.image,
152+
...config.src?.dockerOptions?.additionalOptions,
153+
154+
// Default options: cannot be overridden by users
151155
Cmd: cmd,
156+
AttachStdout: true,
157+
AttachStderr: true,
158+
platform: 'linux/amd64',
159+
Env: [`LOG_LEVEL=${config.logLevel}`, ...(config.src?.dockerOptions?.additionalOptions?.Env || [])],
152160
HostConfig: {
153-
Binds: [`${tmpDir}:/configs`],
154-
AutoRemove: true,
155-
Init: true,
161+
// Defautl host config: can be overridden by users
156162
NanoCpus: maxNanoCpus, // 1e9 nano cpus = 1 cpu
157163
Memory: maxMemory, // 1024 * 1024 bytes = 1MB
158164
LogConfig: {
@@ -161,11 +167,12 @@ export async function runSrcSync(tmpDir: string, config: FarosConfig, command?:
161167
'max-size': config.src?.dockerOptions?.maxLogSize ?? DEFAULT_MAX_LOG_SIZE,
162168
},
163169
},
170+
...config.src?.dockerOptions?.additionalOptions?.HostConfig,
171+
// Default options: cannot be overridden by users
172+
Binds: [`${tmpDir}:/configs`],
173+
AutoRemove: true,
174+
Init: true,
164175
},
165-
AttachStdout: true,
166-
AttachStderr: true,
167-
Env: [`LOG_LEVEL=${config.logLevel}`],
168-
platform: 'linux/amd64',
169176
};
170177

171178
// Create the Docker container

airbyte-local-cli-nodejs/src/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ export interface AirbyteConfigDockerOptions {
4646
maxMemory?: number; // unit: MB
4747
maxCpus?: number; // unit: CPU
4848
maxLogSize?: string; // default: 10m (10MB)
49+
additionalOptions?: any;
4950
}
5051
export enum AirbyteConfigInputType {
5152
FILE = 'file',

0 commit comments

Comments
 (0)