Skip to content
This repository has been archived by the owner on Jul 1, 2024. It is now read-only.

Commit

Permalink
Some Docker-refinements
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
kesselborn committed Jul 22, 2021
1 parent 3eb2ae4 commit 3cdd579
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
13 changes: 11 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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=… \
Expand Down
2 changes: 1 addition & 1 deletion naveed.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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/"
Expand Down

0 comments on commit 3cdd579

Please sign in to comment.