From 717acde2e523a31a029808292e03d652a736a0ea Mon Sep 17 00:00:00 2001 From: Mike Ross <4534713+madmikeross@users.noreply.github.com> Date: Sat, 16 Dec 2023 19:02:42 -0700 Subject: [PATCH] Setup Docker build (#4) --- Cargo.lock | 154 ++++++++------------------------------------- Cargo.toml | 5 +- Dockerfile | 12 ++++ README.md | 9 ++- docker-compose.yml | 21 +++++++ src/main.rs | 6 +- 6 files changed, 73 insertions(+), 134 deletions(-) create mode 100644 Dockerfile create mode 100644 docker-compose.yml diff --git a/Cargo.lock b/Cargo.lock index dad62c1..6763d61 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -269,16 +269,6 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" -[[package]] -name = "errno" -version = "0.3.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f258a7194e7f7c2a7837a8913aeab7fd8c383457034fa20ce4dd3dcb813e8eb8" -dependencies = [ - "libc", - "windows-sys", -] - [[package]] name = "eve-graph" version = "0.1.0" @@ -286,6 +276,7 @@ dependencies = [ "chrono", "futures", "neo4rs", + "openssl", "reqwest", "serde", "serde_json", @@ -295,12 +286,6 @@ dependencies = [ "warp", ] -[[package]] -name = "fastrand" -version = "2.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25cbce373ec4653f1a01a31e8a5e5ec0c622dc27ff9c4e6606eefef5cbbed4a5" - [[package]] name = "fnv" version = "1.0.7" @@ -561,16 +546,17 @@ dependencies = [ ] [[package]] -name = "hyper-tls" -version = "0.5.0" +name = "hyper-rustls" +version = "0.24.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905" +checksum = "ec3efd23720e2049821a693cbc7e65ea87c72f1c58ff2f9522ff332b1491e590" dependencies = [ - "bytes", + "futures-util", + "http", "hyper", - "native-tls", + "rustls", "tokio", - "tokio-native-tls", + "tokio-rustls", ] [[package]] @@ -637,24 +623,12 @@ dependencies = [ "wasm-bindgen", ] -[[package]] -name = "lazy_static" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" - [[package]] name = "libc" version = "0.2.150" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "89d92a4743f9a61002fae18374ed11e7973f530cb3a3255fb354818118b2203c" -[[package]] -name = "linux-raw-sys" -version = "0.4.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "969488b55f8ac402214f3f5fd243ebb7206cf82de60d3172994707a4bcc2b829" - [[package]] name = "lock_api" version = "0.4.11" @@ -731,24 +705,6 @@ dependencies = [ "version_check", ] -[[package]] -name = "native-tls" -version = "0.2.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07226173c32f2926027b63cce4bcd8076c3552846cbe7925f3aaffeac0a3b92e" -dependencies = [ - "lazy_static", - "libc", - "log", - "openssl", - "openssl-probe", - "openssl-sys", - "schannel", - "security-framework", - "security-framework-sys", - "tempfile", -] - [[package]] name = "neo4rs" version = "0.7.0-rc.3" @@ -771,7 +727,7 @@ dependencies = [ "tokio", "tokio-rustls", "url", - "webpki-roots", + "webpki-roots 0.23.1", ] [[package]] @@ -845,10 +801,13 @@ dependencies = [ ] [[package]] -name = "openssl-probe" -version = "0.1.5" +name = "openssl-src" +version = "300.2.1+3.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" +checksum = "3fe476c29791a5ca0d1273c697e96085bbabbbea2ef7afd5617e78a4b40332d3" +dependencies = [ + "cc", +] [[package]] name = "openssl-sys" @@ -858,6 +817,7 @@ checksum = "40a4130519a360279579c2053038317e40eff64d13fd3f004f9e1b72b8a6aaf9" dependencies = [ "cc", "libc", + "openssl-src", "pkg-config", "vcpkg", ] @@ -1089,26 +1049,28 @@ dependencies = [ "http", "http-body", "hyper", - "hyper-tls", + "hyper-rustls", "ipnet", "js-sys", "log", "mime", - "native-tls", "once_cell", "percent-encoding", "pin-project-lite", + "rustls", + "rustls-pemfile", "serde", "serde_json", "serde_urlencoded", "system-configuration", "tokio", - "tokio-native-tls", + "tokio-rustls", "tower-service", "url", "wasm-bindgen", "wasm-bindgen-futures", "web-sys", + "webpki-roots 0.25.3", "winreg", ] @@ -1153,19 +1115,6 @@ version = "0.1.23" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" -[[package]] -name = "rustix" -version = "0.38.25" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc99bc2d4f1fed22595588a013687477aedf3cdcfb26558c559edb67b4d9b22e" -dependencies = [ - "bitflags 2.4.1", - "errno", - "libc", - "linux-raw-sys", - "windows-sys", -] - [[package]] name = "rustls" version = "0.21.9" @@ -1213,15 +1162,6 @@ version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1ad4cc8da4ef723ed60bced201181d83791ad433213d8c24efffda1eec85d741" -[[package]] -name = "schannel" -version = "0.1.22" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c3733bf4cf7ea0880754e19cb5a462007c4a8c1914bff372ccc95b464f1df88" -dependencies = [ - "windows-sys", -] - [[package]] name = "scoped-tls" version = "1.0.1" @@ -1244,29 +1184,6 @@ dependencies = [ "untrusted 0.9.0", ] -[[package]] -name = "security-framework" -version = "2.9.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05b64fb303737d99b81884b2c63433e9ae28abebe5eb5045dcdd175dc2ecf4de" -dependencies = [ - "bitflags 1.3.2", - "core-foundation", - "core-foundation-sys", - "libc", - "security-framework-sys", -] - -[[package]] -name = "security-framework-sys" -version = "2.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e932934257d3b408ed8f30db49d85ea163bfe74961f017f405b025af298f0c7a" -dependencies = [ - "core-foundation-sys", - "libc", -] - [[package]] name = "serde" version = "1.0.192" @@ -1426,19 +1343,6 @@ dependencies = [ "libc", ] -[[package]] -name = "tempfile" -version = "3.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ef1adac450ad7f4b3c28589471ade84f25f731a7a0fe30d71dfa9f60fd808e5" -dependencies = [ - "cfg-if", - "fastrand", - "redox_syscall", - "rustix", - "windows-sys", -] - [[package]] name = "thiserror" version = "1.0.50" @@ -1504,16 +1408,6 @@ dependencies = [ "syn 2.0.39", ] -[[package]] -name = "tokio-native-tls" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbae76ab933c85776efabc971569dd6119c580d8f5d448769dec1764bf796ef2" -dependencies = [ - "native-tls", - "tokio", -] - [[package]] name = "tokio-rustls" version = "0.24.1" @@ -1826,6 +1720,12 @@ dependencies = [ "rustls-webpki 0.100.3", ] +[[package]] +name = "webpki-roots" +version = "0.25.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1778a42e8b3b90bff8d0f5032bf22250792889a5cdc752aa0020c84abe3aaf10" + [[package]] name = "winapi" version = "0.3.9" diff --git a/Cargo.toml b/Cargo.toml index f2264f9..6aaf6ec 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -reqwest = { version = "0.11", features = ["blocking", "json", "serde_json"] } +reqwest = { version = "0.11", default-features = false, features = ["blocking", "json", "serde_json", "rustls-tls"] } serde = { version = "1", features = ["derive"] } serde_json = "1.0" neo4rs = "0.7.0-rc.3" @@ -15,4 +15,5 @@ futures = "0.3.29" uuid = "1.6.0" thiserror = "1.0.50" warp = "0.3.6" -chrono = "0.4.31" \ No newline at end of file +chrono = "0.4.31" +openssl = { version = "0.10", features = ["vendored"] } diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..d00dfc0 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,12 @@ +FROM messense/rust-musl-cross:x86_64-musl as builder +WORKDIR /eve-graph +# Copy the source +COPY . . +# Build the app +RUN cargo build --release --target x86_64-unknown-linux-musl + +# Create a new stage with minimal image +FROM scratch +COPY --from=builder /eve-graph/target/x86_64-unknown-linux-musl/release/eve-graph /eve-graph +ENTRYPOINT ["/eve-graph"] +EXPOSE 8008 \ No newline at end of file diff --git a/README.md b/README.md index fe2dd17..795b578 100644 --- a/README.md +++ b/README.md @@ -34,8 +34,13 @@ the endpoint to assign a risk to each jump: curl -X POST 127.0.0.1:8008/systems/risk ``` -Next, you need to build the `jump-risk` graph in neo4j. Refere to the `build_jump_risk_graph` function in the database +Next, you need to build the `jump-risk` graph in neo4j. Refer to the `build_jump_risk_graph` function in the database module for the query you should run. Last, you need to run a query similar to the `find_shortest_route` function in the database module with a couple modifications in order to find the safest path. Simply substitute `jump-risk` for `system-map` and `risk` for `cost` (and put in your source and destination system names) and you should have a "safe" route -which is also likely shorter than the high sec route. \ No newline at end of file +which is also likely shorter than the high sec route. + +### Running with Docker +A fully functioning docker build for the app is not yet complete. Neo4j will come up, but we still need to install the +data science plugin. The app will start, but requests to ESI from within the container are completing too quickly, and +better logging needs to be added to debug the issue further. \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..58c4023 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,21 @@ +version: '3' +services: + api: + build: + context: . + dockerfile: Dockerfile + ports: + - "8008:8008" + depends_on: + - neo4j + neo4j: + image: neo4j:5.14-community-bullseye + ports: + - "7474:7474" + - "7687:7687" + volumes: + - neo4j_data:/data/ + environment: + - NEO4J_AUTH:neo4j/neo4jneo4j +volumes: + neo4j_data: \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index 0004299..08f988e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -23,6 +23,7 @@ mod eve_scout; #[tokio::main] async fn main() { + println!("Starting eve-graph"); let client = Client::new(); let graph = get_graph_client().await; @@ -65,9 +66,8 @@ async fn main() { .or(stargates_routes) .recover(handle_rejection); - warp::serve(service_routes) - .run(([127, 0, 0, 1], 8008)) - .await; + println!("Serving routes on 8008"); + warp::serve(service_routes).run(([0, 0, 0, 0], 8008)).await; } fn with_client(client: Client) -> impl Filter + Clone {