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

WIP: dockerization #16

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's this used for?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a "multistage" Docker image: its as if you have a two docker files in one but you can access the first docker image. I build the binary in t he golang:alpine image (which contains the go compiler, etc.) and copy the result in a new image that is based on busybox, a minimal Linux Distro. This way, the resulting image is much smaller (384mb vs. 12mb)


COPY --from=base /app/bin/naveed /usr/bin/naveed
COPY --from=base /app/naveed.ini /
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this works because / is CMD's working directory?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

correct


EXPOSE 8465/tcp
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

8465 is just the default, so this assumes people didn't customize this setting in naveed.ini - which should generally be ok, but might result in confusion?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah .. you can remove it as well. For docker images it would be more explicit when the port (and the listening address) could be passed as options or env vars

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:/" \
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that config dir seems bogus; it's not actually being used anywhere and doesn't exist by default either - overall the instructions here are confusing; at the very least, assumptions need to be made explicit

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yup ... this adjustment was just made to keep it consistent with the prior image (as I moved the default config file to /)
.
Thinking about this again: this is actually bullshit: it would overwrite / :D .. if that's even possible -- sorry

-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"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure we want this to be the default though?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mmm ... ok: your choice. For production localhost doesn't make sense unless this runs on a host that contains a reverse proxy

port = 8465
path-prefix = "/naveed"
external-root = "https://example.org/naveed/"
Expand Down