forked from browserless/browserless
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
128 lines (113 loc) · 3.06 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
FROM ubuntu:18.04
# Application parameters and variables
ENV NODE_ENV=production
ENV HOST=0.0.0.0
ENV PORT=3000
ENV application_directory=/usr/src/app
ENV ENABLE_XVBF=true
# Build Args
ARG USE_CHROME_STABLE
# Configuration for Chrome
ENV CONNECTION_TIMEOUT=60000
ENV CHROME_PATH=/usr/bin/google-chrome
ENV USE_CHROME_STABLE=${USE_CHROME_STABLE}
RUN mkdir -p $application_directory
WORKDIR $application_directory
# Install app dependencies
COPY package.json .
COPY tsconfig.json .
# Bundle app source
COPY . .
# Dependencies + NodeJS
RUN apt-get -qq update && \
echo "ttf-mscorefonts-installer msttcorefonts/accepted-mscorefonts-eula select true" | debconf-set-selections && \
apt-get -y -qq install software-properties-common &&\
apt-add-repository "deb http://archive.canonical.com/ubuntu $(lsb_release -sc) partner" && \
apt-add-repository ppa:malteworld/ppa && apt-get -qq update && apt-get -y -qq install \
adobe-flashplugin \
msttcorefonts \
fonts-noto-color-emoji \
fonts-noto-cjk \
fonts-liberation \
fonts-thai-tlwg \
fonts-indic \
fontconfig \
libappindicator3-1 \
pdftk \
unzip \
locales \
gconf-service \
libasound2 \
libatk1.0-0 \
libc6 \
libcairo2 \
libcups2 \
libdbus-1-3 \
libexpat1 \
libfontconfig1 \
libgcc1 \
libgconf-2-4 \
libgdk-pixbuf2.0-0 \
libglib2.0-0 \
libgtk-3-0 \
libnspr4 \
libpango-1.0-0 \
libpangocairo-1.0-0 \
libstdc++6 \
libx11-6 \
libx11-xcb1 \
libxcb1 \
libxcomposite1 \
libxcursor1 \
libxdamage1 \
libxext6 \
libxfixes3 \
libxi6 \
libxrandr2 \
libxrender1 \
libxss1 \
libxtst6 \
ca-certificates \
libappindicator1 \
libnss3 \
lsb-release \
xdg-utils \
wget \
xvfb \
curl &&\
# Install Node
curl --silent --location https://deb.nodesource.com/setup_10.x | bash - &&\
apt-get -y -qq install nodejs &&\
apt-get -y -qq install build-essential &&\
# Fonts
fc-cache -f -v
# It's a good idea to use dumb-init to help prevent zombie chrome processes.
ADD https://github.com/Yelp/dumb-init/releases/download/v1.2.0/dumb-init_1.2.0_amd64 /usr/local/bin/dumb-init
RUN chmod +x /usr/local/bin/dumb-init
# Install Chrome Stable when specified
RUN if [ "$USE_CHROME_STABLE" = "true" ]; then \
cd /tmp &&\
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb &&\
dpkg -i google-chrome-stable_current_amd64.deb;\
fi
# Build
RUN if [ "$USE_CHROME_STABLE" = "true" ]; then \
export PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true;\
fi &&\
npm install -g typescript @types/node &&\
npm install &&\
npm run post-install &&\
npm run build
# Cleanup
RUN apt-get -qq clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# Add user
RUN groupadd -r blessuser && useradd -r -g blessuser -G audio,video blessuser \
&& mkdir -p /home/blessuser/Downloads \
&& chown -R blessuser:blessuser /home/blessuser \
&& chown -R blessuser:blessuser $application_directory
# Run everything after as non-privileged user.
USER blessuser
# Expose the web-socket and HTTP ports
EXPOSE 3000
ENTRYPOINT ["dumb-init", "--"]
CMD [ "node", "./build/index.js" ]