Skip to content

Commit a01d2f9

Browse files
authored
fix(docker): Don't load native on alpine (not supported), fix #6510 (#6636)
1 parent 15e51bc commit a01d2f9

File tree

4 files changed

+58
-50
lines changed

4 files changed

+58
-50
lines changed

packages/cubejs-backend-shared/src/env.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/* eslint-disable no-restricted-syntax */
22
import { get } from 'env-var';
33
import { displayCLIWarning } from './cli';
4+
import { detectLibc } from './platform';
45

56
export class InvalidConfiguration extends Error {
67
public constructor(key: string, value: any, description: string) {
@@ -1542,6 +1543,10 @@ const variables: Record<string, (...args: any) => any> = {
15421543
.asBoolStrict();
15431544

15441545
if (isDevMode) {
1546+
if (process.platform === 'linux' && detectLibc() === 'musl') {
1547+
return undefined;
1548+
}
1549+
15451550
return 15432;
15461551
}
15471552

packages/cubejs-backend-shared/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,5 @@ export * from './cli';
1818
export * from './proxy';
1919
export * from './time';
2020
export * from './process';
21+
export * from './platform';
2122
export * from './FileRepository';
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import { spawnSync } from 'child_process';
2+
import { internalExceptions } from './errors';
3+
import { displayCLIWarning } from './cli';
4+
5+
export function detectLibc() {
6+
if (process.platform !== 'linux') {
7+
throw new Error('Unable to detect libc on not linux os');
8+
}
9+
10+
try {
11+
const { status } = spawnSync('getconf', ['GNU_LIBC_VERSION'], {
12+
encoding: 'utf8',
13+
// Using pipe to protect unexpect STDERR output
14+
stdio: 'pipe'
15+
});
16+
if (status === 0) {
17+
return 'gnu';
18+
}
19+
} catch (e: any) {
20+
internalExceptions(e);
21+
}
22+
23+
{
24+
const { status, stdout, stderr } = spawnSync('ldd', ['--version'], {
25+
encoding: 'utf8',
26+
// Using pipe to protect unexpect STDERR output
27+
stdio: 'pipe',
28+
});
29+
if (status === 0) {
30+
if (stdout.includes('musl')) {
31+
return 'musl';
32+
}
33+
34+
if (stdout.includes('gnu')) {
35+
return 'gnu';
36+
}
37+
} else {
38+
if (stderr.includes('musl')) {
39+
return 'musl';
40+
}
41+
42+
if (stderr.includes('gnu')) {
43+
return 'gnu';
44+
}
45+
}
46+
}
47+
48+
displayCLIWarning('Unable to detect what host library is used as libc, continue with gnu');
49+
50+
return 'gnu';
51+
}

rust/cubestore/js-wrapper/src/utils.ts

Lines changed: 1 addition & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,5 @@
1-
import { spawnSync } from 'child_process';
21
import process from 'process';
3-
import { displayCLIWarning, internalExceptions } from '@cubejs-backend/shared';
4-
5-
export function detectLibc() {
6-
if (process.platform !== 'linux') {
7-
throw new Error('Unable to detect libc on not linux os');
8-
}
9-
10-
try {
11-
const { status } = spawnSync('getconf', ['GNU_LIBC_VERSION'], {
12-
encoding: 'utf8',
13-
// Using pipe to protect unexpect STDERR output
14-
stdio: 'pipe'
15-
});
16-
if (status === 0) {
17-
return 'gnu';
18-
}
19-
} catch (e: any) {
20-
internalExceptions(e);
21-
}
22-
23-
{
24-
const { status, stdout, stderr } = spawnSync('ldd', ['--version'], {
25-
encoding: 'utf8',
26-
// Using pipe to protect unexpect STDERR output
27-
stdio: 'pipe',
28-
});
29-
if (status === 0) {
30-
if (stdout.includes('musl')) {
31-
return 'musl';
32-
}
33-
34-
if (stdout.includes('gnu')) {
35-
return 'gnu';
36-
}
37-
} else {
38-
if (stderr.includes('musl')) {
39-
return 'musl';
40-
}
41-
42-
if (stderr.includes('gnu')) {
43-
return 'gnu';
44-
}
45-
}
46-
}
47-
48-
displayCLIWarning('Unable to detect what host library is used as libc, continue with gnu');
49-
50-
return 'gnu';
51-
}
2+
import { displayCLIWarning, internalExceptions, detectLibc } from '@cubejs-backend/shared';
523

534
export function getTarget(): string {
545
if (process.arch === 'x64') {

0 commit comments

Comments
 (0)