Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Dockerfile: added alpine builders
  • Loading branch information
thom-nic committed Oct 31, 2023
1 parent ea2a8fd commit 74ebe5a
Show file tree
Hide file tree
Showing 8 changed files with 126 additions and 9 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build-pack-publish.yml
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
39 changes: 39 additions & 0 deletions 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:16-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@5 node-gyp@9 \
&& 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
39 changes: 39 additions & 0 deletions 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:16-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@5 node-gyp@9 \
&& 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
39 changes: 39 additions & 0 deletions 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:16-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@5 node-gyp@9 \
&& 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
4 changes: 2 additions & 2 deletions Dockerfile-arm
Expand Up @@ -5,7 +5,7 @@
# # Then copy the artifact to your host:
# docker cp donut:/usr/local/opt/bcrypt-js/prebuilds .

FROM arm32v7/node:14-bullseye
FROM arm32v7/node:16-bullseye

ENV project bcrypt-js
ENV DEBIAN_FRONTEND noninteractive
Expand All @@ -20,7 +20,7 @@ RUN echo "#log: ${project}: Setup system" \
python3 \
&& apt-get clean \
&& update-alternatives --install /usr/local/bin/python python /usr/bin/python3 20 \
&& npm i -g prebuildify node-gyp nodeunit \
&& npm i -g prebuildify@5 node-gyp@9 \
&& sync

ADD . /usr/local/opt/${project}
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile-arm64
Expand Up @@ -5,7 +5,7 @@
# # Then copy the artifact to your host:
# docker cp donut-arm64:/usr/local/opt/bcrypt-js/prebuilds .

FROM arm64v8/node:14-bullseye
FROM arm64v8/node:16-bullseye

ENV project bcrypt-js
ENV DEBIAN_FRONTEND noninteractive
Expand All @@ -20,7 +20,7 @@ RUN echo "#log: ${project}: Setup system" \
python3 \
&& apt-get clean \
&& update-alternatives --install /usr/local/bin/python python /usr/bin/python3 20 \
&& npm i -g prebuildify node-gyp nodeunit \
&& npm i -g prebuildify@5 node-gyp@9 \
&& sync

ADD . /usr/local/opt/${project}
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile-x64
Expand Up @@ -5,7 +5,7 @@
# # Then copy the artifact to your host:
# docker cp donut:/usr/local/opt/bcrypt-js/prebuilds .

FROM node:14-bullseye
FROM node:16-bullseye

ENV project bcrypt-js
ENV DEBIAN_FRONTEND noninteractive
Expand All @@ -20,7 +20,7 @@ RUN echo "#log: ${project}: Setup system" \
python3 \
&& apt-get clean \
&& update-alternatives --install /usr/local/bin/python python /usr/bin/python3 20 \
&& npm i -g prebuildify node-gyp nodeunit \
&& npm i -g prebuildify@5 node-gyp@9 \
&& sync

ADD . /usr/local/opt/${project}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -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",
Expand Down

0 comments on commit 74ebe5a

Please sign in to comment.