forked from browserless/browserless
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
60 lines (50 loc) · 1.55 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
ARG BASE_VERSION=1.21.0
FROM browserless/base:${BASE_VERSION}
# Build Args
ARG USE_CHROME_STABLE
ARG PUPPETEER_CHROMIUM_REVISION
ARG PUPPETEER_VERSION
ARG PORT=3000
# Application parameters and variables
ENV APP_DIR=/usr/src/app
ENV PUPPETEER_CACHE_DIR=${APP_DIR}
ENV PLAYWRIGHT_BROWSERS_PATH=${APP_DIR}
ENV CONNECTION_TIMEOUT=60000
ENV CHROME_PATH=/usr/bin/google-chrome
ENV HOST=0.0.0.0
ENV IS_DOCKER=true
ENV LANG="C.UTF-8"
ENV NODE_ENV=production
ENV PORT=${PORT}
ENV PUPPETEER_CHROMIUM_REVISION=${PUPPETEER_CHROMIUM_REVISION}
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true
ENV USE_CHROME_STABLE=${USE_CHROME_STABLE}
ENV WORKSPACE_DIR=$APP_DIR/workspace
RUN mkdir -p $APP_DIR $WORKSPACE_DIR
WORKDIR $APP_DIR
# Install app dependencies
COPY . .
# Install Chrome Stable when specified
RUN if [ "$USE_CHROME_STABLE" = "true" ]; then \
cd /tmp &&\
wget -q https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb &&\
dpkg -i google-chrome-stable_current_amd64.deb;\
fi
# Build and install external binaries + assets
# NOTE: The `PUPPETEER_VERSION` is needed for production versions
# listed in package.json
RUN if [ "$USE_CHROME_STABLE" = "true" ]; then \
export CHROMEDRIVER_SKIP_DOWNLOAD=false;\
else \
export CHROMEDRIVER_SKIP_DOWNLOAD=true;\
fi &&\
npm i puppeteer@$PUPPETEER_VERSION;\
npm run postinstall &&\
npm run build &&\
npm prune --production &&\
chown -R blessuser:blessuser $APP_DIR
# Run everything after as non-privileged user.
USER blessuser
# Expose the web-socket and HTTP ports
EXPOSE ${PORT}
CMD ["./start.sh"]