-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile.local
78 lines (67 loc) · 4.74 KB
/
Dockerfile.local
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
FROM jsreport/worker:local
USER root
# phantomjs and electron
RUN apt-get update && \
add-apt-repository ppa:litenstein/libicu60-xenial && \
apt-get update && \
apt-get install -y libgtk2.0-dev libpango1.0-dev libharfbuzz-dev libharfbuzz-icu0 libicu60 && \
apt-get install -y bzip2 libxtst-dev libxss1 libgconf2-dev libnss3-dev libasound2-dev libnotify4 libxrender1 libxext6 xvfb dbus-x11 && \
apt-get install -y libfontconfig fonts-dejavu-core fonts-dejavu-extra fonts-droid-fallback fonts-tlwg-garuda fonts-tlwg-kinnari fonts-tlwg-laksaman fonts-tlwg-loma fonts-tlwg-mono fonts-tlwg-norasi fonts-tlwg-purisa fonts-tlwg-sawasdee fonts-tlwg-typewriter fonts-tlwg-typist fonts-tlwg-typo fonts-tlwg-umpush fonts-tlwg-waree && \
curl -Lo phantomjs.tar.bz2 https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-1.9.8-linux-x86_64.tar.bz2 && \
tar jxvf phantomjs.tar.bz2 && \
chmod +x phantomjs-1.9.8-linux-x86_64/bin/phantomjs && \
mv phantomjs-1.9.8-linux-x86_64/bin/phantomjs /usr/local/bin/ && \
rm -rf phantomjs* && \
# unoconv - it needs an update of libreoffice on the xenial ubuntu
apt-get -y install unoconv && \
apt-get install -y software-properties-common && \
add-apt-repository ppa:libreoffice/ppa && \
apt-get update && \
apt install -y libreoffice && \
# cleanup
rm -rf /var/lib/apt/lists/* /var/cache/apt/* && \
rm -rf /src/*.deb && \
rm -rf /tmp/*
USER jsreport:jsreport
RUN yarn add --ignore-workspace-root-check [email protected] \
RUN yarn cache clean --all && rm -rf /tmp/*
# extensions from packages should already be there in the jsreport/worker image
# we just need to define the env var locations for the rest of extensions
ENV extensions_ejs /app/packages/jsreport-ejs
ENV extensions_pug /app/packages/jsreport-pug
ENV extensions_electronPdf /app/packages/jsreport-electron-pdf
ENV extensions_htmlToText /app/packages/jsreport-html-to-text
ENV extensions_docxTemplater /app/packages/jsreport-docxtemplater
ENV extensions_htmlEmbeddedInDocx /app/packages/jsreport-html-embedded-in-docx
ENV extensions_officePassword /app/packages/jsreport-office-password
ENV extensions_unoconv /app/packages/jsreport-unoconv
ENV extensions_wkhtmltopdf /app/packages/jsreport-wkhtmltopdf
ENV extensions_phantomPdf /app/packages/jsreport-phantom-pdf
ENV extensions_phantomImage /app/packages/jsreport-phantom-image
ENV DISPLAY :99
USER root
# startup script to launch dbus and xvfb correctly along with our app:
# - we ensure that lock files created by Xvfb server (stored at /tmp/ with file names like /tmp/.X99-lock)
# are cleanup correctly on each container run (rm -f /tmp/.X*lock),
# the lock file created by the Xvfb server is a signal that xvfb uses to determine if the server is already running.
# this step is important because the `workers` service is constantly restarting the container (docker restart -t 0) in a "hard" way,
# which does not let the Xvfb server to clean up its lock files correctly, we are cleaning up those lock files manually when the container
# runs to avoid errors like "Fatal server error: Server is already active for display 99 If this server is no longer running, remove /tmp/.X99-lock and start again"
# after restarting the container
# - we ensure that temp folders and files created by xvfb-run (stored at /tmp/ with folder names like /tmp/xvfb-run.4dsfx)
# are cleanup correctly on each container run (rm -rfd /tmp/xvfb-run*)
# this step is important because the `workers` service is constantly restarting the container (docker restart -t 0) in a "hard" way,
# which does not let xvfb-run to clean up its temp files correctly, we are cleaning up those files manually when the container runs
# to avoid having stale folders after restarting the container
# - we use xvfb-run command instead of manually configuring Xvfb server because xvfb-run has a built-in mechanism that waits until the Xvfb server
# its already started before trying to start our app (xvfb-run --server-num=99 --server-args='-screen 0 1024x768x24 -ac' node index.js),
# in case that errors from xvfb needs to be printed to stdout for debugging purposes just pass -e /dev/stdout option (xvfb-run -e /dev/stdout .......)
# the important part of this command is the -ac option in --server-args, -ac disables host-based access control mechanisms in Xvfb server,
# which prevents the connection to the Xvfb server from our app
USER root
CMD rm -f /tmp/.X*lock && rm -rfd /tmp/xvfb-run* && xvfb-run --server-num=99 --server-args='-screen 0 1024x768x24 -ac' node server.js
# debugging
# EXPOSE 9229
# CMD rm -f /tmp/.X*lock && rm -rfd /tmp/xvfb-run* && xvfb-run --server-num=99 --server-args='-screen 0 1024x768x24 -ac' node --inspect-brk=0.0.0.0:9229 server.js