From f7c9fe7b910ad229baba164e46e4d51166dda9de Mon Sep 17 00:00:00 2001 From: Thom Nichols <95562+thom-nic@users.noreply.github.com> Date: Wed, 15 Dec 2021 22:38:10 -0500 Subject: [PATCH] Dockerfile: added alpine builders --- .github/workflows/build-pack-publish.yml | 4 +-- Dockerfile-alpine | 39 ++++++++++++++++++++++++ Dockerfile-alpine-arm | 39 ++++++++++++++++++++++++ Dockerfile-alpine-arm64 | 39 ++++++++++++++++++++++++ package.json | 2 +- 5 files changed, 120 insertions(+), 3 deletions(-) create mode 100755 Dockerfile-alpine create mode 100755 Dockerfile-alpine-arm create mode 100755 Dockerfile-alpine-arm64 diff --git a/.github/workflows/build-pack-publish.yml b/.github/workflows/build-pack-publish.yml index 88d6d58..a5ef4a0 100644 --- a/.github/workflows/build-pack-publish.yml +++ b/.github/workflows/build-pack-publish.yml @@ -14,7 +14,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - arch: [x64, arm, arm64] + arch: [x64, arm, arm64, alpine, alpine-arm, alpine-arm64] steps: - uses: actions/checkout@v2 - uses: docker/setup-qemu-action@v1 @@ -48,7 +48,7 @@ jobs: run: | mkdir prebuilds for d in /tmp/prebuilds/*; do - mv $d/* prebuilds/ + cp -Rav $d/* prebuilds/ done - run: chmod a+x prebuilds/*/*.node && find prebuilds -executable -type f - run: echo "PACK_FILE=$(npm pack)" >> $GITHUB_ENV diff --git a/Dockerfile-alpine b/Dockerfile-alpine new file mode 100755 index 0000000..73f3b3f --- /dev/null +++ b/Dockerfile-alpine @@ -0,0 +1,39 @@ +# Usage: +# +# docker build -t bcryptjs-linux-alpine-builder -f Dockerfile-alpine . +# CONTAINER=$(docker create bcryptjs-linux-alpine-builder) +# # Then copy the artifact to your host: +# docker cp "$CONTAINER:/usr/local/opt/bcrypt-js/prebuilds" . +# docker rm "$CONTAINER" + +FROM node:14-alpine + +ENV project bcrypt-js +ENV DEBIAN_FRONTEND noninteractive +ENV LC_ALL en_US.UTF-8 +ENV LANG ${LC_ALL} + +RUN echo "#log: ${project}: Setup system" \ + && set -x \ + && apk add --update build-base python3 \ + && npm i -g prebuildify node-gyp nodeunit \ + && sync + +ADD . /usr/local/opt/${project} +WORKDIR /usr/local/opt/${project} + +RUN echo "#log: ${project}: Running build" \ + && set -x \ + && npm ci \ + && npm run build + +ARG RUN_TESTS=true + +RUN if "${RUN_TESTS}"; then \ + echo "#log ${project}: Running tests" \ + && npm test; \ + else \ + echo "#log ${project}: Tests were skipped!"; \ + fi + +CMD /bin/bash -l diff --git a/Dockerfile-alpine-arm b/Dockerfile-alpine-arm new file mode 100755 index 0000000..24f6d35 --- /dev/null +++ b/Dockerfile-alpine-arm @@ -0,0 +1,39 @@ +# Usage: +# +# docker build -t bcryptjs-alpine-arm-builder -f Dockerfile-arm . +# CONTAINER=$(docker create bcryptjs-alpine-arm-builder) +# # Then copy the artifact to your host: +# docker cp "$CONTAINER:/usr/local/opt/bcrypt-js/prebuilds" . +# docker rm "$CONTAINER" + +FROM arm32v7/node:14-alpine + +ENV project bcrypt-js +ENV DEBIAN_FRONTEND noninteractive +ENV LC_ALL en_US.UTF-8 +ENV LANG ${LC_ALL} + +RUN echo "#log: ${project}: Setup system" \ + && set -x \ + && apk add --update build-base python3 \ + && npm i -g prebuildify node-gyp nodeunit \ + && sync + +ADD . /usr/local/opt/${project} +WORKDIR /usr/local/opt/${project} + +RUN echo "#log: ${project}: Running build" \ + && set -x \ + && npm ci \ + && npm run build + +ARG RUN_TESTS=true + +RUN if "${RUN_TESTS}"; then \ + echo "#log ${project}: Running tests" \ + && npm test; \ + else \ + echo "#log ${project}: Tests were skipped!"; \ + fi + +CMD /bin/bash -l diff --git a/Dockerfile-alpine-arm64 b/Dockerfile-alpine-arm64 new file mode 100755 index 0000000..c1f9a7d --- /dev/null +++ b/Dockerfile-alpine-arm64 @@ -0,0 +1,39 @@ +# Usage: +# +# docker build -t bcryptjs-alpine-arm-builder -f Dockerfile-arm . +# CONTAINER=$(docker create bcryptjs-alpine-arm-builder) +# # Then copy the artifact to your host: +# docker cp "$CONTAINER:/usr/local/opt/bcrypt-js/prebuilds" . +# docker rm "$CONTAINER" + +FROM arm64v8/node:14-alpine + +ENV project bcrypt-js +ENV DEBIAN_FRONTEND noninteractive +ENV LC_ALL en_US.UTF-8 +ENV LANG ${LC_ALL} + +RUN echo "#log: ${project}: Setup system" \ + && set -x \ + && apk add --update build-base python3 \ + && npm i -g prebuildify node-gyp nodeunit \ + && sync + +ADD . /usr/local/opt/${project} +WORKDIR /usr/local/opt/${project} + +RUN echo "#log: ${project}: Running build" \ + && set -x \ + && npm ci \ + && npm run build + +ARG RUN_TESTS=true + +RUN if "${RUN_TESTS}"; then \ + echo "#log ${project}: Running tests" \ + && npm test; \ + else \ + echo "#log ${project}: Tests were skipped!"; \ + fi + +CMD /bin/bash -l diff --git a/package.json b/package.json index 3aaa4cc..52742de 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ "scripts": { "test": "npm ci --build-from-source && jest", "install": "node-gyp-build", - "build": "prebuildify --napi" + "build": "prebuildify --napi --tag-libc --strip" }, "dependencies": { "node-addon-api": "^5.0.0",