Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

S7IPA-168 Add extra base images support #3

Merged
merged 35 commits into from
Jul 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
1e8b074
S7IPA-169 Add support for extra base images other than ubuntu
rcmorano Jul 3, 2020
48fb482
iter0
rcmorano Jul 3, 2020
0edf7d8
fix dpl gem install
rcmorano Jul 6, 2020
54fcd50
added missing dpl subcommand
rcmorano Jul 6, 2020
fc29a69
fixed repo/slug arg
rcmorano Jul 6, 2020
159396b
changin the approach to attach files to release from dpl
rcmorano Jul 6, 2020
0bb6893
changing dpl by a nodejs cli tool... let's see, it worked locally :D
Jul 6, 2020
307d0d4
adding sudo for depends install..
Jul 6, 2020
b866d2d
fifififix
Jul 6, 2020
436be26
fixing git tag
Jul 6, 2020
eeaacf6
tumbleweed
Jul 6, 2020
f231426
.....
Jul 6, 2020
18cd87a
added new build target: ruby:2.4-jessie image (used in e2e Dockerfile)
Jul 7, 2020
648a33c
updated to use debian base images instead of ruby ones
Jul 7, 2020
63e5a56
added RVM ruby minimal version install for fpm gem to work on debian-…
Jul 7, 2020
8a5fa45
fixed fpm gem install order
Jul 7, 2020
6c2dc4f
fixed rvm
Jul 7, 2020
c970a73
fixing rvm2
Jul 7, 2020
a75421e
changing file existance check strategy
Jul 7, 2020
4de1ac6
changed file inclusion from source to . (bash vs sh :s)
Jul 7, 2020
2a9e9fc
wrapped commands in bash to allow rvm to work (hopefully)
Jul 7, 2020
483d529
fixing quotes mess...
Jul 7, 2020
a0186f9
moved everything into a single fpm script...
Jul 7, 2020
62c0d91
removed fail on error btm... (forgot about the $? checks u_u)
Jul 7, 2020
0c2a033
changed codename by version-id (which is not present on debian-8 image)
Jul 7, 2020
e133ddf
typo
Jul 7, 2020
5ef260c
fix++
Jul 7, 2020
f9c7bcf
replaced git-commit-tagged data tgz
Jul 8, 2020
204aada
grr
Jul 8, 2020
95993f4
tar.gz -> tgz
Jul 8, 2020
24779d9
workaround ruby_postal include path...
Jul 8, 2020
ddb2b68
added $DEB_PACKAGE_STUART_VERSION so package can be upgraded from new…
Jul 9, 2020
2b4696f
fine tuning release version extracted from deb pkg version
Jul 9, 2020
f88d3a6
explicitly set datadir so packaged datadir matches
Jul 14, 2020
1affe0c
Merge branch 'master' into rcmorano-S7IPA-169-add-extra-base-images-s…
rcmorano Jul 16, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .github/workflows/docker-builds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ on: [push, pull_request]

env:
DOCKER_IMAGE_BASENAME: libpostal
BASE_IMAGES: "ruby:2.4-jessie ruby:2.4.9-stretch ubuntu:16.04 ubuntu:18.04"

BASE_IMAGES: "debian:8 debian:9 ubuntu:16.04 ubuntu:18.04"

jobs:
build:
Expand Down
24 changes: 10 additions & 14 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,26 @@ FROM ${BASE_IMAGE}
ARG DEB_PACKAGE_NAME="libpostal"
ARG DEB_PACKAGE_DESC="Debian wrapping for https://github.com/openvenues/libpostal"
ARG DEB_PACKAGE_VERSION="0.0.1"
ARG DEB_PACKAGE_STUART_VERSION="1"
ARG BASE_PACKAGES="ruby ruby-dev rubygems build-essential curl autoconf automake libtool pkg-config git gettext"
ENV APT_ARGS="-y -o APT::Install-Suggests=false -o APT::Install-Recommends=false"

RUN apt-get update -qq && \
DEBIAN_FRONTEND=noninteractive apt-get install ${APT_ARGS} ${BASE_PACKAGES} && \
gem install --no-document fpm
DEBIAN_FRONTEND=noninteractive apt-get install ${APT_ARGS} ${BASE_PACKAGES}

# compile libpostal
COPY ./ /src
WORKDIR /src
RUN bash bootstrap.sh && \
mkdir -p /output/usr && \
./configure --prefix=/output/usr && \
./configure --prefix=/output/usr --datadir=/usr/share/libpostal && \
make -j && \
make install

