consbio / mbtileserver

Basic Go server for mbtiles
ISC License
657 stars 104 forks source link

Deploy arm64 image to Docker Hub #146

Closed dnlbaldwin closed 2 years ago

dnlbaldwin commented 2 years ago

Hi, I've been experimenting with running mbtileserver on a Raspberry Pi 4 to serve maps on my local network. Would it be possible to deploy the arm64 image created in your GitHub workflow to Docker Hub?

brendan-ward commented 2 years ago

Have you been able to successfully run it on a Raspberry Pi?

Do you specifically need this as a Docker image? We currently have Arm64 binaries on our releases page, e.g., 0.8.2

At the moment I don't have releases building Docker images (I build them locally for x86_64) but it looks theoretically possible to build multi-arch images, but I don't have an easy way to test arm64 images (requires firing up an AWS instance). We also need to add an arm64 Dockerfile.

dnlbaldwin commented 2 years ago

I was able to quickly create a docker image on my RPi4. More than likely not optimized.

FROM golang:1.16-buster

RUN \
    dpkg --add-architecture arm64 && \
    apt-get update && \
    apt-get install -y ca-certificates openssl zip curl jq \
    libsqlite3-dev:arm64 && \
    update-ca-certificates && \
    rm -rf /var/lib/apt

RUN go get github.com/consbio/mbtileserver

WORKDIR /go/bin/

RUN mkdir /go/bin/tilesets

ENTRYPOINT ["mbtileserver"]

There was some funnies with some paths so I had to modify my docker-compose.yml file to be

  map-server:
    image: "192.168.0.42:10000/mbtileserver"
    ports:
      - "8090:8000"
    environment:
      # FIXME the default is /tilesets but the arm image doesn't map there
      - TILE_DIR=/go/bin/tilesets
    volumes:
      - type: bind
        source: ./map-server/data/
        target: /go/bin/tilesets

I've built multi arch node images before with docker buildx using the following guide. I can take a look to see how a go app would work.

https://medium.com/@artur.klauser/building-multi-architecture-docker-images-with-buildx-27d80f7e2408

brendan-ward commented 2 years ago

@dnlbaldwin thanks for looking into the Arm64 Dockerfile so quickly!

It looks like you are setting WORKDIR /go/bin/ which is why the tileset path needed to be updated; it should remain WORKDIR /

Let us know what you find out using buildx; I haven't had a chance yet to investigate that further.

dnlbaldwin commented 2 years ago

I've been able to build a multiarch image using the guide above with the unmodified Dockerfile in this repo. I've pushed both images here:

https://hub.docker.com/repository/docker/danbaldwin/mbtileserver

I've noticed it takes much longer to build overall, but I guess that's due to QEMU being required to emulate arm64. Took around 17 minutes to build on my i7-4760 with 8GB of RAM:

image

You can test arm64 images on amd64 using the following guide by the looks of things:

https://www.stereolabs.com/docs/docker/building-arm-container-on-x86/