aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFuwn <[email protected]>2024-03-05 05:58:41 -0800
committerFuwn <[email protected]>2024-03-05 05:58:41 -0800
commit71f4b701d0341323f03e33d96f8db59796bbe6ad (patch)
tree0158bc5f527ce0c5fd28086f7b5c9e37f141661e
parentfeat(rustc): bump nightly (diff)
downloadlocus-71f4b701d0341323f03e33d96f8db59796bbe6ad.tar.xz
locus-71f4b701d0341323f03e33d96f8db59796bbe6ad.zip
ci(earthly): switch to earthly from docker
-rw-r--r--.dockerignore12
-rw-r--r--.earthlyignore9
-rw-r--r--Dockerfile63
-rw-r--r--Earthfile62
-rw-r--r--Makefile.toml5
-rw-r--r--docker-compose.yaml7
6 files changed, 71 insertions, 87 deletions
diff --git a/.dockerignore b/.dockerignore
deleted file mode 100644
index ad46f3a..0000000
--- a/.dockerignore
+++ /dev/null
@@ -1,12 +0,0 @@
-# Rust
-target/
-
-# IDE
-.idea/
-
-# Development
-.locus/
-
-# Fleet
-.cargo/
-fleet.toml
diff --git a/.earthlyignore b/.earthlyignore
new file mode 100644
index 0000000..a873cd5
--- /dev/null
+++ b/.earthlyignore
@@ -0,0 +1,9 @@
+**
+
+!.git/
+!amenadiel/
+!content/
+!src/
+!build.rs
+!Cargo.*
+!yarte.toml
diff --git a/Dockerfile b/Dockerfile
deleted file mode 100644
index 33d59e1..0000000
--- a/Dockerfile
+++ /dev/null
@@ -1,63 +0,0 @@
-FROM clux/muslrust:nightly-2024-02-01 AS environment
-
-ENV CHANNEL=nightly-2024-02-01
-
-RUN curl "https://static.rust-lang.org/rustup/archive/${RUSTUP_VER}/${RUST_ARCH}/rustup-init" -o rustup-init \
- && chmod +x rustup-init \
- && ./rustup-init -y --default-toolchain ${CHANNEL} --profile minimal \
- && rm rustup-init \
- && ~/.cargo/bin/rustup target add x86_64-unknown-linux-musl \
- && echo "[build]\ntarget = \"x86_64-unknown-linux-musl\"" > ~/.cargo/config
-
-RUN cargo install sccache
-
-# RUN apt-get update && apt-get install clang-3.9 -y
-
-RUN apt-get update && apt-get install -y gnupg2
-
-RUN curl -fsSL https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add - \
- && apt-get install -y clang
-
-RUN cargo install \
- --git https://github.com/dimensionhq/fleet \
- --rev 693a0d40aaf2dab5acea84ee8de15ec36dd12199 \
- fleet-rs
-
-RUN rustup component add rust-src --toolchain nightly-2024-02-01-x86_64-unknown-linux-gnu
-
-FROM environment as builder
-
-WORKDIR /usr/src
-
-RUN cargo new locus
-
-WORKDIR /usr/src/locus
-
-COPY Cargo.* ./
-
-COPY amenadiel/ ./amenadiel/
-
-RUN fleet build --release -Zbuild-std
-
-COPY . .
-
-RUN --mount=type=cache,target=/usr/src/locus/target \
- --mount=type=cache,target=/root/.cargo/registry \
- fleet build --release --bin locus \
- && strip -s /usr/src/locus/target/x86_64-unknown-linux-musl/release/locus \
- && mv /usr/src/locus/target/x86_64-unknown-linux-musl/release/locus .
-
-FROM gcr.io/distroless/static:nonroot
-
-WORKDIR /locus
-
-COPY --from=builder --chown=nonroot:nonroot /usr/src/locus/locus .
-
-COPY --from=builder --chown=nonroot:nonroot /usr/src/locus/content ./content
-
-# CBA
-USER root
-
-EXPOSE 1965
-
-ENTRYPOINT ["/locus/locus"]
diff --git a/Earthfile b/Earthfile
new file mode 100644
index 0000000..a6cd4ae
--- /dev/null
+++ b/Earthfile
@@ -0,0 +1,62 @@
+VERSION 0.7
+
+docker:
+ ARG tag=latest
+
+ FROM gcr.io/distroless/static:nonroot
+
+ WORKDIR /locus
+
+ COPY +build/locus .
+ COPY +build/content ./content
+
+ # CBA
+ USER root
+
+ EXPOSE 1965
+
+ ENTRYPOINT ["./locus"]
+
+ SAVE IMAGE --push fuwn/locus:$tag
+
+deps:
+ ARG rustc="nightly-2024-02-01"
+
+ FROM clux/muslrust:$rustc
+
+ RUN curl "https://static.rust-lang.org/rustup/archive/${RUSTUP_VER}/${RUST_ARCH}/rustup-init" -o rustup-init \
+ && chmod +x rustup-init \
+ && ./rustup-init -y --default-toolchain $rustc --profile minimal \
+ && rm rustup-init
+ RUN ~/.cargo/bin/rustup target add x86_64-unknown-linux-musl
+ RUN echo "[build]\ntarget = \"x86_64-unknown-linux-musl\"" > ~/.cargo/config
+ RUN rustup component add rust-src --toolchain nightly-2024-02-01-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 .
+
+ SAVE ARTIFACT /source/locus/locus
+ SAVE ARTIFACT /source/locus/content
diff --git a/Makefile.toml b/Makefile.toml
index f900f33..894043b 100644
--- a/Makefile.toml
+++ b/Makefile.toml
@@ -51,8 +51,3 @@ args = [
dependencies = ["checkfc"]
command = "cargo"
args = ["run", "--", "{@}"]
-
-[tasks.docker-build]
-dependencies = ["checkfc"]
-command = "docker"
-args = ["build", "-t", "fuwn/locus:latest", "."]
diff --git a/docker-compose.yaml b/docker-compose.yaml
deleted file mode 100644
index 3da776b..0000000
--- a/docker-compose.yaml
+++ /dev/null
@@ -1,7 +0,0 @@
-services:
- locus:
- ports:
- - "1965:1965"
- volumes:
- - "./.locus:/locus/.locus"
- image: "fuwn/locus:latest"