dolthub / dolt

Dolt – Git for Data
Apache License 2.0
17.44k stars 498 forks source link

ARM64 Docker Image does not contain arm binaries #8110

Closed Marmelatze closed 2 weeks ago

Marmelatze commented 2 weeks ago

It looks like the docker image for arm64 on dockerhub does not contain the right binaries. Therfore it cannot be run on arm machines:

$ docker create --platform=linux/arm64  dolthub/dolt:latest
39f100cd42da3f2d453086faf0a243c7e13e64a4b74e3311c97ae52a493b9668
$ docker cp 39f100cd42da3f2d453086faf0a243c7e13e64a4b74e3311c97ae52a493b9668:/usr/local/bin/dolt .
Successfully copied 100MB to /tmp/.
$ file dolt
dolt: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), statically linked, Go BuildID=dWoZQviT7IJ7KfQUQaNH/tdyTiXo2uWNTeThpxB5N/ZkepMIlOFzZyweXbmbPR/1r9FCW-2uEGMKbNrPUH4, stripped
$ docker info
Client: Docker Engine - Community
 Version:    27.0.3
 Context:    default
 Debug Mode: false
 Plugins:
  buildx: Docker Buildx (Docker Inc.)
    Version:  v0.15.1
    Path:     /usr/libexec/docker/cli-plugins/docker-buildx
  compose: Docker Compose (Docker Inc.)
    Version:  v2.28.1
    Path:     /usr/libexec/docker/cli-plugins/docker-compose

Server:
 Containers: 2
  Running: 0
  Paused: 0
  Stopped: 2
 Images: 1
 Server Version: 27.0.3
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Using metacopy: false
  Native Overlay Diff: true
  userxattr: false
 Logging Driver: json-file
 Cgroup Driver: systemd
 Cgroup Version: 2
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local splunk syslog
 Swarm: inactive
 Runtimes: io.containerd.runc.v2 runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: ae71819c4f5e67bb4d5ae76a6b735f29cc25774e
 runc version: v1.1.13-0-g58aa920
 init version: de40ad0
 Security Options:
  apparmor
  seccomp
   Profile: builtin
  cgroupns
 Kernel Version: 5.10.0-30-arm64
 Operating System: Debian GNU/Linux 11 (bullseye)
 OSType: linux
 Architecture: aarch64
 CPUs: 4
 Total Memory: 7.758GiB
 Name: civai
 ID: 80e10b48-174a-4b19-8af9-96143102d5a0
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false
timsehn commented 2 weeks ago

@coffeegoddd or @reltuk will look at this

fulghum commented 2 weeks ago

Thanks for reporting this one. @coffeegoddd and I were just poking around and didn't see any obvious problems in the docker build scripts, but we'll keep digging in to find what's happening here.

Marmelatze commented 2 weeks ago

I think the problem is that BUILDARCH is the archtiecture of the build host an not of the target. TARGETARCH would be the right variable according to the docs: https://docs.docker.com/build/building/variables/#multi-platform-build-arguments

coffeegoddd commented 2 weeks ago

@Marmelatze Thanks for submitting this issue!

I did some investigation into our DockerHub image release process and from what I can tell, it is pretty broken for arm64. I don't think it has ever worked, actually.

We attempt to use the docker/build-push-action action to build dolthub/dolt and dolthub/dolt-sql-server on multiple platforms, but the Dockerfile definitions aren't quiet right for doing this...

As you've pointed out, even the BUILDARCH variable isn't quiet right. I'm planning to fix this and get this working properly, but it will take a bit of finagling, and I'll be out of the office until next week.

In the meantime I've included some Dockerfile definitions you can use to successfully create arm64 images, so that you aren't blocked, until my fix is in:

For a dolthub/dolt arm64 image for Dolt v1.41.3 you can use:

FROM --platform=linux/arm64 ubuntu:22.04

ENV DOLT_VERSION=1.41.3

