diff --git a/Earthfile b/Earthfile new file mode 100644 index 0000000..146eb29 --- /dev/null +++ b/Earthfile @@ -0,0 +1,56 @@ +VERSION 0.7 + +ARG MIX_ENV=test + +deps: + ARG ELIXIR=1.16.0 + ARG OTP=26.1.2 + FROM hexpm/elixir:${ELIXIR}-erlang-${OTP}-alpine-3.17.5 + RUN apk add --no-cache build-base git + WORKDIR /src + RUN mix local.rebar --force + RUN mix local.hex --force + COPY mix.exs mix.lock ./ + COPY --dir lib . + RUN mix deps.get + RUN mix deps.compile --force + RUN mix compile + SAVE ARTIFACT /src/_build AS LOCAL _build + SAVE ARTIFACT /src/deps AS LOCAL deps + +ci: + FROM +deps + COPY .formatter.exs . + RUN mix clean + RUN mix compile --warning-as-errors + RUN mix format --check-formatted + RUN mix credo --strict + +test: + FROM +deps + COPY mix.exs mix.lock ./ + COPY --dir lib ./ + RUN mix test + +release: + FROM +deps + ENV MIX_ENV=prod + RUN apk add xz + RUN wget -q https://ziglang.org/builds/zig-linux-x86_64-0.11.0.tar.xz + RUN tar Jxvf zig-linux-x86_64-*.tar.xz + RUN mkdir -p ~/.local/bin + RUN mv zig-linux-x86_64-*/ ~/.local/bin/zig + COPY mix.exs ./ + COPY --dir lib priv ./ + RUN PATH="${PATH}:${HOME}/.local/bin/zig" mix release + SAVE ARTIFACT /src/burrito_out/exlings_linux /app/exlings AS LOCAL release + +docker: + FROM alpine:3.17.5 + WORKDIR /app + RUN chown nobody /app + USER nobody + COPY +release/app/exlings . + CMD ["./exlings"] + ARG GITHUB_REPO="zoedsoupe/exlings" + SAVE IMAGE --push ghcr.io/$GITHUB_REPO:prod diff --git a/flake.lock b/flake.lock index 2e18cc1..588ac8d 100644 --- a/flake.lock +++ b/flake.lock @@ -2,11 +2,11 @@ "nodes": { "nixpkgs": { "locked": { - "lastModified": 1698318101, - "narHash": "sha256-gUihHt3yPD7bVqg+k/UVHgngyaJ3DMEBchbymBMvK1E=", + "lastModified": 1705133751, + "narHash": "sha256-rCIsyE80jgiOU78gCWN3A0wE0tR2GI5nH6MlS+HaaSQ=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "63678e9f3d3afecfeafa0acead6239cdb447574c", + "rev": "9b19f5e77dd906cb52dade0b7bd280339d2a1f3d", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index 1c65b13..12271da 100644 --- a/flake.nix +++ b/flake.nix @@ -10,15 +10,12 @@ pkgs = import nixpkgs { inherit system; }; - - inherit (pkgs.beam) packagesWith interpreters; - erl = packagesWith interpreters.erlangR26; in { devShells."${system}".default = with pkgs; mkShell { name = "exlings"; packages = - [zig xz _7zz erl.elixir] + [zig xz _7zz elixir_1_16] ++ lib.optional stdenv.isDarwin [ darwin.apple_sdk.frameworks.CoreServices darwin.apple_sdk.frameworks.CoreFoundation diff --git a/mix.exs b/mix.exs index 476a7fe..7703f7f 100644 --- a/mix.exs +++ b/mix.exs @@ -31,8 +31,8 @@ defmodule Exlings.MixProject do burrito: [ targets: [ # macos: [os: :darwin, cpu: :x86_64], - macos_m1: [os: :darwin, cpu: :aarch64] - # linux: [os: :linux, cpu: :x86_64], + macos_m1: [os: :darwin, cpu: :aarch64], + linux: [os: :linux, cpu: :x86_64], # windows: [os: :windows, cpu: :x86_64] ], debug: Mix.env() != :prod