aboutsummaryrefslogtreecommitdiff
path: root/Earthfile
diff options
context:
space:
mode:
authorFuwn <[email protected]>2023-12-12 09:08:04 +0000
committerFuwn <[email protected]>2024-03-17 13:52:56 +0000
commit883d2b5fcb44a1aefea214d8199f07f10cda8d7b (patch)
tree39d13bb42f81b50dd9da1f1dad30944333994bc4 /Earthfile
parentstyle: use rustfmt (diff)
downloadseptember-883d2b5fcb44a1aefea214d8199f07f10cda8d7b.tar.xz
september-883d2b5fcb44a1aefea214d8199f07f10cda8d7b.zip
ci(earthly): ditch dockerfile
Diffstat (limited to 'Earthfile')
-rw-r--r--Earthfile67
1 files changed, 67 insertions, 0 deletions
diff --git a/Earthfile b/Earthfile
new file mode 100644
index 0000000..4eae88e
--- /dev/null
+++ b/Earthfile
@@ -0,0 +1,67 @@
+VERSION 0.7
+
+all:
+ BUILD +docker
+ BUILD +git
+
+docker:
+ ARG tag=latest
+
+ FROM scratch
+
+ COPY +build/september .
+
+ EXPOSE 80
+
+ CMD ["./september"]
+
+ SAVE IMAGE --push fuwn/september:$tag
+
+git:
+ LOCALLY
+
+ RUN git push
+
+deps:
+ ARG rustc="1.69.0"
+
+ 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 \
+ && ~/.cargo/bin/rustup target add x86_64-unknown-linux-musl \
+ && echo "[build]\ntarget = \"x86_64-unknown-linux-musl\"" > ~/.cargo/config
+
+ 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
+
+build:
+ FROM +deps
+
+ WORKDIR /source
+
+ RUN cargo new september
+
+ WORKDIR /source/september
+
+ COPY Cargo.* .
+
+ RUN cargo build --release
+
+ COPY .git .git
+ COPY src src
+ COPY build.rs build.rs
+ COPY Cargo.* .
+
+ RUN --mount=type=cache,target=/source/september/target \
+ --mount=type=cache,target=/root/.cargo/registry \
+ cargo build --release --bin september \
+ && strip -s /source/september/target/x86_64-unknown-linux-musl/release/september \
+ && mv /source/september/target/x86_64-unknown-linux-musl/release/september .
+
+ SAVE ARTIFACT /source/september/september
+