RUN apt update -y && \
    apt install -y \
        tini \
        ca-certificates && \
    apt clean && \
    rm -rf /var/lib/apt/lists/*

ADD https://github.com/dolthub/dolt/releases/download/v${DOLT_VERSION}/dolt-linux-arm64.tar.gz dolt-linux-arm64.tar.gz
RUN tar zxvf dolt-linux-arm64.tar.gz && \
    cp dolt-linux-arm64/bin/dolt /usr/local/bin && \
    rm -rf dolt-linux-arm64 dolt-linux-arm64.tar.gz

WORKDIR /var/lib/dolt
ENTRYPOINT ["tini", "--", "/usr/local/bin/dolt"]

You can build this image with docker build -t dolt:v1.41.3 -f Dockerfile ., and then run it with docker run dolt:v1.41.3.

For a dolthub/dolt-sql-server arm64 image for Dolt v1.41.3 you can use:

FROM --platform=linux/arm64 ubuntu:22.04

ENV DOLT_VERSION=1.41.3

RUN apt update -y && \
    apt install -y \
        tini \
        ca-certificates && \
    apt clean && \
    rm -rf /var/lib/apt/lists/*

ADD https://github.com/dolthub/dolt/releases/download/v${DOLT_VERSION}/dolt-linux-arm64.tar.gz dolt-linux-arm64.tar.gz
RUN tar zxvf dolt-linux-arm64.tar.gz && \
    cp dolt-linux-arm64/bin/dolt /usr/local/bin && \
    rm -rf dolt-linux-arm64 dolt-linux-arm64.tar.gz

RUN mkdir /docker-entrypoint-initdb.d
VOLUME /var/lib/dolt

COPY ./docker-entrypoint.sh /usr/local/bin/
RUN chmod +x /usr/local/bin/docker-entrypoint.sh

EXPOSE 3306 33060
WORKDIR /var/lib/dolt
ENTRYPOINT ["tini", "--", "docker-entrypoint.sh"]

You can build this image with docker build -t dolt-sql-server:v1.41.3 -f Dockerfile ., and then run it with docker run dolt-sql-server:v1.41.3. Note you will need a copy of docker-entrypoint.sh next to the Dockerfile for this to build successfully, since it contains a COPY statement.

coffeegoddd commented 2 weeks ago

@Marmelatze Actually, I had some time to fix this before my vacation. Docker images are fixed for Dolt >= 1.41.4.

% docker create --platform=linux/arm64  dolthub/dolt:1.41.4
Unable to find image 'dolthub/dolt:1.41.4' locally
1.41.4: Pulling from dolthub/dolt
4ce000a43472: Already exists 
a4c27a1e8138: Pull complete 
558316364871: Pull complete 
d7c8812eaf64: Pull complete 
c723a631958f: Pull complete 
Digest: sha256:709b88ddf77e602c129f363ee068190fcf56fc8b7aefac62445a03ea12e1fb4d
Status: Downloaded newer image for dolthub/dolt:1.41.4
cbe0802d7029c66fe449ca644f597da06aa73816c1d40e22c6ad0e88e8d947a0
% docker cp cbe0802d7029c66fe449ca644f597da06aa73816c1d40e22c6ad0e88e8d947a0:/usr/local/bin/dolt .
                             Successfully copied 97.1MB to /Users/dustin/src/ld/.
% file ./dolt
./dolt: ELF 64-bit LSB executable, ARM aarch64, version 1 (SYSV), statically linked, Go BuildID=zV3iJYE8d8fGl_tL2v_q/Au58OCAEMA4OPTqEFp1_/i6mx-B9qwkygMc9t-zuW/ZyG9Kl0IHoYjmejp0SbO, stripped
% rm ./dolt
% docker create --platform=linux/amd64  dolthub/dolt:1.41.4                                     
Unable to find image 'dolthub/dolt:1.41.4' locally
1.41.4: Pulling from dolthub/dolt
3713021b0277: Already exists 
981eb1c518ed: Pull complete 
171c492a2a4e: Pull complete 
2914ef3228d2: Pull complete 
75f8143a59cb: Pull complete 
Digest: sha256:709b88ddf77e602c129f363ee068190fcf56fc8b7aefac62445a03ea12e1fb4d
Status: Downloaded newer image for dolthub/dolt:1.41.4
d5fcc161b1d80dd6e9dc9f0720b6fb2f0c8b07fa902c6a7e87f1142105582e16
% docker cp d5fcc161b1d80dd6e9dc9f0720b6fb2f0c8b07fa902c6a7e87f1142105582e16:/usr/local/bin/dolt .
                               Successfully copied 100MB to /Users/dustin/src/ld/.
% file ./dolt                                                                                     
./dolt: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), statically linked, Go BuildID=GYoOvPaBuN3_SwKCe-AL/hRp6IvzeTbOEmHerStHC/y1PabwQ99qV2y3G6sSlX/7DEEYi2-H4RbYfgbXgmd, stripped
bpf120 commented 2 weeks ago

@Marmelatze , we'd love to learn about your Dolt use case. Feel free to email me or swing by our Discord if you'd like to share.