aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Cargo.toml1
-rw-r--r--Dockerfile9
-rw-r--r--Earthfile10
-rw-r--r--src/main.rs5
4 files changed, 17 insertions, 8 deletions
diff --git a/Cargo.toml b/Cargo.toml
index 1fee096..f09e785 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -21,6 +21,7 @@ members = ["amenadiel"]
opt-level = 3
lto = "fat"
codegen-units = 1
+strip = true
[dependencies]
tokio = { version = "1.38.0", features = ["full"] } # Asynchronous Runtime
diff --git a/Dockerfile b/Dockerfile
index cef3617..c4ca302 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -27,16 +27,17 @@ RUN --mount=type=cache,target=/source/locus/target \
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
-FROM gcr.io/distroless/static:nonroot
+FROM scratch
WORKDIR /locus
COPY --from=build /source/locus/locus .
COPY ./content ./content
-
-# CBA
-USER root
+# 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
diff --git a/Earthfile b/Earthfile
index 0ff237d..14b43ac 100644
--- a/Earthfile
+++ b/Earthfile
@@ -3,15 +3,14 @@ VERSION 0.7
docker:
ARG tag=latest
- FROM gcr.io/distroless/static:nonroot
+ FROM scratch
WORKDIR /locus
COPY +build/locus .
COPY +build/content ./content
-
- # CBA
- USER root
+ # 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
@@ -51,6 +50,9 @@ build:
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
diff --git a/src/main.rs b/src/main.rs
index c2dccb0..0153b04 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -20,6 +20,8 @@ mod xml;
#[macro_use] extern crate log;
+use std::alloc::System;
+
use {
// dotenv::var,
pickledb::PickleDb,
@@ -27,6 +29,9 @@ use {
tokio::time::Instant,
};
+#[global_allocator]
+static A: System = System;
+
const ERROR_HANDLER_RESPONSE: &str =
"The requested resource could not be found at this time. You can try \
refreshing the page, if that doesn't change anything; contact Fuwn! \