Skip to content

Commit

Permalink
ci: change dockerfile for multi-platform build on CI
Browse files Browse the repository at this point in the history
  • Loading branch information
zavoloklom committed Nov 22, 2024
1 parent 5318d97 commit 3d05b2e
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 4 deletions.
21 changes: 17 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
14 changes: 14 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 3d05b2e

Please sign in to comment.