Open cpswan opened 3 years ago
Hi @cpswan -- definitely glad if this helps. While this started as a personal project, I'm meeting with the team to begin the process of making this an official image. I'll discuss this with them next week to see if that's something that could be supported. For now, this is a community project and I don't have the means to test on other architectures. Would be great if others were willing to pitch in on that.
Thanks @subfuzion - I can definitely rustle up some Arm test kit, and I know @cconstab is keen to try stuff out too.
Good to hear that you might be getting things on a more official footing too :)
Yes! Happy to test on Arm and Arm64 with a box full of Pi's and few other "things"...
Happy to provide remote access to them if that helps with the development..
I've had a go at making Arm and Arm64 versions, but first I needed a multi arch build image:
FROM debian:stable
ARG DART_VERSION="2.12.4"
ARG ARCH="x64"
WORKDIR /tmp/
RUN \
apt-get -q update && apt-get install --no-install-recommends -y -q \
gnupg2 curl git ca-certificates unzip openssh-client && \
curl -O https://storage.googleapis.com/dart-archive/channels/stable/release/$DART_VERSION/sdk/dartsdk-linux-$ARCH-release.zip && \
unzip dartsdk-linux-$ARCH-release.zip -d /usr/lib/ && \
rm dartsdk-linux-$ARCH-release.zip && \
mv /usr/lib/dart-sdk /usr/lib/dart
ENV DART_SDK /usr/lib/dart
ENV PATH $DART_SDK/bin:/root/.pub-cache/bin:$PATH
Which I can use to build arm/arm64 thus:
sudo docker build -t atsigncompany/buildimage --build-arg DART_VERSION=2.12.4 --build-arg ARCH=arm .
With that in hand I could then make an Arm64 version:
# Based on subfuzion/dart-docker-slim
FROM atsigncompany/buildimage AS dart
FROM scratch
# Absolute minimum
COPY --from=dart /lib/ld-linux-aarch64.so.1 /lib/ld-linux-aarch64.so.1
COPY --from=dart /lib/aarch64-linux-gnu/ld-linux-aarch64.so.1 /lib/aarch64-linux-gnu/ld-linux-aarch64.so.1
COPY --from=dart /lib/aarch64-linux-gnu/libdl.so.2 /lib/aarch64-linux-gnu/libdl.so.2
COPY --from=dart /lib/aarch64-linux-gnu/libc.so.6 /lib/aarch64-linux-gnu/libc.so.6
COPY --from=dart /lib/aarch64-linux-gnu/libm.so.6 /lib/aarch64-linux-gnu/libm.so.6
COPY --from=dart /lib/aarch64-linux-gnu/librt.so.1 /lib/aarch64-linux-gnu/librt.so.1
COPY --from=dart /lib/aarch64-linux-gnu/libpthread.so.0 /lib/aarch64-linux-gnu/libpthread.so.0
# For HTTP client requests: name service support
COPY etc-hosts /etc/hosts
COPY --from=dart /etc/nsswitch.conf /etc/nsswitch.conf
COPY --from=dart /etc/resolv.conf /etc/resolv.conf
COPY --from=dart /lib/aarch64-linux-gnu/libnss_dns-2.28.so /lib/aarch64-linux-gnu/libnss_dns-2.28.so
COPY --from=dart /lib/aarch64-linux-gnu/libresolv-2.28.so /lib/aarch64-linux-gnu/libresolv-2.28.so
# For HTTPS client requests: root certificate chain
COPY --from=0 /usr/share/ca-certificates /usr/share/ca-certificates
COPY --from=0 /etc/ssl/certs /etc/ssl/certs
and Arm:
# Based on subfuzion/dart-docker-slim
FROM atsigncompany/buildimage AS dart
FROM scratch
# Absolute minimum
COPY --from=dart /lib/ld-linux-armhf.so.3 /lib/ld-linux-armhf.so.3
COPY --from=dart /lib//arm-linux-gnueabihf/ld-linux-armhf.so.3 /lib//arm-linux-gnueabihf/ld-linux-armhf.so.3
COPY --from=dart /lib/arm-linux-gnueabihf/libdl.so.2 /lib/arm-linux-gnueabihf/libdl.so.2
COPY --from=dart /lib/arm-linux-gnueabihf/libc.so.6 /lib/arm-linux-gnueabihf/libc.so.6
COPY --from=dart /lib/arm-linux-gnueabihf/libm.so.6 /lib/arm-linux-gnueabihf/libm.so.6
COPY --from=dart /lib/arm-linux-gnueabihf/librt.so.1 /lib/arm-linux-gnueabihf/librt.so.1
COPY --from=dart /lib/arm-linux-gnueabihf/libpthread.so.0 /lib/arm-linux-gnueabihf/libpthread.so.0
# For HTTP client requests: name service support
COPY etc-hosts /etc/hosts
COPY --from=dart /etc/nsswitch.conf /etc/nsswitch.conf
COPY --from=dart /etc/resolv.conf /etc/resolv.conf
COPY --from=dart /lib/arm-linux-gnueabihf/libnss_dns.so.2 /lib/arm-linux-gnueabihf/libnss_dns.so.2
COPY --from=dart /lib/arm-linux-gnueabihf/libresolv.so.2 /lib/arm-linux-gnueabihf/libresolv.so.2
# For HTTPS client requests: root certificate chain
COPY --from=0 /usr/share/ca-certificates /usr/share/ca-certificates
COPY --from=0 /etc/ssl/certs /etc/ssl/certs
NB COPY
of /etc/hosts wasn't working for me, so I just copied in a local file etc-hosts
:
127.0.0.1 localhost
::1 localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
I've done a trivial test with some Dart to print out the Platform version (as that includes system arch):
import 'dart:io' show Platform, stdout;
void main() {
print(Platform.version);
}
But haven't yet flexed any muscles with networking etc., though that will come soon with some of the stuff @cconstab is working on.
Hey @cpswan -- this is great work. However, before you invest too much energy into this here in this repo, I should mention that we just created a new repo and we're working with the Docker official images team to get an official image for Dart published. The repo is at dart-lang/dart-docker and we plan to handle multi-arch support through templates (ex: Dockerfile-debian.template) to create the target Dockerfile in the appropriate directory for a particular release channel. I plan to deprecate this repo once that happens. I'll open an issue there and link to this issue for tracking.
I've been planning to use this image to (massively) reduce the image size for some Dart based containers. But I'm also being asked to provide multi arch images for the Apple M1, AWS Graviton and Raspberry Pi folk.
My priority would be arm64, but I guess armv7 would also be useful for earlier Pis.