Publish a container
Thanks for intlc, it's really cool! We're looking at using it in our setup, which involves running it in a few places, including GitHub Actions.
Would it be possible to publish a Docker container to make it easier to use, especially in GH Actions?
So far we've been using a local image:
FROM debian:12.6-slim AS intlc
ENV LANG=C.UTF-8
ENV LC_ALL=C.UTF-8
ADD https://github.com/unsplash/intlc/releases/download/v0.8.3/intlc-v0.8.3-linux-x86_64 /usr/local/bin/intlc
RUN chmod +x /usr/local/bin/intlc
But using it in Actions might be a bit tricky. (We can probably build and use it in the job itself, but complicated jobs are hard to develop/debug...)
Hey, nice to hear you might find intlc useful! 🙂 I'll look into adding an action shortly.
In the meantime, if you happen to be familiar with Nix, this is the derivation we use at Unsplash for our dev shells incl/ CI:
{ fetchurl, lib, stdenv }:
stdenv.mkDerivation rec {
pname = "intlc";
version = "0.8.3";
src = if stdenv.isDarwin
then fetchurl {
url = "https://github.com/unsplash/intlc/releases/download/v${version}/intlc-v${version}-macos-aarch64";
sha256 = "f4p9q0hlQrPydJQTveVLRdUOsMRPsBE0Lc2NpumHJBA=";
}
else fetchurl {
url = "https://github.com/unsplash/intlc/releases/download/v${version}/intlc-v${version}-linux-x86_64";
sha256 = "+F42fvw/ykOoG9f4rNXvgusioy6MSIjet/jt8ffvJ1I=";
};
dontUnpack = true;
installPhase = ''
mkdir -p $out/bin/
cp $src $out/bin/intlc
chmod +x $out/bin/intlc
'';
meta = {
homepage = "https://github.com/unsplash/intlc";
description = "Compile ICU messages into code.";
license = lib.licenses.mit;
platforms = [ "x86_64-linux" "aarch64-darwin" ];
};
}
(Though notably as per #99 this wouldn't run on NixOS proper without some dynamic link patching.)
Hey, you can give this a try: https://github.com/unsplash/setup-intlc
For now you'll need to target @master. If it works as expected on your end I'll tag v1. Let me know how you get on!
Thanks @samhh, I managed to get that working in Act locally.
Having a container itself available would still be useful: our current setup has https://github.com/PREreview/prereview.org/blob/201089e90883466bf315a666ab701b5237e0a18d/Dockerfile#L14-L25 which things like Dependabot won't be able to update for us. (That said, it wouldn't know how to update the version in the Action anyhow...)
I was hoping to make the action container-based but then it was unclear how to automate/generalise versioning. By contrast the current solution should continue to work with new releases of intlc provided the releases file pattern is unchanged.
Generally I'd be happy to add a container - you've already got one that works! - but I'm unsure how I could do so in such a way that wouldn't incur a maintenance burden upon all new releases.
Also setup-intlc@v1/[email protected] is now tagged.
Thanks, we're using the Action now.
It should be possible to add steps to your 'publish' job (or, maybe better, a job that follows on) to publish an image without any overhead. Following something like https://github.com/tests-always-included/mo/blob/7e86c1a5f525f352983077d743c2ce2f5d75f4fa/.github/workflows/release.yaml#L29-L45 to deploy to GitHub's Container Registry looks reasonably straightforward (but I've not tried this before... 😅).
Turns out our container didn't work on Apple silicon: https://github.com/PREreview/prereview.org/commit/0260b8183fe73e0f21b66a5399e60b82efd06d27 mitigates the issue, but does leave Docker emitting a 'InvalidBaseImagePlatform' warning.
I've not had to deal with multi-architecture Docker before, but I think the only way to remove the warning is to make the whole thing multi-architecture. Docker has the BUILDARCH variable available, with values like amd64 and arm64. If intlc were released with thoses suffixes (rather than x86_64 and aarch64) I think this could be used:
FROM debian:12.6-slim AS intlc
ARG BUILDARCH
[...]
ADD https://github.com/unsplash/intlc/releases/download/v0.8.3/intlc-v0.8.3-linux-$BUILDARCH /usr/local/bin/intlc
For anybody else trying to get this working within a Docker container on an Apple silicon mac, I was able to do so with the following Dockerfile:
FROM --platform=linux/amd64 debian:12.6-slim AS intlc
ENV LANG=C.UTF-8
ENV LC_ALL=C.UTF-8
ADD https://github.com/unsplash/intlc/releases/download/v0.8.4/intlc-v0.8.4-linux-x86_64 /usr/local/bin/intlc
RUN chmod +x /usr/local/bin/intlc
I'm then also building and running with the --platform linux/amd64 argument:
docker build --platform linux/amd64 -t intlc-tool ./commands/intlc
docker run --platform linux/amd64 --rm -v "$(pwd):/work" -w "/work" intlc-tool intlc compile "$file" -l "$locale" > "$dir/$locale.generated.tsx"