container: Install kcl, tmpl from binaries

`tmpl` takes a long time to compile on a Raspberry Pi, so I've created a
CI pipeline to build it separately.

`kcl` seems to have a [bug][0] that causes it to include the x86_64
builds of `kclvm_cli` and `libkclvm_cli_cdylib.so` on aarch64.  This
naturally doesn't work, so we need to fetch the correct builds
ourselves.

[0]: https://github.com/kcl-lang/cli/issues/31
master
Dustin 2024-01-14 12:23:32 -06:00
parent f0ee31e3b1
commit 8f31b0302c
1 changed files with 18 additions and 16 deletions

View File

@ -3,24 +3,24 @@ FROM registry.fedoraproject.org/fedora-minimal:39 AS build
RUN --mount=type=cache,target=/var/cache \
microdnf install -y \
--setopt install_weak_deps=0 \
cargo \
git \
go \
gzip \
tar \
&& ARCH=$(uname -m) \
&& case "${ARCH}" in \
x86_64) ARCH=amd64 ;; \
aarch64) ARCH=arm64 ;; \
esac \
&& url="https://github.com/kcl-lang/lib/raw/v0.7.5/lib/linux-${ARCH}/" \
&& curl -fsSL "${url}/kclvm_cli" -o /usr/local/bin/kclvm_cli \
&& curl -fsSL "${url}/libkclvm_cli_cdylib.so" \
-o /usr/local/bin/libkclvm_cli_cdylib.so \
&& chmod +x /usr/local/bin/kclvm_cli \
&& url="https://github.com/kcl-lang/cli/releases/download/v0.7.2/kcl-v0.7.2-linux-${ARCH}.tar.gz" \
&& curl -fsSL "${url}" \
| tar -C /usr/local/bin -xz kcl \
&& :
RUN --mount=type=cache,target=/root/go \
go install kcl-lang.io/cli/cmd/kcl@v0.7 \
&& /root/go/bin/kcl > /dev/null \
&& cp /root/go/bin/* /usr/local/bin/ \
&& :
RUN --mount=type=cache,target=/root/.cargo \
cargo install --git https://git.pyrocufflink.net/dustin/tmpl.git \
&& cp /root/.cargo/bin/tmpl /usr/local/bin \
&& :
FROM registry.fedoraproject.org/fedora-minimal:39
FROM git.pyrocufflink.net/containerimages/tmpl
RUN --mount=type=cache,target=/var/cache \
--mount=type=bind,from=build,source=/,target=/build \
@ -42,6 +42,8 @@ COPY nsenter.sh /usr/local/bin/nsenter.sh
COPY config.sh /
ENTRYPOINT []
CMD ["/config.sh"]
ENV KCL_GO_DISABLE_ARTIFACT=on