Skip to content

Commit

Permalink
add Dockerfile, refs #25
Browse files Browse the repository at this point in the history
  • Loading branch information
miku committed May 18, 2019
1 parent 2a1c7bf commit 56efa8f
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 3 deletions.
32 changes: 32 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
################################
# STEP 1 build executable binary
################################
FROM golang:1.12.5-alpine3.9 AS builder
LABEL stage=intermediate

# Install git, required for fetching the dependencies.
RUN apk update && apk add --no-cache git make

WORKDIR /app
COPY . .

# Fetch dependencies, using go get, download only, verbose.
RUN go get -d -v

# Build the binary.
RUN make esbulk

############################
# STEP 2 build a small image
############################
FROM scratch

# Copy our static executable.
COPY --from=builder /app/esbulk /app/esbulk

# https://stackoverflow.com/questions/52969195/docker-container-running-golang-http-client-getting-error-certificate-signed-by
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/

# Default command.
ENTRYPOINT ["/app/esbulk"]

11 changes: 9 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
SHELL := /bin/bash
TARGETS = esbulk
VERSION = 0.5.2

# http://docs.travis-ci.com/user/languages/go/#Default-Test-Script
test:
Expand Down Expand Up @@ -31,10 +31,17 @@ cover:
go tool cover -html=coverage.out

esbulk:
go build cmd/esbulk/esbulk.go
CGO_ENABLED=0 go build cmd/esbulk/esbulk.go

# ==== packaging

image:
DOCKER_CONTENT_TRUST=0 docker build --rm -t esbulk:$(VERSION) .
docker rmi -f $$(docker images -q --filter label=stage=intermediate)

rmi:
docker rmi esbulk:$(VERSION)

deb: $(TARGETS)
mkdir -p packaging/debian/esbulk/usr/sbin
cp $(TARGETS) packaging/debian/esbulk/usr/sbin
Expand Down
17 changes: 16 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,26 @@ For `deb` or `rpm` packages, see: https://github.com/miku/esbulk/releases
[intenthq/esbulk-docker](https://hub.docker.com/r/intenthq/esbulk-docker/) as
well (thanks [@albertpastrana](https://github.com/albertpastrana)), [#25](https://github.com/miku/esbulk/issues/25).

Run:

```
$ docker run -it intenthq/esbulk-docker esbulk -v
$ docker run -it --rm intenthq/esbulk-docker esbulk -v
0.5.1
```

Since 0.5.2 (May 2019) there is a [Dockerfile](Dockerfile) included in the
repo, it uses the multi-stage build and a FROM SCRATCH image, which allows for
a lightweight 7.85MB image.

```
$ git clone https://github.com/miku/esbulk.git
$ cd esbulk
$ make image # use make rmi to cleanup
$ docker run -it esbulk:0.5.2 -v
0.5.2
```


Usage
-----

Expand Down

0 comments on commit 56efa8f

Please sign in to comment.