# move out big files from the package
WORKDIR /output
RUN tar -zcf data.tgz usr/share/libpostal && \
rm -rf /output/usr/share/libpostal/*
RUN tar -C / -zcf data.tgz usr/share/libpostal && \
rm -rf /output/usr/share/libpostal/* /usr/share/libpostal

# build deb package
RUN export DEB_PACKAGE_VERSION=$(sed 's|^v||' /src/versions/parser)+git$(bash -c 'cd /src; git rev-parse HEAD | head -c7') && \
envsubst '${DEB_PACKAGE_VERSION}' < /src/assets/fpm-deb-scripts/postinst.sh.tpl > /src/assets/fpm-deb-scripts/postinst.sh && \
fpm -n ${DEB_PACKAGE_NAME} \
-v ${DEB_PACKAGE_VERSION} \
--description "${DEB_PACKAGE_DESC}" \
-s dir \
-t deb \
--after-install /src/assets/fpm-deb-scripts/postinst.sh \
/output/usr=/
RUN bash /src/assets/bin/fpm-packaging
31 changes: 31 additions & 0 deletions assets/bin/fpm-packaging
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/bash

INSTALLED_RUBY_VERSION=$(ruby --version | head -c8 | awk '{print $2}')
# NOTE: latest official ruby ver for jessie is 2.1 and fpm requires >2.3, so we use rvm for jessie
test -z ${FPM_REQUIRED_RUBY_VERSION+x} && FPM_REQUIRED_RUBY_VERSION=2.3

dpkg --compare-versions ${INSTALLED_RUBY_VERSION} ge ${FPM_REQUIRED_RUBY_VERSION}
if [ $? -ne 0 ]
then
command curl -sSL https://rvm.io/mpapis.asc | gpg --import -
command curl -sSL https://rvm.io/pkuczynski.asc | gpg --import -
curl -sSL https://get.rvm.io | bash -s stable
source /etc/profile.d/rvm.sh
rvm install ${FPM_REQUIRED_RUBY_VERSION}
rvm use ${FPM_REQUIRED_RUBY_VERSION}
fi

gem install --no-document fpm

export DEB_PACKAGE_VERSION=$(sed 's|^v||' /src/versions/parser)-${DEB_PACKAGE_STUART_VERSION}+git$(bash -c 'cd /src; git rev-parse HEAD | head -c7')

envsubst '${DEB_PACKAGE_VERSION}' < /src/assets/fpm-deb-scripts/postinst.sh.tpl > /src/assets/fpm-deb-scripts/postinst.sh

fpm -n ${DEB_PACKAGE_NAME} \
-v ${DEB_PACKAGE_VERSION} \
--description "${DEB_PACKAGE_DESC}" \
-s dir \
-t deb \
--after-install /src/assets/fpm-deb-scripts/postinst.sh \
/output/usr=/

12 changes: 9 additions & 3 deletions assets/fpm-deb-scripts/postinst.sh.tpl
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
#!/bin/sh

download_data() {
. /etc/lsb-release
if [ -e /etc/lsb-release ]; then . /etc/lsb-release; fi
if [ -e /etc/os-release ]; then . /etc/os-release; fi
if [ "${DISTRIB_ID}" = "Ubuntu" ]
then
curl -sL https://github.com/StuartApp/libpostal/releases/download/${GH_RELEASE}/ubuntu-${DISTRIB_RELEASE}-data-${GH_RELEASE}.tar.gz | tar -C / -zxf -
curl -sL https://github.com/StuartApp/libpostal/releases/download/${GH_RELEASE}/ubuntu_${DISTRIB_RELEASE}-data.tgz | tar -C / -zxf -
else
# we assume it's debian
curl -sL https://github.com/StuartApp/libpostal/releases/download/${GH_RELEASE}/debian_${VERSION_ID}-data.tgz | tar -C / -zxf -
fi
}

Expand All @@ -16,10 +20,12 @@ after_upgrade() {
after_install() {
echo "Installing data package '${GH_RELEASE}' from GH releases..."
download_data
# workaround ruby_postal not using default include path
ln -nfs /usr/include/libpostal /usr/local/include/libpostal
}

export PACKAGE_VERSION=${DEB_PACKAGE_VERSION}
export GH_RELEASE=$(echo ${PACKAGE_VERSION} | sed 's|+git|-|')
export GH_RELEASE=$(echo ${PACKAGE_VERSION} | sed 's|-.+git|-|')

if [ "${1}" = "configure" -a -z "${2}" ] || \
[ "${1}" = "abort-remove" ]
Expand Down