diff --git a/Dockerfile b/Dockerfile index b9e1e68..81de714 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,27 +1,19 @@ # Build backend -FROM golang:1.22.1-alpine3.19 as build_backend +FROM rust:1.81-alpine3.20 as build_backend -RUN apk add upx alpine-sdk +RUN apk add upx musl-dev WORKDIR / -COPY vingo/go.sum go.sum +COPY vingo/Cargo.* . -COPY vingo/go.mod go.mod +COPY vingo/migration migration -RUN go mod download - -COPY vingo/main.go . - -COPY vingo/database database - -COPY vingo/handlers handlers - -RUN CGO_ENABLED=1 go build -ldflags "-s -w" -v -tags musl vingo/. - -RUN upx --best --lzma vingo +COPY vingo/src src +RUN cargo build --release +RUN upx --best --lzma target/release/vingo # Build frontend FROM node:20.15.1-alpine3.20 as build_frontend @@ -40,17 +32,15 @@ COPY vinvoor/production.env .env RUN yarn run build - - # End container -FROM alpine:3.19 +FROM alpine:3.20 WORKDIR / -COPY --from=build_backend vingo . +COPY --from=build_backend target/release/vingo . COPY --from=build_frontend /dist public -ENV DEVELOPMENT=false +ENV DEVELOPMENT=FALSE EXPOSE 4000 diff --git a/vingo/Cargo.lock b/vingo/Cargo.lock index 637732e..3289edf 100644 --- a/vingo/Cargo.lock +++ b/vingo/Cargo.lock @@ -1081,6 +1081,12 @@ dependencies = [ "pin-project-lite", ] +[[package]] +name = "http-range-header" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ce4ef31cda248bbdb6e6820603b82dfcd9e833db65a43e997a0ccec777d11fe" + [[package]] name = "httparse" version = "1.9.4" @@ -1371,6 +1377,16 @@ version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" +[[package]] +name = "mime_guess" +version = "2.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7c44f8e672c00fe5308fa235f821cb4198414e1c77935c1ab6948d3fd78550e" +dependencies = [ + "mime", + "unicase", +] + [[package]] name = "minimal-lexical" version = "0.2.1" @@ -2808,6 +2824,19 @@ dependencies = [ "tokio", ] +[[package]] +name = "tokio-util" +version = "0.7.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9cf6b47b3771c49ac75ad09a6162f53ad4b8088b76ac60e8ec1455b31a189fe1" +dependencies = [ + "bytes", + "futures-core", + "futures-sink", + "pin-project-lite", + "tokio", +] + [[package]] name = "tower" version = "0.4.13" @@ -2848,10 +2877,18 @@ checksum = "1e9cd434a998747dd2c4276bc96ee2e0c7a2eadf3cae88e52be55a05fa9053f5" dependencies = [ "bitflags 2.6.0", "bytes", + "futures-util", "http", "http-body", "http-body-util", + "http-range-header", + "httpdate", + "mime", + "mime_guess", + "percent-encoding", "pin-project-lite", + "tokio", + "tokio-util", "tower-layer", "tower-service", "tracing", @@ -2994,6 +3031,15 @@ version = "1.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" +[[package]] +name = "unicase" +version = "2.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7d2d4dafb69621809a81864c9c1b864479e1235c0dd4e199924b9742439ed89" +dependencies = [ + "version_check", +] + [[package]] name = "unicode-bidi" version = "0.3.15" diff --git a/vingo/Cargo.toml b/vingo/Cargo.toml index 3d1d361..66c7528 100644 --- a/vingo/Cargo.toml +++ b/vingo/Cargo.toml @@ -35,6 +35,7 @@ tokio = { version = "1.39.3", default-features = false, features = [ tower-http = { version = "0.5.2", default-features = false, features = [ "trace", "cors", + "fs", ] } tower-sessions = { version = "0.12.3", default-features = false, features = [ "memory-store", diff --git a/vingo/src/main.rs b/vingo/src/main.rs index 3f3575f..41c1370 100644 --- a/vingo/src/main.rs +++ b/vingo/src/main.rs @@ -2,7 +2,7 @@ mod entities; mod middleware; mod routes; -use std::sync::Arc; +use std::{env, sync::Arc}; use chrono::Local; use routes::{auth, cards, days, leaderboard, scans, seasons, settings}; @@ -15,7 +15,10 @@ use axum::{ use sea_orm::{prelude::DateTimeWithTimeZone, Database, DatabaseConnection}; use tokio::sync::Mutex; use tower_http::cors::CorsLayer; -use tower_http::trace::TraceLayer; +use tower_http::{ + services::{ServeDir, ServeFile}, + trace::TraceLayer, +}; use tower_sessions::{cookie::SameSite, MemoryStore, SessionManagerLayer}; use migration::{Migrator, MigratorTrait}; @@ -60,13 +63,19 @@ async fn main() { }; // build our application with a route - let app = Router::new() + let mut app = Router::new() .nest("/api", routes()) .layer(sess_mw) .layer(CorsLayer::very_permissive()) .layer(TraceLayer::new_for_http()) .with_state(state); + if env::var("DEVELOPMENT").unwrap_or("".into()) != "TRUE" { + app = app.fallback_service( + ServeDir::new("public").not_found_service(ServeFile::new("public/index.html")), + ); + }; + // run it let listener = tokio::net::TcpListener::bind("0.0.0.0:4000").await.unwrap(); diff --git a/vinvoor/src/overview/heatmap/Rect.tsx b/vinvoor/src/overview/heatmap/Rect.tsx index 562b679..557ab4a 100644 --- a/vinvoor/src/overview/heatmap/Rect.tsx +++ b/vinvoor/src/overview/heatmap/Rect.tsx @@ -1,6 +1,6 @@ import { FC } from "react"; -import { HeatmapRectStyle } from "../../theme"; import { RECT_RADIUS, RECT_SIZE, RECT_STROKE, SPACE } from "./utils"; +import { HeatmapRectStyle } from "../../themes/theme"; interface RectProps { idx: number;