-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 2a5f0ba
Showing
4 changed files
with
107 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
FROM node:9.5.0-alpine as builder | ||
|
||
ARG version=0.0.0 | ||
ENV NODE_VERSION=$version | ||
|
||
RUN apk update | ||
RUN apk add make python binutils gnupg curl | ||
RUN apk add upx --no-cache --repository http://dl-cdn.alpinelinux.org/alpine/edge/community | ||
|
||
RUN npm install --no-save node-musl | ||
|
||
# gpg keys listed at https://github.com/nodejs/node#release-team | ||
RUN for key in \ | ||
94AE36675C464D64BAFA68DD7434390BDBE9B9C5 \ | ||
FD3A5288F042B6850C66B31F09FE44734EB7990E \ | ||
71DCFD284A79C3B38668286BC97EC7A07EDE3FC1 \ | ||
DD8F2338BAE7501E3DD5AC78C273792F7D83545D \ | ||
C4F0DFFF4E8C1A8236409D08E73BC641CC11F4C8 \ | ||
B9AE9905FFD7803F25714661B63B535A4C206CA9 \ | ||
56730D5401028683275BD23C23EFEFE93C4CFFFE \ | ||
77984A986EBC2AA786BC0F66B01FBB92821C587A \ | ||
8FCCA13FEF1D0C2E91008E09770F7A9A5AE15600 \ | ||
; do \ | ||
gpg --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys "$key" || \ | ||
gpg --keyserver hkp://ipv4.pool.sks-keyservers.net --recv-keys "$key" || \ | ||
gpg --keyserver hkp://pgp.mit.edu:80 --recv-keys "$key" ; \ | ||
done \ | ||
&& curl -fsSLO --compressed "https://nodejs.org/dist/v$NODE_VERSION/node-v$NODE_VERSION.tar.xz" \ | ||
&& curl -fsSLO --compressed "https://nodejs.org/dist/v$NODE_VERSION/SHASUMS256.txt.asc" \ | ||
&& gpg --batch --decrypt --output SHASUMS256.txt SHASUMS256.txt.asc \ | ||
&& grep " node-v$NODE_VERSION.tar.xz\$" SHASUMS256.txt | sha256sum -c - \ | ||
&& tar -xf "node-v$NODE_VERSION.tar.xz" | ||
|
||
RUN cd "node-v$NODE_VERSION" \ | ||
&& eval "$("../node_modules/.bin/musl-exports")" \ | ||
&& ./configure \ | ||
--fully-static \ | ||
--without-dtrace \ | ||
--without-inspector \ | ||
--without-etw \ | ||
&& make -j$(getconf _NPROCESSORS_ONLN) | ||
|
||
RUN upx node-v$NODE_VERSION/out/Release/node | ||
|
||
FROM scratch | ||
|
||
ARG version=0.0.0 | ||
|
||
COPY --from=builder node-v$version/out/Release/node / | ||
COPY --from=builder /etc/passwd /etc/passwd | ||
|
||
USER node | ||
|
||
ENTRYPOINT ["./node"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2018 Antonin Stefanutti | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Scratch Node.js Docker Images | ||
|
||
Smallest Node.js Docker images (<15MB). | ||
|
||
## Content | ||
|
||
* A fully statically linked and compressed Node.js binary | ||
* An `/etc/passwd` entry for a `node` user | ||
|
||
## Images | ||
|
||
* `latest`, `11`, `11.1`, `11.1.0` – 14.6 MB | ||
* `10`, `10.13`, `10.13.0` – 14.3 MB | ||
|
||
## Usage | ||
|
||
```dockerfile | ||
FROM node as builder | ||
|
||
WORKDIR /app | ||
|
||
COPY package.json package-lock.json index.js ./ | ||
|
||
RUN npm install --prod | ||
|
||
FROM astefanutti/scratch-node | ||
|
||
COPY --from=builder /app / | ||
|
||
ENTRYPOINT ["./node", "index.js"] | ||
``` |