This repository has been archived by the owner on Mar 30, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
71 lines (52 loc) · 1.56 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
FROM alpine:latest
####
# pre-installation
####
USER root
ENV HOME /home
ENV USER docker
ENV APP_DIR $HOME/$USER/app
# http://pkg-shadow.alioth.debian.org/features.php
ENV TEMPORARY_DEPENDENCIES='shadow'
RUN apk update && apk --no-cache add ${TEMPORARY_DEPENDENCIES}
# add user as per: https://docs.docker.com/engine/userguide/eng-image/dockerfile_best-practices/#user
RUN groupadd -r $USER && useradd --no-log-init -r -g $USER $USER
###
# nodejs installation
###
RUN apk --no-cache add \
--update \
nodejs \
nodejs-npm \
# clean up obsolete files
&& rm -rf /tmp/* /root/.npm
####
# post-installation
####
# clean no longer needed dependencies
RUN apk del ${TEMPORARY_DEPENDENCIES}
####
# user and content management
####
# create dedicated directory
RUN mkdir -p $APP_DIR
RUN mkdir -p $APP_DIR/reports/screenshots
ADD bin/bash/entrypoint.sh /entrypoint.sh
RUN chmod 755 /entrypoint.sh
# copy package.json to image
ADD package.json $APP_DIR
# change rights of the folder containing the newly copied content
RUN chown -R $USER $HOME
RUN chown $USER:$USER -R $APP_DIR/reports
# switch to docker user to ensure correct permissions for npm dependencies
USER $USER
WORKDIR $APP_DIR
RUN npm install --ignore-scripts --unsafe-perm --loglevel warn
# 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)
USER root
ADD . $APP_DIR
# switch back to the docker user
USER $USER
ENTRYPOINT ["/entrypoint.sh"]