首页 > 解决方案 > 将 jpostal/libpostal 部署到 EC2 实例中

问题描述

我正在尝试将 jpostal 工件部署到 EC2 实例中,以便我们的 Web 应用程序可以使用该库。据我了解,“scr/main/jniLibs”中的 jni 文件链接到“/usr/local/include/libpostal”和“/usr/local/lib/”中的 c 库。但是,我无权将“libpostal.h”写入“/usr/local/include/libpostal”和“pkgconfig,libpostal.a,libpostal.la,libpostal.so,libpostal.so.1,libpostal.so .1.0.0" 到 EC2 实例中的 "/usr/local/lib/"。有什么解决办法吗?

谢谢。

标签: amazon-web-servicesparsingamazon-ec2street-address

解决方案


I managed to build and save all artefacts into a local folder, e.g. "/app/libpostal/" and then the deployment process is simply copying them to the same folder in a EC2 machine. The key thing is to use ./configure command to specify all the folders to store the artefacts and there is a tricky step where I use my own jpostal_build.sh instead of the default one:

1. Custom "jpostal_build.sh" has 2 lines:

./bootstrap.sh

./configure --libdir=/app/libpostal/jniLibs make install

2. The main script "generate_jpostal_artifacts.sh":

#!/bin/bash
#################################################
## Build jpostal and libpostal artefacts
#################################################
#Install required build tools 

sudo apt-get install curl autoconf automake libtool pkg-config

#Clean up and checkout libpostal from github

sudo rm -rf /app/libpostal

sudo mkdir -p /app/libpostal

sudo chown -R $USER /app

git clone https://github.com/openvenues/libpostal 

cd libpostal

./bootstrap.sh

#Configure data directory and C libraries location 

./configure --prefix=/app/libpostal --datadir=/app/libpostal/datadir

#Build libpostal 

make -j4 make install sudo ldconfig cd ..

#Build jpostal 

rm -rf ./jpostal

git clone https://github.com/openvenues/jpostal.git

cp jpostal_build.sh ./jpostal/build.sh

export PKG_CONFIG_PATH=/app/libpostal/lib/pkgconfig/

pkg-config --cflags --libs libpostal

cd jpostal

./gradlew assemble

cd ..

#################################################
## zip all libpostal/jpostal artifacts for future deployment
################################################# 

cd /app

tar -cvzf totalcheck-libpostal-1.0.0.tar.gz libpostal

#################################################
## Create config file for local
################################################# 

echo $(pwd)/libpostal/jniLibs > /var/tmp/libpostal_configs.txt

echo $(pwd)/libpostal/datadir/libpostal >> /var/tmp/libpostal_configs.txt

推荐阅读