diff options
| author | Fuwn <[email protected]> | 2024-06-24 04:36:20 -0700 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2024-06-24 04:36:20 -0700 |
| commit | a7d1406683e29358a269f0c10df572339eebcf5d (patch) | |
| tree | e3d4e6f672ad38180cb031859fab9e343fbc319c | |
| parent | feat(technology): maths (diff) | |
| download | locus-a7d1406683e29358a269f0c10df572339eebcf5d.tar.xz locus-a7d1406683e29358a269f0c10df572339eebcf5d.zip | |
chore: add fly.io configuration
| -rw-r--r-- | .dockerignore | 9 | ||||
| -rw-r--r-- | Cargo.lock | 75 | ||||
| -rw-r--r-- | Cargo.toml | 2 | ||||
| -rw-r--r-- | Dockerfile | 43 | ||||
| -rw-r--r-- | fly.toml | 33 | ||||
| -rw-r--r-- | src/main.rs | 3 |
6 files changed, 97 insertions, 68 deletions
diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..a873cd5 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,9 @@ +** + +!.git/ +!amenadiel/ +!content/ +!src/ +!build.rs +!Cargo.* +!yarte.toml @@ -109,17 +109,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" [[package]] -name = "atty" -version = "0.2.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" -dependencies = [ - "hermit-abi 0.1.19", - "libc", - "winapi", -] - -[[package]] name = "autocfg" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -442,24 +431,11 @@ dependencies = [ [[package]] name = "env_logger" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44533bbbb3bb3c1fa17d9f2e4e38bbbaf8396ba82193c4cb1b6445d711445d36" -dependencies = [ - "atty", - "humantime 1.3.0", - "log", - "regex", - "termcolor", -] - -[[package]] -name = "env_logger" version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "85cdab6a89accf66733ad5a1693a4dcced6aeff64602b634530dd73c1f3ee9f0" dependencies = [ - "humantime 2.1.0", + "humantime", "is-terminal", "log", "regex", @@ -1215,15 +1191,6 @@ checksum = "2c6201b9ff9fd90a5a3bac2e56a830d0caa509576f0e503818ee82c181b3437a" [[package]] name = "hermit-abi" -version = "0.1.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" -dependencies = [ - "libc", -] - -[[package]] -name = "hermit-abi" version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d77f7ec81a6d05a3abb01ab6eb7590f6083d08449fe5a1c8b1e620283546ccb7" @@ -1285,15 +1252,6 @@ checksum = "d897f394bad6a705d5f4104762e116a75639e470d80901eed05a860a95cb1904" [[package]] name = "humantime" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df004cfca50ef23c36850aaaa59ad52cc70d0e90243c3c7737a4dd32dc7a3c4f" -dependencies = [ - "quick-error", -] - -[[package]] -name = "humantime" version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" @@ -1551,7 +1509,7 @@ version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cb0889898416213fab133e1d33a0e5858a48177452750691bde3666d0fdbaf8b" dependencies = [ - "hermit-abi 0.3.3", + "hermit-abi", "rustix", "windows-sys 0.48.0", ] @@ -1640,7 +1598,7 @@ dependencies = [ "germ", "log", "pickledb", - "pretty_env_logger 0.5.0", + "pretty_env_logger", "rand", "reqwest", "serde", @@ -1851,7 +1809,7 @@ version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" dependencies = [ - "hermit-abi 0.3.3", + "hermit-abi", "libc", ] @@ -2078,21 +2036,11 @@ checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" [[package]] name = "pretty_env_logger" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "926d36b9553851b8b0005f1275891b392ee4d2d833852c417ed025477350fb9d" -dependencies = [ - "env_logger 0.7.1", - "log", -] - -[[package]] -name = "pretty_env_logger" version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "865724d4dbe39d9f3dd3b52b88d859d66bcb2d6a0acfd5ea68a65fb66d4bdc1c" dependencies = [ - "env_logger 0.10.0", + "env_logger", "log", ] @@ -2122,12 +2070,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "744a264d26b88a6a7e37cbad97953fa233b94d585236310bcbc88474b4092d79" [[package]] -name = "quick-error" -version = "1.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" - -[[package]] name = "quote" version = "1.0.36" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -3228,17 +3170,16 @@ checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" [[package]] name = "windmark" -version = "0.3.9" +version = "0.3.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "067db1081f730ba0ca3de472cf4202060e0e9f7aac83208fc225e06dff05f284" +checksum = "60f603f41fdc0ce9876b6eefdcc7cb285acc02aeec92f9e8e23dde251e4322ab" dependencies = [ "async-trait", "log", "matchit", "openssl", "paste", - "pretty_env_logger 0.4.0", - "regex", + "pretty_env_logger", "tokio", "tokio-openssl", "tree_magic", @@ -27,7 +27,7 @@ tokio = { version = "1.38.0", features = ["full"] } # Asynchronous Runtime chrono = "0.4.38" # Date and Time pickledb = "0.5.1" # Database tantivy = "0.19.2" # Full-text Search Engine -windmark = { version = "0.3.9", features = [ +windmark = { version = "0.3.10", features = [ "logger", "auto-deduce-mime", "response-macros", diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..4cf5374 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,43 @@ +FROM clux/muslrust:nightly as dependencies + +RUN rustup component add rust-src --toolchain nightly-x86_64-unknown-linux-gnu + +FROM clux/muslrust:nightly as build + +WORKDIR /source + +RUN cargo new locus + +WORKDIR /source/locus + +COPY amenadiel/ ./amenadiel/ +COPY Cargo.* . + +RUN rustup component add rust-src --toolchain nightly-x86_64-unknown-linux-gnu +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 . + +FROM gcr.io/distroless/static:nonroot + +WORKDIR /locus + +COPY --from=build /source/locus/locus . +COPY ./content ./content + +# CBA +USER root + +EXPOSE 1965 + +ENTRYPOINT ["./locus"] diff --git a/fly.toml b/fly.toml new file mode 100644 index 0000000..f3f0c63 --- /dev/null +++ b/fly.toml @@ -0,0 +1,33 @@ +# fly.toml app configuration file generated for locus on 2024-06-24T04:24:22-07:00 +# +# See https://fly.io/docs/reference/configuration/ for information about how to use this file. +# + +app = 'locus' +primary_region = 'sea' + +[build] + +[[mounts]] + source = 'locus' + destination = '/locus/.locus' + +[http_service] + internal_port = 1965 + force_https = true + auto_stop_machines = true + auto_start_machines = true + min_machines_running = 0 + processes = ['app'] + +[[services]] + protocol = 'tcp' + internal_port = 1965 + + [[services.ports]] + port = 1965 + +[[vm]] + memory = '1gb' + cpu_kind = 'shared' + cpus = 1 diff --git a/src/main.rs b/src/main.rs index d5dab7a..c2dccb0 100644 --- a/src/main.rs +++ b/src/main.rs @@ -21,6 +21,7 @@ mod xml; #[macro_use] extern crate log; use { + // dotenv::var, pickledb::PickleDb, std::sync::{LazyLock, Mutex}, tokio::time::Instant, @@ -59,6 +60,8 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> { router.set_private_key_file(".locus/locus_private.pem"); router.set_certificate_file(".locus/locus_public.pem"); + // router.set_private_key(var("LOCUS_PRIVATE_KEY")?.replace("\\n", "\n")); + // router.set_certificate(var("LOCUS_CERTIFICATE")?.replace("\\n", "\n")); router.set_error_handler(|_| { windmark::response::Response::not_found(ERROR_HANDLER_RESPONSE) }); |