From 3eb2ae4d714bc136fa03654877326e1c7af2d6c6 Mon Sep 17 00:00:00 2001 From: FND Date: Wed, 21 Jul 2021 14:18:16 +0200 Subject: [PATCH 1/2] added Docker instructions Co-authored-by: ak --- Dockerfile | 7 +++++++ README.md | 19 +++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..b73b662 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,7 @@ +FROM golang:alpine3.11 + +WORKDIR /app +COPY . /app + +RUN go build -o bin/naveed +CMD ["/app/bin/naveed"] diff --git a/README.md b/README.md index 0bcfc90..4b7971c 100644 --- a/README.md +++ b/README.md @@ -57,6 +57,25 @@ NB: user (i.e. the application is expected to be served via a reverse proxy) +### Docker + +* build: + + $ docker build --rm -t naveed . + +* run: + + $ docker run -it --rm --name naveed -p8080:8465 + -v "$(pwd)/config:/app/config" \ + -e NAVEED_USERS_URL=… \ + -e NAVEED_USERS_USERNAME=… \ + -e NAVEED_USERS_PASSWORD=… \ + naveed + + note that you will need to add the configuration files mentioned above to + the container and you might also need to adjust the port numbers + + Architectural Overview ---------------------- From 3cdd579c59733eb7ab7d182261ce2a0facce7c38 Mon Sep 17 00:00:00 2001 From: Daniel Bornkessel Date: Thu, 22 Jul 2021 15:18:41 +0200 Subject: [PATCH 2/2] Some Docker-refinements - use multi-stage build: build the binary in a `alpine:golang3.11` image but use `busybox:stable` for the run time image and just pick the build artifacts ... this reduces the image size from 384mb -> 12.4mb - build with CGO_ENABLED=0 to avoid dependency to glibc: this makes it more compatible with different types of linux images - add EXPOSE statement to Dockerfile - add `USER=nobody` statement to avoid running as root within the container - remove `-it` option from README: this is only needed if you want to interactively use the container - use 0.0.0.0 as the default listing host ... otherwise requests from other hosts will not be responded to However: `sendmail` is missing from the container and therefore this will not run correctly. As I don't know whether it usually runs with sendmail I stopped at this point -- happy to support again --- Dockerfile | 13 +++++++++++-- README.md | 4 ++-- naveed.ini | 2 +- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index b73b662..9fe2162 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,16 @@ -FROM golang:alpine3.11 +FROM golang:alpine3.11 as base WORKDIR /app COPY . /app +ENV CGO_ENABLED=0 RUN go build -o bin/naveed -CMD ["/app/bin/naveed"] + +FROM busybox + +COPY --from=base /app/bin/naveed /usr/bin/naveed +COPY --from=base /app/naveed.ini / + +EXPOSE 8465/tcp +USER nobody +CMD ["/usr/bin/naveed"] diff --git a/README.md b/README.md index 4b7971c..ee9032f 100644 --- a/README.md +++ b/README.md @@ -65,8 +65,8 @@ NB: * run: - $ docker run -it --rm --name naveed -p8080:8465 - -v "$(pwd)/config:/app/config" \ + $ docker run --rm --name naveed -p8080:8465 + -v "$(pwd)/config:/" \ -e NAVEED_USERS_URL=… \ -e NAVEED_USERS_USERNAME=… \ -e NAVEED_USERS_PASSWORD=… \ diff --git a/naveed.ini b/naveed.ini index 14b04bd..4ac4fdd 100644 --- a/naveed.ini +++ b/naveed.ini @@ -2,7 +2,7 @@ # * relative paths originate from the application's working directory # * changes require restarting the server -host = "localhost" +host = "0.0.0.0" port = 8465 path-prefix = "/naveed" external-root = "https://example.org/naveed/"