roc-lang / basic-webserver

A basic webserver in Roc
https://roc-lang.github.io/basic-webserver/
Universal Permissive License v1.0
72 stars 15 forks source link

Running inside Docker #14

Closed Gauteab closed 9 months ago

Gauteab commented 9 months ago

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 :)

Anton-4 commented 9 months ago

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