Skip to content

Commit

Permalink
Dockerfile: added alpine builders
Browse files Browse the repository at this point in the history
  • Loading branch information
thom-nic committed Dec 16, 2021
1 parent fbb90b4 commit af81d7f
Show file tree
Hide file tree
Showing 5 changed files with 119 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-pack-publish.yml
Original file line number Diff line number Diff line change
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
39 changes: 39 additions & 0 deletions Dockerfile-alpine
Original file line number Diff line number Diff line change
@@ -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
39 changes: 39 additions & 0 deletions Dockerfile-alpine-arm
Original file line number Diff line number Diff line change
@@ -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
39 changes: 39 additions & 0 deletions Dockerfile-alpine-arm64
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"scripts": {
"test": "npx nodeunit test/*.js",
"install": "node-gyp-build",
"build": "prebuildify --napi"
"build": "prebuildify --napi --tag-libc --strip"
},
"dependencies": {
"node-addon-api": "^3.1.0",
Expand Down

0 comments on commit af81d7f

Please sign in to comment.