Skip to content

Commit 214e23a

Browse files
committed
fix: 恢复 linux/s390x 镜像支持
1 parent ddb3ab7 commit 214e23a

7 files changed

Lines changed: 209 additions & 386 deletions

File tree

.github/workflows/build-docker-image.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ jobs:
212212
QL_BRANCH=${{ github.ref_name }}
213213
SOURCE_COMMIT=${{ github.sha }}
214214
network: host
215-
platforms: linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/ppc64le,linux/386
215+
platforms: linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/ppc64le,linux/s390x,linux/386
216216
context: .
217217
file: ./docker/Dockerfile
218218
push: true
@@ -290,6 +290,7 @@ jobs:
290290
QL_BRANCH=${{ github.ref_name }}
291291
SOURCE_COMMIT=${{ github.sha }}
292292
network: host
293+
# Keep s390x on Debian: npm can hang under QEMU with Alpine (nodejs/docker-node#1973).
293294
platforms: linux/amd64,linux/arm/v7,linux/arm64,linux/ppc64le,linux/s390x
294295
context: .
295296
file: ./docker/Dockerfile.debian
@@ -354,7 +355,7 @@ jobs:
354355
QL_BRANCH=${{ github.ref_name }}
355356
SOURCE_COMMIT=${{ github.sha }}
356357
network: host
357-
platforms: linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/ppc64le,linux/386
358+
platforms: linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/ppc64le,linux/s390x,linux/386
358359
context: .
359360
file: ./docker/Dockerfile.310
360361
push: true
@@ -419,6 +420,7 @@ jobs:
419420
QL_BRANCH=${{ github.ref_name }}
420421
SOURCE_COMMIT=${{ github.sha }}
421422
network: host
423+
# Keep s390x on Debian: npm can hang under QEMU with Alpine (nodejs/docker-node#1973).
422424
platforms: linux/amd64,linux/arm/v7,linux/arm64,linux/ppc64le,linux/s390x
423425
context: .
424426
file: ./docker/Dockerfile.debian310

docker/Dockerfile

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,26 @@
1-
FROM python:3.11-alpine3.18 AS builder
1+
# Run Node package installation natively on the builder. Node/npm can spin at
2+
# 100% CPU when Alpine s390x is emulated through QEMU.
3+
FROM --platform=$BUILDPLATFORM node:18-alpine3.18 AS builder
4+
5+
ARG TARGETARCH
6+
ENV NPM_CONFIG_PREFIX=/opt/node-global
7+
ENV PATH=/opt/node-global/bin:${PATH}
8+
29
COPY package.json .npmrc pnpm-lock.yaml /tmp/build/
310
RUN set -x \
4-
&& apk update \
5-
&& apk add nodejs npm git \
11+
&& apk add --no-cache git \
612
&& npm i -g pnpm@8.3.1 pm2 ts-node typescript@5 \
713
&& cd /tmp/build \
8-
&& pnpm install --prod
14+
&& case "${TARGETARCH}" in \
15+
amd64) NODE_ARCH=x64 ;; \
16+
386) NODE_ARCH=ia32 ;; \
17+
ppc64le) NODE_ARCH=ppc64 ;; \
18+
*) NODE_ARCH="${TARGETARCH}" ;; \
19+
esac \
20+
&& npm_config_target_platform=linux \
21+
npm_config_target_arch="${NODE_ARCH}" \
22+
npm_config_target_libc=musl \
23+
pnpm install --prod
924

1025
FROM python:3.11-alpine
1126

@@ -26,8 +41,8 @@ VOLUME /ql/data
2641

2742
EXPOSE 5700
2843

29-
COPY --from=builder /usr/local/lib/node_modules/. /usr/local/lib/node_modules/
30-
COPY --from=builder /usr/local/bin/. /usr/local/bin/
44+
COPY --from=builder /opt/node-global/lib/node_modules/. /usr/local/lib/node_modules/
45+
COPY --from=builder /opt/node-global/bin/. /usr/local/bin/
3146

