Bind to 0.0.0.0 so that it works containerized

This commit is contained in:
Martin Brodbeck 2025-04-16 11:31:36 +02:00
parent 8b32c52f90
commit eff186830a

View file

@ -17,17 +17,17 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
use axum::{ use axum::{
Json, Router,
extract::{Path, State}, extract::{Path, State},
http::HeaderMap, http::HeaderMap,
http::StatusCode, http::StatusCode,
routing::get, routing::get,
routing::post, routing::post,
routing::put, routing::put,
Json, Router,
}; };
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use serde_json::{json, Value}; use serde_json::{Value, json};
use sqlx::{postgres::PgPoolOptions, PgExecutor, PgPool}; use sqlx::{PgExecutor, PgPool, postgres::PgPoolOptions};
use std::env; use std::env;
use std::time::{Duration, SystemTime, UNIX_EPOCH}; use std::time::{Duration, SystemTime, UNIX_EPOCH};
@ -85,7 +85,7 @@ async fn main() {
.route("/version", get(version)) .route("/version", get(version))
.with_state(db_pool); .with_state(db_pool);
let mut bind_with = "127.0.0.1:".to_owned(); let mut bind_with = "0.0.0.0:".to_owned();
bind_with += &listen_port; bind_with += &listen_port;
let listener = tokio::net::TcpListener::bind(bind_with).await.unwrap(); let listener = tokio::net::TcpListener::bind(bind_with).await.unwrap();
axum::serve(listener, app).await.unwrap(); axum::serve(listener, app).await.unwrap();