-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
46 lines (30 loc) · 1.25 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
FROM alpine:3
USER root
ENV HOME /home
ENV APP_DIR $HOME/docker/app
ENV TEMPORARY_DEPENDENCIES='shadow'
RUN apk --no-cache add bash ${TEMPORARY_DEPENDENCIES}
# add user as per: https://docs.docker.com/engine/userguide/eng-image/dockerfile_best-practices/#user
RUN groupadd -r docker && useradd --no-log-init -r -g docker docker
RUN chown -R docker $HOME
RUN apk add npm nodejs
# clean no longer needed dependencies
RUN apk del ${TEMPORARY_DEPENDENCIES}
# create directories
RUN mkdir -p $APP_DIR
RUN mkdir -p $APP_DIR/tests_output/screenshots
RUN chown -R docker $APP_DIR
WORKDIR $APP_DIR
COPY --chown=docker:docker package.json package-lock.json ./
# switch to docker user to ensure correct permissions for npm dependencies
USER docker
# `npm ci` actually enforces the package-lock and is way faster!
# See https://docs.npmjs.com/cli/ci.html
RUN npm ci --ignore-scripts --unsafe-perm --loglevel warn --no-progress || \
npm install --ignore-scripts --unsafe-perm --loglevel warn --no-progress
USER root
# add rest of repo to image (doing this after installing npm dependencies
# makes for a faster development workflow because only a change to package*.json
# will force docker to rebuild the "npm install" layer above)
COPY --chown=docker:docker . ./
USER docker