3247
RUN set -x \
3348
&& apk update -f \

docker/Dockerfile.310

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,26 @@
1-
FROM python:3.10-alpine3.18 AS builder
1+
# Run Node package installation natively on the builder. Node/npm can spin at
2+
# 100% CPU when Alpine s390x is emulated through QEMU.
3+
FROM --platform=$BUILDPLATFORM node:18-alpine3.18 AS builder
4+
5+
ARG TARGETARCH
6+
ENV NPM_CONFIG_PREFIX=/opt/node-global
7+
ENV PATH=/opt/node-global/bin:${PATH}
8+
29
COPY package.json .npmrc pnpm-lock.yaml /tmp/build/
310
RUN set -x \
4-
&& apk update \
5-
&& apk add nodejs npm git \
11+
&& apk add --no-cache git \
612
&& npm i -g pnpm@8.3.1 pm2 ts-node typescript@5 \
713
&& cd /tmp/build \
8-
&& pnpm install --prod
14+
&& case "${TARGETARCH}" in \
15+
amd64) NODE_ARCH=x64 ;; \
16+
386) NODE_ARCH=ia32 ;; \
17+
ppc64le) NODE_ARCH=ppc64 ;; \
18+
*) NODE_ARCH="${TARGETARCH}" ;; \
19+
esac \
20+
&& npm_config_target_platform=linux \
21+
npm_config_target_arch="${NODE_ARCH}" \
22+
npm_config_target_libc=musl \
23+
pnpm install --prod
924

1025
FROM python:3.10-alpine
1126

@@ -26,8 +41,8 @@ VOLUME /ql/data
2641

2742
EXPOSE 5700
2843

29-
COPY --from=builder /usr/local/lib/node_modules/. /usr/local/lib/node_modules/
30-
COPY --from=builder /usr/local/bin/. /usr/local/bin/
44+
COPY --from=builder /opt/node-global/lib/node_modules/. /usr/local/lib/node_modules/
45+
COPY --from=builder /opt/node-global/bin/. /usr/local/bin/
3146

3247
RUN set -x \
3348
&& apk update -f \

docker/Dockerfile.debian

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
FROM node:22-slim AS nodebuilder
1+
# Node 20 Bookworm is the latest official Node image variant that covers the
2+
# full Debian build matrix, including arm/v7, ppc64le, and s390x.
3+
FROM node:20-bookworm-slim AS nodebuilder
24

35
FROM python:3.11-slim-bookworm AS builder
46
COPY package.json .npmrc pnpm-lock.yaml /tmp/build/

docker/Dockerfile.debian310

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
FROM node:22-slim AS nodebuilder
1+
# Node 20 Bookworm is the latest official Node image variant that covers the
2+
# full Debian build matrix, including arm/v7, ppc64le, and s390x.
3+
FROM node:20-bookworm-slim AS nodebuilder
24

35
FROM python:3.10-slim-bookworm AS builder
46
COPY package.json .npmrc pnpm-lock.yaml /tmp/build/

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
}
6868
},
6969
"overrides": {
70-
"sqlite3": "git+https://github.com/whyour/node-sqlite3.git#v1.0.3",
70+
"sqlite3": "git+https://github.com/whyour/node-sqlite3.git#v1.1.0",
7171
"@codemirror/state": "6.5.4",
7272
"@codemirror/view": "6.39.16"
7373
}
@@ -111,7 +111,7 @@
111111
"request-ip": "3.3.0",
112112
"sequelize": "^6.37.5",
113113
"sockjs": "^0.3.24",
114-
"sqlite3": "git+https://github.com/whyour/node-sqlite3.git#v1.0.3",
114+
"sqlite3": "git+https://github.com/whyour/node-sqlite3.git#v1.1.0",
115115
"toad-scheduler": "^3.0.1",
116116
"typedi": "^0.10.0",
117117
"undici": "^7.9.0",

0 commit comments

Comments
 (0)