Skip to content

Commit

Permalink
fix: use pkg-fetch fork: armv7 support and performances 🚀 (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
n1ru4l authored Aug 21, 2020
1 parent f02b5c9 commit adbdbd4
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 7 deletions.
10 changes: 8 additions & 2 deletions Dockerfile.cross
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,18 @@ ARG PKG_OS

ARG PKG_ARCH

ARG NPROC

RUN __DEPENDENCIES__

ENV PKG_CACHE_PATH=/fetched

RUN mkdir -p /fetched && npm install pkg-fetch
# Use https://github.com/n1ru4l/pkg-fetch/tree/pkg-binary-fork for building
RUN git clone -b pkg-binary-fork --single-branch https://github.com/n1ru4l/pkg-fetch.git /build
WORKDIR /build
RUN yarn && yarn run babel
RUN mkdir -p /fetched

RUN /node_modules/.bin/pkg-fetch ${PKG_NODE} ${PKG_OS} ${PKG_ARCH}
RUN MAKE_JOB_COUNT=${NPROC} yarn run bin ${PKG_NODE} ${PKG_OS} ${PKG_ARCH}

CMD ["sh"]
19 changes: 14 additions & 5 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ if [ ! -z "$1" ]; then

if [ "$1" == "arm32v7" ]; then
arch=arm32v7
pkg_arch=armv6 # cannot build for armv7
pkg_arch=armv7
platform="linux/arm/v7"
elif [ "$1" == "arm32v6" ]; then
arch=arm32v6
Expand Down Expand Up @@ -62,7 +62,7 @@ else
;;
2)
arch=arm32v7
pkg_arch=armv6
pkg_arch=armv7
platform="linux/arm/v7"
break
;;
Expand Down Expand Up @@ -142,15 +142,24 @@ fi

cp Dockerfile.cross Dockerfile.build

sed -i "s|__TAG__|${tag}|g" Dockerfile.build
if [[ "$OSTYPE" == "darwin"* ]]; then
sed -i "" "s|__TAG__|${tag}|g" Dockerfile.build
sed -i "" "s|__DEPENDENCIES__|${dependencies}|g" Dockerfile.build

NPROC=$(sysctl -n hw.physicalcpu)
else
sed -i "s|__TAG__|${tag}|g" Dockerfile.build
sed -i "s|__DEPENDENCIES__|${dependencies}|g" Dockerfile.build

sed -i "s|__DEPENDENCIES__|${dependencies}|g" Dockerfile.build
NPROC=$(nproc)
fi

docker buildx build -f Dockerfile.build \
docker buildx build --progress plain -f Dockerfile.build \
--platform $platform \
--build-arg PKG_NODE="$pkg_node" \
--build-arg PKG_OS="$pkg_os" \
--build-arg PKG_ARCH="$pkg_arch" \
--build-arg NPROC="$NPROC" \
--load \
-t ${arch}/pkgbinaries:${pkg_os}-${pkg_node} .

Expand Down

0 comments on commit adbdbd4

Please sign in to comment.