forked from marlosirapuan/dokku-wkhtmltopdf
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pre-build
executable file
·36 lines (34 loc) · 2.1 KB
/
pre-build
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
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
APP="$2"; IMAGE="dokku/$APP"
CERTIFICATE_PASSWORD=$(docker run --rm $IMAGE cat app/.env | grep CERTIFICATE_PASSWORD | cut -d '=' -f2 | cut -d '"' -f2)
echo "-----> Installing pdiolibs libs ..."
COMMAND=$(cat <<EOF
echo deb http://cz.archive.ubuntu.com/ubuntu focal main universe >> /etc/apt/sources.list
apt-get -y update
apt-get install -y -q --no-install-recommends ghostscript curl poppler-utils fontconfig libfontconfig1-dev libfreetype6-dev libx11-dev libxext-dev libxrender-dev xfonts-base xfonts-75dpi fonts-freefont-ttf fonts-liberation ttf-dejavu
echo "[Start] Enabling GhostScript Fonts..."
echo "/Arial << /FileType /TrueType /Path (/usr/share/fonts/truetype/msttcorefonts/Arial.ttf) /SubfontID 0 /CSI [(Identity) 0] >> ;" >> /usr/share/ghostscript/9.55.0/Resource/Init/cidfmap
echo "/Arial,Bold << /FileType /TrueType /Path (/usr/share/fonts/truetype/msttcorefonts/Arial_Bold.ttf) /SubfontID 0 /CSI [(Identity) 0] >> ;" >> /usr/share/ghostscript/9.55.0/Resource/Init/cidfmap
echo "[Finish] Enabling GhostScript Fonts..."
echo "[Start] Installing WkhtmltoPDF..."
curl -sLO https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6.1-2/wkhtmltox_0.12.6.1-2.jammy_amd64.deb
dpkg -i wkhtmltox_0.12.6.1-2.jammy_amd64.deb
echo "[Finish] Installing WkhtmltoPDF..."
echo "[Start] OpenSSL Certificate Legacy Setup..."
# Gerar private key
openssl pkcs12 -in /app/certificates/pdio_crt.pfx -nocerts -nodes -legacy -password pass:$CERTIFICATE_PASSWORD -out /app/certificates/private.key
# Gerar public key
openssl rsa -in /app/certificates/private.key -pubout -out /app/certificates/public.key
# Gerar certificate
openssl pkcs12 -in /app/certificates/pdio_crt.pfx -clcerts -nokeys -legacy -password pass:$CERTIFICATE_PASSWORD -out /app/certificates/ping.crt
echo "[Finish] OpenSSL Certificate Legacy Setup..."
echo "-----> pdiolibs installed!"
sleep 1 # wait so that docker run has not exited before docker attach
EOF
)
id=$(docker run -d $IMAGE /bin/bash -e -c "$COMMAND")
#enable logs
docker attach $id
test $(docker wait $id) -eq 0
docker commit $id $IMAGE > /dev/null