From 3d05b2ec4431dba0ce92722dadc68aff9cb9ecfa Mon Sep 17 00:00:00 2001 From: Sergey Kupletsky Date: Fri, 22 Nov 2024 10:40:07 +0100 Subject: [PATCH] ci: change dockerfile for multi-platform build on CI --- Dockerfile | 21 +++++++++++++++++---- Makefile | 14 ++++++++++++++ 2 files changed, 31 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index d0ad253..6e37216 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,6 +10,19 @@ COPY . . # SEA Builder RUN npm run build:pkg && ./scripts/generate-sea.sh /bin/dclint +# Collect platform-specific dependencies +SHELL ["/bin/ash", "-o", "pipefail", "-c"] +RUN mkdir -p /dependencies/lib /dependencies/usr/lib && \ + ldd /bin/dclint | awk '{print $3}' | grep -vE '^$' | while read -r lib; do \ + if [ -f "$lib" ]; then \ + if [ "${lib#/usr/lib/}" != "$lib" ]; then \ + cp "$lib" /dependencies/usr/lib/; \ + elif [ "${lib#/lib/}" != "$lib" ]; then \ + cp "$lib" /dependencies/lib/; \ + fi; \ + fi; \ + done + FROM alpine:3.19 AS alpine-version ENV NODE_NO_WARNINGS=1 @@ -46,11 +59,11 @@ FROM scratch AS scratch-version ENV NODE_NO_WARNINGS=1 -COPY --from=builder "/usr/lib/libstdc++.so.6" "/usr/lib/libstdc++.so.6" -COPY --from=builder /usr/lib/libgcc_s.so.1 /usr/lib/libgcc_s.so.1 -COPY --from=builder /lib/ld-musl-aarch64.so.1 /lib/ld-musl-aarch64.so.1 -COPY --from=builder /lib/libc.musl-aarch64.so.1 /lib/libc.musl-aarch64.so.1 +# Copy dependencies +COPY --from=builder /dependencies/lib /lib +COPY --from=builder /dependencies/usr/lib /usr/lib +# Copy dclint COPY --from=builder /bin/dclint /bin/dclint WORKDIR /app diff --git a/Makefile b/Makefile index 46a1c0f..63a5b14 100644 --- a/Makefile +++ b/Makefile @@ -46,5 +46,19 @@ dev: docker ## Start development inside container. Note: node_modules, bin, pkg, dev-sync: docker ## Start development inside container. Note: all files are synced. docker run --rm -it -v ${PWD}:/app --entrypoint /bin/sh ${IMAGE_NAME}:${IMAGE_TAG} +###### +# TEST SCRIPTS +###### + +docker-x: ## Build docker image with build-x. + docker buildx create --use + docker buildx build --file Dockerfile . --tag ${IMAGE_NAME}:${IMAGE_TAG} \ + --platform linux/amd64,linux/arm64 \ + --pull \ + --build-arg BUILD_DATE=${BUILD_DATE} \ + --build-arg BUILD_VERSION=${BUILD_VERSION} \ + --build-arg BUILD_REVISION=${BUILD_REVISION} \ + --progress plain + check-version: docker ## Check version in docker container. Note: all files are not synced. docker run --rm -it ${IMAGE_NAME}:${IMAGE_TAG} -v