Skip to content

Commit 4afc7a1

Browse files
klutchellsebdeckers
authored andcommitted
update to latest qemu; use yarn to avoid npm install issues; use 3-stage build to keep sizes down
1 parent 0e3d843 commit 4afc7a1

File tree

2 files changed

+24
-33
lines changed

2 files changed

+24
-33
lines changed

Dockerfile

+22-31
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,44 @@
11
ARG ARCH=amd64
22

3-
FROM alpine as qemu
3+
FROM alpine:3.9.2 as qemu
44

55
RUN apk add --no-cache curl
66

7-
ARG QEMU_VERSION=3.1.0-2
8-
ARG QEMU_ARCHS="arm aarch64"
7+
ARG QEMU_VERSION=4.0.0
98

10-
RUN for i in ${QEMU_ARCHS}; \
11-
do \
12-
curl -fsSL https://github.com/multiarch/qemu-user-static/releases/download/v${QEMU_VERSION}/qemu-${i}-static.tar.gz \
13-
| tar zxvf - -C /usr/bin; \
14-
done \
15-
&& chmod +x /usr/bin/qemu-*
9+
# https://github.com/hadolint/hadolint/wiki/DL4006
10+
SHELL ["/bin/ash", "-o", "pipefail", "-c"]
11+
12+
RUN curl -fsSL https://github.com/multiarch/qemu-user-static/releases/download/v${QEMU_VERSION}/qemu-arm-static.tar.gz | tar zxvf - -C /usr/bin
13+
RUN curl -fsSL https://github.com/multiarch/qemu-user-static/releases/download/v${QEMU_VERSION}/qemu-aarch64-static.tar.gz | tar zxvf - -C /usr/bin
14+
15+
RUN chmod +x /usr/bin/qemu-*
1616

1717
# ----------------------------------------------------------------------------
1818

19-
FROM ${ARCH}/node:11-alpine
19+
FROM ${ARCH}/node:11-alpine as build
2020

21-
# install qemu binaries used for cross-compiling
21+
# copy qemu binaries used for cross-compiling
2222
COPY --from=qemu /usr/bin/qemu-* /usr/bin/
2323

2424
RUN apk add --no-cache \
25-
git \
25+
alpine-sdk \
2626
curl \
27-
net-tools \
28-
drill
27+
drill \
28+
git \
29+
net-tools \
30+
python
2931

3032
WORKDIR /app
3133

32-
# copy source files
3334
COPY package.json ./
3435
COPY source/ ./source
3536

36-
# running as root user gets stuck @ node ./prebuilt-bindings install
37-
# as a workaround run as node user just for installation
38-
# https://github.com/nodejs/docker-node/issues/873
39-
RUN chown -R node:node /app
40-
USER node
37+
RUN yarn install --ignore-optional --production
4138

42-
RUN npm install --production --no-optional
43-
44-
# switch back to root
45-
USER root
46-
47-
# create link in path
48-
RUN ln -s /app/source/bin.js /usr/local/bin/dohnut
49-
RUN chmod +x /app/source/bin.js
39+
# ----------------------------------------------------------------------------
5040

51-
# remove qemu binaries used for cross-compiling
52-
RUN rm /usr/bin/qemu-*
41+
FROM ${ARCH}/node:11-alpine
5342

5443
ARG BUILD_DATE
5544
ARG BUILD_VERSION
@@ -65,4 +54,6 @@ LABEL org.label-schema.build-date="${BUILD_DATE}"
6554
LABEL org.label-schema.version="${BUILD_VERSION}"
6655
LABEL org.label-schema.vcs-ref="${VCS_REF}"
6756

68-
ENTRYPOINT [ "dohnut" ]
57+
COPY --from=build /app /app
58+
59+
ENTRYPOINT [ "node", "/app/source/bin.js" ]

Makefile

+2-2
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,11 @@ qemu-user-static:
7373
@docker run --rm --privileged multiarch/qemu-user-static:register --reset
7474

7575
qemu-arm-static:
76-
wget -q https://github.com/multiarch/qemu-user-static/releases/download/v3.1.0-2/qemu-arm-static \
76+
wget -q https://github.com/multiarch/qemu-user-static/releases/download/v4.0.0/qemu-arm-static \
7777
&& chmod +x qemu-arm-static
7878

7979
qemu-aarch64-static:
80-
wget -q https://github.com/multiarch/qemu-user-static/releases/download/v3.1.0-2/qemu-aarch64-static \
80+
wget -q https://github.com/multiarch/qemu-user-static/releases/download/v4.0.0/qemu-aarch64-static \
8181
&& chmod +x qemu-aarch64-static
8282

8383
## -- Parameters --

0 commit comments

Comments
 (0)