Skip to content

Commit

Permalink
Merge pull request #5 from tthogho1/websocket_QA
Browse files Browse the repository at this point in the history
set static folder to / path
  • Loading branch information
tthogho1 authored Oct 9, 2024
2 parents 516ecb5 + e10638f commit f7ae813
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
29 changes: 29 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
FROM rust:1.70-slim-buster AS builder

WORKDIR /app

# 依存関係のキャッシュ
COPY Cargo.toml Cargo.lock askama.toml ./

COPY src ./src
RUN ls -la ./src
COPY templates ./templates
RUN ls -la ./templates
COPY static ./static
RUN ls -la ./static

# RUN mkdir src && echo "fn main() {}" > src/main.rs
RUN cargo build --release
RUN rm -rf src

#CMD ["/app/target/release/websocket_rust"]


# 実行ステージ
FROM debian:buster-slim

RUN apt-get update && rm -rf /var/lib/apt/lists/*

COPY --from=builder /app/target/release/websocket_rust /usr/local/bin/websocket_rust

CMD ["websocket_rust"]
4 changes: 2 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,14 @@ async fn main() {
let app = Router::new()
.route("/ws", get(ws_handler))
.with_state(Arc::clone(&app_state));
let app = app.route("/", get(move || async move {hello_handler(port).await}));
let app = app.route("/Chat", get(move || async move {hello_handler(port).await}));
let app = app.route("/position",post(position_handler)).with_state(Arc::clone(&app_state));
let app: Router<Arc<websocket_rust::AppState>> = app.route("/users",post(getallusers_handler)).with_state(Arc::clone(&app_state));
let app = app.route("/usersinbounds",post(get_users_in_bounds)).with_state(Arc::clone(&app_state));

// 静的ファイルを提供
let app = app
.nest_service("/static", get_service(ServeDir::new("static")).handle_error(
.nest_service("/", get_service(ServeDir::new("static")).handle_error(
|error| async move {
(
axum::http::StatusCode::INTERNAL_SERVER_ERROR,
Expand Down

0 comments on commit f7ae813

Please sign in to comment.