aboutsummaryrefslogtreecommitdiff
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
parentstyle: use rustfmt (diff)
downloadseptember-883d2b5fcb44a1aefea214d8199f07f10cda8d7b.tar.xz
september-883d2b5fcb44a1aefea214d8199f07f10cda8d7b.zip
ci(earthly): ditch dockerfile
-rw-r--r--.dockerignore14
-rw-r--r--.earthlyignore7
-rw-r--r--Dockerfile51
-rw-r--r--Earthfile67
4 files changed, 74 insertions, 65 deletions
diff --git a/.dockerignore b/.dockerignore
deleted file mode 100644
index 1f6c60f..0000000
--- a/.dockerignore
+++ /dev/null
@@ -1,14 +0,0 @@
-# Rust
-target/
-**/*.rs.bk
-Cargo.lock
-
-# IDE
-.idea/
-
-# Development
-.env
-
-# Fleet
-.cargo/
-fleet.toml
diff --git a/.earthlyignore b/.earthlyignore
new file mode 100644
index 0000000..2dc9aba
--- /dev/null
+++ b/.earthlyignore
@@ -0,0 +1,7 @@
+**
+
+!.git/
+!src/
+!build.rs
+!Cargo.*
+
diff --git a/Dockerfile b/Dockerfile
deleted file mode 100644
index 9ce262b..0000000
--- a/Dockerfile
+++ /dev/null
@@ -1,51 +0,0 @@
-FROM clux/muslrust:1.69.0 AS environment
-
-ENV CHANNEL=1.69.0
-
-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 -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 fleet-rs
-
-FROM environment as builder
-
-WORKDIR /usr/src
-
-RUN cargo new september
-
-WORKDIR /usr/src/september
-
-COPY Cargo.* .
-
-# RUN fleet build --release
-RUN cargo build --release
-
-COPY . .
-
-RUN --mount=type=cache,target=/usr/src/september/target \
- --mount=type=cache,target=/root/.cargo/registry \
- cargo build --release --bin september \
- && strip -s /usr/src/september/target/x86_64-unknown-linux-musl/release/september \
- && mv /usr/src/september/target/x86_64-unknown-linux-musl/release/september .
-
-FROM scratch
-
-WORKDIR /september
-
-COPY --from=builder /usr/src/september/september .
-
-EXPOSE 80
-
-ENTRYPOINT ["/september/september"]
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
+