Currently it is a challenge to build a small Docker image for postgis and psm2pgsql. This is due to a package in Alpine testing.
With the help of a few GitHub projects I managed to create the images. I will document my steps here.
Instead of raspbian I use hypriot as my OS for hosting Docker containers.
SSH into your Raspberry Pi and create a source folder if you don't already have one.
mkdir src
cd src
I found a good project that helps in building Alpine packages: dnephin/docker-apk-build. I adapted this project to be able to compile for Alpine 3.10.
git clone https://github.com/Duvel/docker-apk-build
cd docker-apk-build
You can start the build environment with:
make build
and a build image will be created and started.
First you need to do some setup:
~/bin/setup.sh
The problematic package is proj4 and the newest version 6 also gives issues when compiling with osm2pgsql, so we will checkout version 5.2.0. After that we will create and sign the image.
git checkout 9f72f605cf4187e49a9b311c82084faa2174e5cc
cd /work/testing/proj4/
abuild -c -r -P /target
cd /target/testing/armv7/
apk index -o APKINDEX.tar.gz *.apk
abuild-sign APKINDEX.tar.gz
exit
Leave the build folder:
cd ~/src
I created a clone of the docker postgis image appropriate/docker-postgis and adjusted it to use the locally build package.
git clone https://github.com/Duvel/docker-postgis
cd docker-postgis/10-2.5/alpine
Copy the build package and keys to the build-dir:
cp -r ~/src/docker-apk-build/target .
cp -r ~/src/docker-apk-build/user.abuild .
Now you can build the image:
docker build -t duvel/postgis:10-alpine-armv6 .
Leave the build folder:
cd ~/src
Now we also can build the osm2pgsql image, which I cloned from stefda/osm2pgsql.
git clone https://github.com/Duvel/osm2pgsql
cd osm2pgsql
Copy the build package and keys to the build-dir:
cp -r ~/src/docker-apk-build/target .
cp -r ~/src/docker-apk-build/user.abuild .
Now you can build the image:
docker build -t duvel/osm2pgsql:0.96-armv6 .
Leave the build folder:
cd ~/src
I pushed the final images to the docker hub, so you can easily pull them: