From 7147315b0434e6e75a43ae6407eb44a931c61fe2 Mon Sep 17 00:00:00 2001 From: Johannes Loher Date: Tue, 27 Nov 2018 20:31:20 +0100 Subject: [PATCH] bind to all addresses and drop privileges --- Dockerfile | 4 ++++ source/app.d | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index f988178..4c561ae 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,6 +2,10 @@ FROM dlang2/dmd-ubuntu WORKDIR /dlang/vibe-docker COPY . . +RUN useradd --user-group --create-home --shell /bin/false app +RUN chown -R app:app /dlang/vibe-docker +USER app + RUN dub build -v EXPOSE 8080 diff --git a/source/app.d b/source/app.d index bdfe867..159508f 100644 --- a/source/app.d +++ b/source/app.d @@ -4,14 +4,14 @@ void main() { auto settings = new HTTPServerSettings; settings.port = 8080; - settings.bindAddresses = ["::1", "127.0.0.1"]; + settings.bindAddresses = ["::", "0.0.0.0"]; listenHTTP(settings, &hello); logInfo("Please open http://127.0.0.1:8080/ in your browser."); runApplication(); } -void hello(HTTPServerRequest req, HTTPServerResponse res) +void hello(HTTPServerRequest, HTTPServerResponse res) { res.writeBody("Hello, World!"); }