From 96dae54411933c04cd269a469e98532571b596fb Mon Sep 17 00:00:00 2001 From: Romain Mallard Date: Wed, 11 Mar 2026 14:30:12 +0100 Subject: [PATCH] FIX: re implement docker file --- .gitignore | 2 ++ Dockerfile | 23 +++++++++++++++++++++++ src/chat/extractor.rs | 1 - src/chat/handlers.rs | 2 +- src/main.rs | 25 ++++++++++++------------- 5 files changed, 38 insertions(+), 15 deletions(-) create mode 100644 Dockerfile diff --git a/.gitignore b/.gitignore index ec47942..c3fcca0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ /target +/.vscode + .env \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..639f4f3 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,23 @@ +FROM rust:latest AS builder +WORKDIR /app +COPY . . +RUN cargo build --release + +FROM debian:bookworm-slim + +# Create the app user with UID 1001 +RUN useradd -u 1001 -m appuser + +# Create working directory (only needed if your app expects /app) +WORKDIR /app + +# Copy binary from builder +COPY --from=builder /app/target/release/hotel-api-rs /usr/local/bin/hotel-api-rs + +# Switch to non-root user +USER 1001 + +# Expose API port +EXPOSE 8080 + +CMD ["/usr/local/bin/hotel-api-rs"] diff --git a/src/chat/extractor.rs b/src/chat/extractor.rs index 3b64ea2..ffb5f84 100644 --- a/src/chat/extractor.rs +++ b/src/chat/extractor.rs @@ -3,7 +3,6 @@ use axum::{ extract::{FromRequest, Request}, http::StatusCode, }; -use chrono::NaiveDateTime; use serde::Deserialize; #[derive(Deserialize, Debug)] diff --git a/src/chat/handlers.rs b/src/chat/handlers.rs index 7db2b71..8cb3ef8 100644 --- a/src/chat/handlers.rs +++ b/src/chat/handlers.rs @@ -208,7 +208,7 @@ pub struct Get pub async fn get_conv_users( State(state): State, AuthClaims { user_id, hotel_id }: AuthClaims, - Path(conv_id): Path<(i32)>, + Path(conv_id): Path, ) -> impl IntoResponse { let pool = state.hotel_pools.get_pool(hotel_id); diff --git a/src/main.rs b/src/main.rs index a2da3bf..8df2ca1 100644 --- a/src/main.rs +++ b/src/main.rs @@ -4,25 +4,14 @@ use axum::extract::{ ws::{Message, WebSocket, WebSocketUpgrade}, }; use axum::serve; - use jsonwebtoken::{DecodingKey, EncodingKey}; use reqwest::header::AUTHORIZATION; use reqwest::header::CONTENT_TYPE; use reqwest::header::USER_AGENT; + + use tokio::net::TcpListener; - - -mod chat; -mod inventory; -mod rooms; -mod routes; -mod utils; -use dashmap::DashMap; -use r2d2::Pool; -use r2d2_sqlite::SqliteConnectionManager; -use std::sync::Arc; - use crate::utils::auth::JwtKeys; use crate::utils::db_pool::{AppState, HotelPool}; use routes::create_router; @@ -33,6 +22,16 @@ use std::env; use axum::http::{HeaderValue, Method}; use tower_http::cors::{Any, CorsLayer}; +mod chat; +mod inventory; +mod rooms; +mod routes; +mod utils; +use dashmap::DashMap; +use r2d2::Pool; +use r2d2_sqlite::SqliteConnectionManager; +use std::sync::Arc; + pub async fn notify_discord(msg: &str) -> Result<(), reqwest::Error> { let payload = serde_json::json!({ "content": msg