Skip to content

Commit

Permalink
feat: add earthfile
Browse files Browse the repository at this point in the history
  • Loading branch information
zoedsoupe committed Jan 14, 2024
1 parent fbee591 commit be6597f
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 9 deletions.
56 changes: 56 additions & 0 deletions Earthfile
Original file line number Diff line number Diff line change
@@ -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
6 changes: 3 additions & 3 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 1 addition & 4 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit be6597f

Please sign in to comment.