2021-12-12 02:57:20 -08:00
|
|
|
# syntax=docker.io/docker/dockerfile:1.3@sha256:42399d4635eddd7a9b8a24be879d2f9a930d0ed040a61324cfdf59ef1357b3b2
|
2021-01-19 07:15:54 -08:00
|
|
|
FROM node:lts-alpine@sha256:2ae9624a39ce437e7f58931a5747fdc60224c6e40f8980db90728de58e22af7c
|
2020-08-15 16:38:10 -07:00
|
|
|
|
2020-08-16 02:25:37 -07:00
|
|
|
# npm wants to clone random Git repositories - lovely.
|
2021-01-19 07:15:54 -08:00
|
|
|
RUN apk add git python make build-base
|
2020-08-16 02:25:37 -07:00
|
|
|
|
2020-08-15 16:38:10 -07:00
|
|
|
# Run as user, otherwise, npx explodes.
|
|
|
|
USER 1000
|
|
|
|
RUN mkdir -p /home/node/app
|
|
|
|
RUN mkdir -p /home/node/.npm
|
|
|
|
WORKDIR /home/node/app
|
|
|
|
|
2020-08-17 02:17:49 -07:00
|
|
|
# Only invalidate the npm install step if package.json changed
|
|
|
|
ADD --chown=node:node package.json .
|
2020-11-19 03:53:16 -08:00
|
|
|
ADD --chown=node:node package-lock.json .
|
2021-07-20 14:34:37 -07:00
|
|
|
ADD --chown=node:node .env.test .env
|
2020-08-15 16:38:10 -07:00
|
|
|
|
|
|
|
# We want to cache node_modules *and* incorporate it into the final image.
|
|
|
|
RUN --mount=type=cache,uid=1000,gid=1000,target=/home/node/.npm \
|
|
|
|
--mount=type=cache,uid=1000,gid=1000,target=node_modules \
|
|
|
|
npm install && \
|
|
|
|
cp -r node_modules node_modules_cache
|
|
|
|
|
|
|
|
# Amusingly, Debian's coreutils version has a bug where mv believes that
|
|
|
|
# the target is on a different fs and does a full recursive copy for what
|
|
|
|
# could be a renameat syscall. Alpine does not have this bug.
|
|
|
|
RUN rmdir node_modules && mv node_modules_cache node_modules
|
2020-08-17 02:17:49 -07:00
|
|
|
|
|
|
|
ADD --chown=node:node . .
|