Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Publish a container #208

Open
thewilkybarkid opened this issue Jul 19, 2024 · 6 comments
Open

Publish a container #208

thewilkybarkid opened this issue Jul 19, 2024 · 6 comments
Assignees

Comments

@thewilkybarkid
Copy link

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...)

thewilkybarkid added a commit to PREreview/prereview.org that referenced this issue Jul 22, 2024
Note the files are currently unused.

Refs #1817, unsplash/intlc#208
@samhh
Copy link
Member

samhh commented Jul 24, 2024

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.)

@samhh samhh self-assigned this Jul 24, 2024
@samhh
Copy link
Member

samhh commented Jul 24, 2024

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!

@thewilkybarkid
Copy link
Author

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...)

@samhh
Copy link
Member

samhh commented Jul 26, 2024

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.

thewilkybarkid added a commit to PREreview/prereview.org that referenced this issue Jul 30, 2024
@thewilkybarkid
Copy link
Author

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... 😅).

@thewilkybarkid
Copy link
Author

Turns out our container didn't work on Apple silicon: PREreview/prereview.org@0260b81 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants