Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
698 changes: 271 additions & 427 deletions Cargo.lock

Large diffs are not rendered by default.

16 changes: 15 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,18 @@ members = [
"heatmap-client", "heatmap-api",
]

resolver = "1"
[workspace.dependencies]
leptos = { version = "0.6.12", features = ["csr", "nightly"] }
serde = {version = "1.0.204", features = ["derive"] }
serde_json = "1.0.120"
chrono = "0.4.38"
log = "0.4.22"
geo = "0.28.0"
base64 = "0.22.1"






resolver = "2"
8 changes: 4 additions & 4 deletions heatmap-api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version = "0.1.0"
edition = "2021"

[dependencies]
chrono = "0.4.38"
leptos = "0.6.12"
serde = "1.0.204"
serde_json = "1.0.120"
chrono = { workspace = true}
leptos = { workspace = true}
serde = {workspace = true}
serde_json = {workspace = true}
15 changes: 7 additions & 8 deletions heatmap-client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,29 +10,28 @@ forced-target = "wasm32-unknown-unknown"
async-std = "1.12.0"
bytemuck = { version = "1.12", features = [ "derive" ] }
cgmath = { version = "0.18.0", features = ["swizzle"] }
chrono = "0.4.38"
console_error_panic_hook = "0.1.7"
console_log = "1.0.0"
earcutr = "0.4.3"
image = "0.25.1"
leptos = { version = "0.6.12", features = ["csr", "nightly"] }
leptosfmt = "0.1.18"
log = "0.4.21"
reqwest = { version = "0.12.5", features = ["json"] }
serde = "1.0.203"
serde_json = "1.0.118"
wasm-bindgen = "0.2.92"
wasm-bindgen-futures = "0.4.42"
web-sys = { version = "0.3.69", features = ["Document", "Window", "Element"] }
wgpu = { version = "0.20.1", features = ["webgl"] }
winit = "0.30.3"
heatmap-api = { path = "../heatmap-api" }
geo = "0.28.0"
js-sys = "0.3.69"
png = "0.17.13"
urlencoding = "2.1.3"
base64 = "0.22.1"
text-to-png = "0.2.0"
chrono = {workspace = true}
leptos = { workspace = true}
serde = {workspace = true}
serde_json = {workspace = true}
log = {workspace = true}
geo = {workspace = true}
base64 = {workspace = true}

[lints.clippy]
unwrap_used = "warn"
1 change: 0 additions & 1 deletion heatmap-service/.dockerignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
.env
.env_tests
target
6 changes: 3 additions & 3 deletions heatmap-service/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,14 @@ actix-cors = "0.7.0"
actix-http = "3.2.1"
actix-web = "4.1.0"
approx = "0.5.1"
base64 = "0.13.0"
chrono = { version = "0.4.24", features = ["serde"] }
config = "0.13.2"
deadpool-redis = { version = "0.10.2", features = ["serde"] }
derive_more = "0.99.17"
dotenv = "0.15.0"
env_logger = "0.9.0"
futures-util = "0.3.28"
geo = "0.28.0"
geojson = "0.24.1"
log = "0.4.22"
pin-project = "1.0.12"
redis = { version = "0.21.5", features = ["tokio-comp"] }
serde = "1.0.163"
Expand All @@ -29,3 +26,6 @@ serde_with = "2.0.0"
heatmap-api = { path = "../heatmap-api" }
rust-embed = "8.5.0"
rayon = "1.10.0"
base64 = { workspace = true }
log = {workspace = true}
geo = {workspace = true}
23 changes: 16 additions & 7 deletions heatmap-service/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
FROM rust:1.69 AS builder

RUN update-ca-certificates
FROM rust:1.86 AS builder

ENV USER=heatmap
ENV UID=10001
Expand All @@ -16,10 +14,18 @@ RUN adduser \

WORKDIR /heatmap

COPY ./ .
COPY ./heatmap-service ./heatmap-service
COPY ./heatmap-api ./heatmap-api

RUN <<EOF
echo "SERVER_ADDRESS=127.0.0.1:8000" >> ./.env
echo "CACHE_TTL=3600" >> ./.env
echo "HEATMAP_GEO_JSON_PATH=/heatmap/sat_data.geojson" >> ./.env
echo "GEO_JSON_PATH=/heatmap/sat_data.geojson" >> ./.env
EOF

RUN cargo update # required to fix issue with poorly specified dependencies for tokio-postgres
RUN cargo build --release
# --release would be preferable here but I run out of memory with the flag
RUN cargo build --release --manifest-path=./heatmap-service/Cargo.toml

FROM gcr.io/distroless/cc

Expand All @@ -28,7 +34,10 @@ COPY --from=builder /etc/group /etc/group

WORKDIR /heatmap

COPY --from=builder /heatmap/target/release/heatmap-service ./
COPY --from=builder /heatmap/heatmap-service/target/debug/heatmap-service ./
COPY --from=builder /heatmap/heatmap-service/sat_data.geojson ./
COPY --from=builder /heatmap/.env ./


USER heatmap:heatmap

Expand Down
24 changes: 16 additions & 8 deletions heatmap-service/src/geo_assets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,24 @@ impl GeoAssets {
pub fn from_config(config: Config) -> Self {
Self {
heatmap_features: Granule::from_feature_collection(
config.heatmap_geo_json_path.try_into().unwrap(),
config
.heatmap_geo_json_path
.try_into()
.expect("Failed to get sat_data.geojson"),
)
.unwrap(),
.expect("Failed to convert sat_data.geojson to Granules"),
outline_features: Granule::from_feature_collection(
std::str::from_utf8(Assets::get("outline.geojson").unwrap().data.as_ref())
.unwrap()
.parse::<GeoJson>()
.unwrap()
.try_into()
.unwrap(),
std::str::from_utf8(
Assets::get("outline.geojson")
.expect("failed to get outline.geojson")
.data
.as_ref(),
)
.expect("Failed to convert outline to str")
.parse::<GeoJson>()
.expect("Failed to parse outline GeoJson")
.try_into()
.expect("Failed to convert outline to a FeatureCollection"),
)
.unwrap(),
}
Expand Down
2 changes: 1 addition & 1 deletion heatmap-service/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ async fn main() -> std::io::Result<()> {
HttpServer::new(move || {
let cors = Cors::default()
.allowed_origin("https://asfadmin.github.io") // The client is hosted on github pages
.allowed_origin("localhost") // Allowed for debug purposes
.allowed_origin("http://localhost:8080") // Allowed for debug purposes
.allowed_methods(vec!["GET", "POST"])
.allowed_headers(vec![header::AUTHORIZATION, header::ACCEPT])
.allowed_header(header::CONTENT_TYPE)
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[toolchain]
channel = "nightly"
channel = "nightly-2024-09-01"
Loading