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

Raspberry #144

Closed
ivanlunardi opened this issue Jul 19, 2019 · 36 comments
Closed

Raspberry #144

ivanlunardi opened this issue Jul 19, 2019 · 36 comments

Comments

@ivanlunardi
Copy link

It is possible to run on Rapberry pi3?

@Duvel
Copy link

Duvel commented Jul 21, 2019

Hi, it is possible to run it on a Raspberry Pi. I compiled the alpine variant on a Raspberry Pi 3 and 4, but currently there is an issue with a package in testing. I'm currently working on a gist how to solve this.

Here is a link to the gist: Build a postgis and osm2pgsql Docker image on a Raspberry Pi.

Finished writing the gist.

@Duvel
Copy link

Duvel commented Jul 21, 2019

I pushed an image to docker: https://hub.docker.com/r/duvel/postgis.

@krasi-georgiev
Copy link

would you push the changes to the official repo as well?

@Duvel
Copy link

Duvel commented Aug 4, 2019

@krasi-georgiev what do you mean with the official repo? Git or docker hub? Because of the specialized build I don't think it is a good idea to push it to git.

@krasi-georgiev
Copy link

I meant docker hub. If proj4 is the only problem , why not try to get this solved upstream?

I am now playing with the new docker buildx command so might be a good way to test it to push multi arch images.

@Duvel
Copy link

Duvel commented Aug 4, 2019

I could push it to docker hub, that would be fine, but could also mean that the other images should als be prepared for this.

Creating an multi-arch image isn't that difficult, but I haven't played yet with the new buildx, so I don't know if that makes it easier.

I'm not sure if solving upstream will help. Problem is that proj4 has been renamed, is now on version 6 (which broke osm2pgsql), is in testing on Alpine and isn't always build for arm if I am correct. So my first action was to get a good recipe to even be able to build it and use it on a Raspberry Pi.

Also when looking at #143 I don't know how smart it currently is to invest time in the current repo's.

@krasi-georgiev
Copy link

hm yeah good point.

I need the arm/v7 arch so will try to follow your gist to create an image for that.

@Duvel
Copy link

Duvel commented Aug 4, 2019

Why do you need a armv7 specific one? AFAIK does this one also runs on armv7.

@krasi-georgiev
Copy link

aah ok, I didn't know, will test it and let you know.

@krasi-georgiev
Copy link

it works with the only problem that when using with an init script doesn't complete the initialization with the error:
pg_ctl: server does not shut down

to replicate you can use this docker-compose file:
https://github.com/arribada/SMARTConnect/blob/master/docker-compose.yml#L1-L19

and the init script is:
https://github.com/arribada/SMARTConnect/blob/master/postgres/initdb.sql

@Duvel
Copy link

Duvel commented Aug 8, 2019

For me the initdb works, but I see that you're using a sql file and not a shell script. SMARTconnect probably uses a different postgis image, that can handle sql scripts. Maybe have a look at the initdb-postgis.sh in this project.

@krasi-georgiev
Copy link

The postgis image uses the official postgres as a base which does support sql as an init script.

The problem is not with the init sql, but that the server doesn't shutdown for some reason.

For me the image size is not that important so I just built a multi arch image from docker-postgis/9.6-2.5/Dockerfile

Here is the Dockerfile that works

FROM --platform=$BUILDPLATFORM postgres:9.6
MAINTAINER Mike Dillon <[email protected]>

ENV POSTGIS_MAJOR 2.3
ENV POSTGIS_VERSION 2.3.*

