Skip to content
This repository has been archived by the owner on Aug 28, 2023. It is now read-only.

Commit

Permalink
add AWS Lambda target
Browse files Browse the repository at this point in the history
  • Loading branch information
deniszatsepin authored Sep 23, 2020
1 parent 182a178 commit b32dc1b
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ jobs:
target: centos6-x86_64
amazonlinux2_x86_64:
target: amazonlinux2-x86_64
amazonlinux2_lambda:
target: amazonlinux2_lambda
opensuse_leap15_x86_64:
target: opensuse.leap15-x86_64
archlinux_amd64:
Expand Down Expand Up @@ -119,6 +121,7 @@ jobs:
targets/*.rpm
targets/*.7z
targets/*.xz
targets/*.zip
- job: 'self_hosted'
pool:
name: 'docker'
Expand Down
25 changes: 25 additions & 0 deletions after_compile/amazonlinux2_lambda.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/usr/bin/env bash

# We need only binary wkhtmltox files in lambda layer, so we delete all the others
rm -rf /tgt/wkhtmltox/{include,share,lib}

# We need to copy dependencies which are not presented in amazonlinux2 image
libs="libjpeg libpng15 libXrender libfontconfig libfreetype libXext libX11 libxcb libXau libexpat libuuid libbz2"
mkdir -p /tgt/wkhtmltox/lib
for lib in $(echo $libs); do
echo ".*${lib}\.so\.[0-9]{1,2}" | xargs find /usr/lib64 -regextype posix-awk -regex | xargs cp -t /tgt/wkhtmltox/lib/
done

# To be able to create pdf files we need a font.
# There is one (dejavu) in the docker image used for compilation.
cp -r /usr/share/fonts /tgt/wkhtmltox/
cat >/tgt/wkhtmltox/fonts/fonts.conf <<EOL
<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
<dir>/var/task/fonts</dir>
<dir>/opt/fonts</dir>
<cachedir>/tmp/fonts-cache</cachedir>
<config></config>
</fontconfig>
EOL
11 changes: 9 additions & 2 deletions build
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ def compile_docker(config, target, src_dir, tgt_dir, debug=False):
cross = config['docker-targets'][target].get('cross_compile')
dimage = '--user %d:%d %s%s' % (os.getuid(), os.getgid(), config['docker-prefix'], target)
def dshell(wd, cmd):
shell('docker run --rm -v%s:/src -v%s:/tgt -w%s %s %s' % (
os.path.abspath(src_dir), os.path.abspath(tgt_dir), wd, dimage, cmd))
shell('docker run --rm -v%s:/src -v%s:/tgt -v%s:/pkg -w%s %s %s' % (
os.path.abspath(src_dir), os.path.abspath(tgt_dir), os.getcwd(), wd, dimage, cmd))

if not os.path.exists(os.path.join(tgt_dir, 'qt_configured')):
qtconf = config['docker-targets'][target].get('qt_config', 'docker')
Expand All @@ -128,6 +128,10 @@ def compile_docker(config, target, src_dir, tgt_dir, debug=False):
dshell('/tgt/app', '/tgt/qt/bin/qmake /src/wkhtmltopdf.pro CONFIG+=silent')
dshell('/tgt/app', 'make install INSTALL_ROOT=/tgt/wkhtmltox')

script = 'after_compile/%s.sh' % config['docker-targets'][target].get('after_compile', '')
if os.path.exists(os.path.abspath(script)):
dshell('/tgt/app', '/pkg/%s' % script)

def package_docker(config, target, src_dir, iteration, clean=False):
tgt_dir = os.path.join('targets', target)
if clean:
Expand Down Expand Up @@ -164,6 +168,9 @@ def package_docker(config, target, src_dir, iteration, clean=False):
fpacman = '-t pacman'
fpm_args = fpm_args.replace('/usr/local', '/usr')
shell('docker run --rm -v%s:/tgt -w/tgt %s %s' % (os.path.abspath('targets'), fpm_args, fpacman))
elif output == 'lambda_zip':
shell('rm -f targets/%s.zip' % archive)
shell('cd targets/%s/wkhtmltox && zip -r ../../%s.zip *' % (target, archive))

if clean:
shell('rm -fr %s' % tgt_dir)
Expand Down
8 changes: 8 additions & 0 deletions build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,14 @@ docker-targets:
xorg-x11-fonts-Type1
zlib
amazonlinux2_lambda:
source: docker/Dockerfile.centos
args:
from: amazonlinux:2
output: lambda_zip
after_compile: amazonlinux2_lambda
arch: x86_64

opensuse.leap15:
source: docker/Dockerfile.opensuse
args:
Expand Down

0 comments on commit b32dc1b

Please sign in to comment.