aboutsummaryrefslogtreecommitdiff
path: root/Earthfile
blob: 9a8c2aa2e2860947acf0305e1b7793ce256292c6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
VERSION 0.7

docker:
  ARG tag=latest

  FROM scratch

  WORKDIR /locus

  COPY +build/locus .
  COPY +build/content ./content
  # https://www.reddit.com/r/docker/comments/8y2zyx/how_to_add_a_empty_directory_to_a_scratch_image/e27oumn/
  COPY +build/new_tmp /tmp

  EXPOSE 1965

  ENTRYPOINT ["./locus"]

  SAVE IMAGE --push ghcr.io/gemrest/locus:$tag

deps:
  ARG rustc="nightly-2024-07-17"

  FROM clux/muslrust:${rustc}

  RUN rustup component add rust-src --toolchain nightly-x86_64-unknown-linux-gnu

build:
  FROM +deps

  WORKDIR /source

  RUN cargo new locus

  WORKDIR /source/locus

  COPY amenadiel/ ./amenadiel/
  COPY Cargo.* .

  RUN cargo build --release -Zbuild-std

  COPY .git .git
  COPY content content
  COPY src src
  COPY build.rs build.rs
  COPY yarte.toml yarte.toml

  RUN --mount=type=cache,target=/source/locus/target \
    --mount=type=cache,target=/root/.cargo/registry \
    cargo build --release --bin locus \
    && strip -s /source/locus/target/x86_64-unknown-linux-musl/release/locus \
    && mv /source/locus/target/x86_64-unknown-linux-musl/release/locus .
  RUN strip -s /source/locus/locus
  RUN mkdir /new_tmp

  SAVE ARTIFACT /source/locus/locus
  SAVE ARTIFACT /source/locus/content
  SAVE ARTIFACT /new_tmp