RUN apt-get update \
      && apt-cache showpkg postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR \
      && apt-get install -y --no-install-recommends \
           postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR=$POSTGIS_VERSION \
           postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR-scripts=$POSTGIS_VERSION \
           postgis=$POSTGIS_VERSION \
      && rm -rf /var/lib/apt/lists/*

RUN mkdir -p /docker-entrypoint-initdb.d
COPY ./initdb-postgis.sh /docker-entrypoint-initdb.d/postgis.sh
COPY ./update-postgis.sh /usr/local/bin

The only change is adding FROM --platform=$BUILDPLATFORM postgres:9.6 and reducing the Postgis Version as apparently 2.5 is not ported to Arm.

Than I used docker buildx to build and push a mutli arch image like:

docker buildx create --name multi
docker buildx create --append   --name multi ssh://[email protected]
docker buildx use multi

docker buildx build --platform linux/amd64,linux/arm/v7 -t arribada/postgis --push .

@Duvel
Copy link

Duvel commented Aug 8, 2019

I did not know you could also supply a sql and just saw that they were using their own postgis-image. I was just looking at the differences.

If it now works for you, it probably is more an issue in alpine then in postgres/postgis or it could be related to the older postgis version.

@krasi-georgiev
Copy link

unfortunately it doesn't work with exactly the same error. I guess a problem with ARM or the 2.3 postgis version.

@krasi-georgiev
Copy link

Just tried it on a laptop and it worked so not an issue with the image, probably ARM or the SD card on the RPI is playing up

@Duvel
Copy link

Duvel commented Aug 8, 2019

I just gave the script a try and it worked for me. So maybe there is an issue with the docker-compose file.

The steps I took:

curl -O https://raw.githubusercontent.com/arribada/SMARTConnect/master/postgres/initdb.sql
docker run -it -v $(pwd)/initdb.sql:/docker-entrypoint-initdb.d/initdb.sql duvel/postgis:10-alpine

@Duvel
Copy link

Duvel commented Aug 8, 2019

I gave the repository a try, but with a slightly adjusted docker-compose and it works for me as well.

version: '3.6'
services:
  postgres:
    image: duvel/postgis:10-alpine
    volumes:
    - ./postgres/initdb.sql:/docker-entrypoint-initdb.d/initdb.sql

@krasi-georgiev
Copy link

ok thanks, I will test with a new SD card as I think that is the problem.

@krasi-georgiev
Copy link

yep all working fine it was the slow SD card

@Loongle
Copy link

Loongle commented Dec 15, 2019

Can this solve the docker installation problem on the raspberry pi??

@phillipross
Copy link
Contributor

@Duvel Scanning the discussion here, there are some interesting bits. Would you be able to enumerate the issues you're currently faced with in getting this to work, and we can determine which ones are postgis specific and try to unblock them if we can. Thanks!

@Duvel
Copy link

Duvel commented Feb 11, 2020

@phillipross I think the status is still the same, issues with the proj package (also gdal) for the alpine version and I'm seeing an unable to locate package for postgis in the debian one, so I'm guessing it is not build by default for ARM.

@GammaGames
Copy link

GammaGames commented Feb 25, 2020

I'm able to download the base postgres images and run them on the pi, but trying to build the postgis images fails for various reasons. Looks like the postgres-12-postgis-3 package isn't available in the debian (buster) flavor, and the alpine version is missing the gdal-dev package, at least for alpine v3.11. It is available in the edge branch though.

Edit: Changing the debian image to just install postgis makes it work successfully

@smellman
Copy link
Contributor

smellman commented Mar 8, 2020

I can build 12-3.0-apline in Ubuntu 19.10 arm64 with Raspberry Pi 4.

@GammaGames
Copy link

I just tried again on the raspi3 with raspbian buster and still ran into the unable to locate package postgresql-12-postgis-3 issue for the 12-3.0. The alpine version is missing the gdal-dev and proj-dev packages.

@GammaGames
Copy link

Verifying @smellman, you can build the image on 19.10 raspi4. You cannot pull and run any images or build the non-alpine version though, so it is still less than ideal.

@Duvel
Copy link

Duvel commented Aug 30, 2020

I was also able to build both the default and alpine variant on Ubuntu 20.04 arm64. So it seems there is better support for arm64 upstream.

@phillipross I think we now can create arm64 images. Is that something to start looking into?

@phillipross
Copy link
Contributor

@Duvel yes!

@Duvel
Copy link

Duvel commented Sep 1, 2020

@phillipross do you know how and where the images are currently created?

I'm going to have a look into this for another project I'm working on:
https://www.docker.com/blog/multi-arch-build-and-images-the-simple-way/
But that is for images build by github.

@phillipross
Copy link
Contributor

The way things are now... the source in the docker-postgis repo consist of scripts and templates for Dockerfiles. There is also a travis-ci configuration which triggers a travis-ci job for each pull request and commit or merge to the main branch. The images are actually built on travis and pushed to dockerhub.

Currently, the travis configuration is simple. It uses a ubuntu 16.04 vm on travis infrastructure with docker and git installed in the VM. I have no first-hand experience with building arm images yet, but the postgis debian images are based on the official postgres images, and I'm pretty sure they have arm builds. I had planned to research how they're doing arm builds for postgres and see if the same could be done for postgis but I haven't had the time to do so.

@Duvel
Copy link

Duvel commented Sep 2, 2020

A quick google showed me we can build arm64 images with travis. Not yet exactly sure enough how, but that can be determined. But when I look at the current Makefile and current structure of the repository, I do think we have a challenge.

I'm going to look if I can get a travis build setup for my other project, only not sure yet when I will have the time.

@phillipross
Copy link
Contributor

The reason I had mentioned the official postgresql images is because this postgis repo was originally influences by the postgresql repo. It might be worth checking out how they go about building the arm images.

@Duvel
Copy link

Duvel commented Sep 4, 2020

Check, I see now, what you mean. I was confused by the official repo, but I needed to look for the special repo for the docker images. This seems to use github for building and not travis. I'll see if I can understand how they build it.

@phillipross
Copy link
Contributor

I'm closing this issue with a reference to issue #216 where more up to date discussion is occurring.

@BigBoulard
Copy link

BigBoulard commented Aug 29, 2023

I pushed an image to docker: https://hub.docker.com/r/duvel/postgis.

@Duvel I tried to pull and load it but there no Postgres role and it seems not to accept the POSTGRES_USER and POSTGRES_PASSWORD env. (I'm not using it on a Raspberry but as a makeshift for my M2 cause I don't see any recent postgis docker image for ARM64 arch)

@Duvel
Copy link

Duvel commented Aug 30, 2023

@BigBoulard I have no issues running it, maybe you could provide more info how you run and connect to postgres. Maybe also have a look at the POSTGRES_HOST_AUTH_METHOD env variable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants