muesli / beehive

A flexible event/agent & automation system with lots of bees 🐝
GNU Affero General Public License v3.0
6.28k stars 319 forks source link

Improve Dockerfile #205

Closed schnz closed 5 years ago

schnz commented 5 years ago

I found this repository today and wanted to try beehive. Unfortunately the Dockerfile seems broken as the go get command fails. I then tried the image that is hosted on Docker Hub and found that it is over two years old and contains an old binary of beehive.

Because of that I created my own Dockerfile for beehive. It uses the Docker multi-stage build feature and results in a MUCH smaller image (24.2 MB compared to 800 MB). Beehive is build with the embed option which makes it possible to use a single binary within an alpine container.

Feel free to integrate this file to the repository or provide it as an additional alternative to the existing ones.

FROM golang:1.11-alpine

RUN apk add -U --no-cache curl git make g++ && \
    curl "https://raw.githubusercontent.com/golang/dep/master/install.sh" | sh && \
    go get -d -v github.com/muesli/beehive && \
    cd ${GOPATH}/src/github.com/muesli/beehive && \
    make get-deps && \
    make

FROM alpine:3.8

RUN apk add -U --no-cache ca-certificates

WORKDIR /app

COPY --from=0 /go/src/github.com/muesli/beehive/beehive .

ENTRYPOINT ["./beehive"]
HenryQW commented 5 years ago

LGTM, the Dockerfile is indeed out-dated and I haven't got time to update it, please PR this!

seblw commented 5 years ago

You can use scratch instead of alpine:3.8 to make it even smaller.

schnz commented 5 years ago

You can use scratch instead of alpine:3.8 to make it even smaller.

Good point but it refuses to run if i use scratch:

standard_init_linux.go:190: exec user process caused "no such file or directory"

Furthermore it wouldn't contain the ca-certificates package which is important for crawling RSS feeds over HTTPS. Otherwise fetching would fail with

ERRO[0085] [Fefe Blog]: https://blog.fefe.de/rss.xml: Get https://blog.fefe.de/rss.xml: x509: certificate signed by unknown authority

muesli commented 5 years ago

I've pushed some updates to the Dockerfile in git master, and new docker images will from now on be automatically built on the docker hub (fribbledom/beehive).