roc-lang / basic-webserver

A basic webserver in Roc

Home Page:https://roc-lang.github.io/basic-webserver/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Running inside Docker

Gauteab opened this issue · comments

I tried to containerize a simple webapp, but was having issues with the host being hard coded to 127.0.0.1.

I resolved the issue by adding an environment variable ROC_BASIC_WEBSERVER_HOST that I set to 0.0.0.0 and used it like:

    let host = env::var(HOST_ENV_NAME).unwrap_or("127.0.0.1".to_string());
    let addr = format!("{}:{}", host, port).parse::<SocketAddr>().expect("Failed to parse host and port");

If this is an acceptable solution I'll make a PR, and I could add some more variables like PORT.

Otherwise, I'd love to hear it :)

ROC_BASIC_WEBSERVER_HOST and ROC_BASIC_WEBSERVER_PORT sounds good @Gauteab, go for it :)