Skip to content

Commit

Permalink
zess: prodocker and static files
Browse files Browse the repository at this point in the history
  • Loading branch information
hannes-dev committed Oct 4, 2024
1 parent c511a6f commit 8c62458
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ WORKDIR /
COPY --from=build_backend target/release/vingo .
COPY --from=build_frontend /dist public

ENV DEVELOPMENT=false
ENV DEVELOPMENT=FALSE

EXPOSE 4000

Expand Down
46 changes: 46 additions & 0 deletions vingo/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions vingo/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
15 changes: 12 additions & 3 deletions vingo/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand All @@ -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};
Expand Down Expand Up @@ -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();

Expand Down

0 comments on commit 8c62458

Please sign in to comment.