forked from travisjeffery/jocko
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor dockerfile, go modules with golang v1.14.2; "closes travisje…
…ffery#163" - removed dep-related comands and notes - added two Dockerfiles (works with Podman, Buildah too) - "prod": for clean build, with tests, runnng with non-root user, from scratch container - "dev": there is caching for golang deps, without tests, run as root, and result container can be not from scratch, for debug reasons. - docker-compose file: - added shared context-build block, DRY. - removed command name `jocko` in line `command: jocko broker...` because of we using the same ENTRYPOINT in docker file. - small fixes in module paths: - "github.com/hashicorp/consul/testutil/retry" -> "github.com/hashicorp/consul/sdk/testutil/retry" - update go.mod to the lastest version for all transitive deps (exepts github.com/mitchellh/go-testing-interface v1.4.0)
- Loading branch information
Showing
12 changed files
with
697 additions
and
200 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,20 @@ | ||
FROM golang:1.9-alpine as build-base | ||
RUN apk update && apk upgrade && \ | ||
apk add --no-cache bash git openssh make && \ | ||
go get -u github.com/golang/dep/cmd/dep | ||
ADD . /go/src/github.com/travisjeffery/jocko | ||
WORKDIR /go/src/github.com/travisjeffery/jocko | ||
RUN GOOS=linux GOARCH=amd64 make build | ||
# The file using for build smallest conatiner for production | ||
# And there are additionals: `go test` step and non-root user unlike the Dockerfile-dev. | ||
|
||
FROM alpine:latest | ||
COPY --from=build-base /go/src/github.com/travisjeffery/jocko/cmd/jocko/jocko /usr/local/bin/jocko | ||
FROM golang:1.14-alpine as build-base | ||
RUN install -g nobody -o nobody -m 0770 -d /tmp/empty-dir-owned-by-nobody | ||
RUN echo 'nobody:x:65534:65534:nobody:/:/sbin/nologin' > /tmp/passwd | ||
|
||
ADD . $GOPATH/src/github.com/travisjeffery/jocko/ | ||
WORKDIR $GOPATH/src/github.com/travisjeffery/jocko/ | ||
RUN go mod download && go mod verify | ||
RUN CGO_ENABLED=0 go test -v ./... | ||
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -installsuffix cgo -o /jocko cmd/jocko/main.go | ||
|
||
FROM scratch | ||
COPY --chown=65534:65534 --from=build-base /tmp/empty-dir-owned-by-nobody /tmp | ||
COPY --from=build-base /jocko /jocko | ||
COPY --from=build-base /tmp/passwd /etc/passwd | ||
EXPOSE 9092 9093 9094 9095 | ||
VOLUME "/tmp/jocko" | ||
CMD ["jocko", "broker"] | ||
USER nobody | ||
ENTRYPOINT ["/jocko"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# The file using for build conatiner for regular development, | ||
# it skip downloading vedor files if `go.*` files was not edited | ||
|
||
FROM golang:1.14-alpine as build-base | ||
WORKDIR /build | ||
COPY go.mod . | ||
COPY go.sum . | ||
RUN go mod download | ||
COPY . . | ||
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -installsuffix cgo -o /jocko cmd/jocko/main.go | ||
|
||
FROM scratch | ||
COPY --from=build-base /jocko /jocko | ||
EXPOSE 9092 9093 9094 9095 | ||
VOLUME "/tmp/jocko" | ||
ENTRYPOINT ["/jocko"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,25 @@ | ||
version: '3' | ||
|
||
x-context-build: | ||
&context-build | ||
context: . | ||
dockerfile: Dockerfile-dev | ||
|
||
services: | ||
jocko_a: | ||
build: | ||
context: . | ||
<<: *context-build | ||
image: travisjeffery/jocko:latest | ||
command: jocko broker --id 0 --raft-addr=jocko_a:9093 --bootstrap --bootstrap-expect=3 | ||
command: broker --id 0 --raft-addr=jocko_a:9093 --bootstrap --bootstrap-expect=3 | ||
|
||
jocko_b: | ||
build: | ||
context: . | ||
<<: *context-build | ||
image: travisjeffery/jocko:latest | ||
command: jocko broker --join=jocko_a:9094 --id 1 --raft-addr=jocko_b:9093 --bootstrap-expect=3 | ||
command: broker --join=jocko_a:9094 --id 1 --raft-addr=jocko_b:9093 --bootstrap-expect=3 | ||
|
||
jocko_c: | ||
build: | ||
context: . | ||
<<: *context-build | ||
image: travisjeffery/jocko:latest | ||
command: jocko broker --join=jocko_a:9094 --id 2 --raft-addr=jocko_c:9093 --bootstrap-expect=3 | ||
command: broker --join=jocko_a:9094 --id 2 --raft-addr=jocko_c:9093 --bootstrap-expect=3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,62 +1,62 @@ | ||
module github.com/travisjeffery/jocko | ||
|
||
go 1.12 | ||
go 1.14 | ||
|
||
require ( | ||
github.com/Shopify/sarama v1.13.0 | ||
github.com/apache/thrift v0.0.0-20161221203622-b2a4d4ae21c7 | ||
github.com/armon/go-metrics v0.0.0-20190430140413-ec5e00d3c878 | ||
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973 | ||
github.com/boltdb/bolt v1.3.1 | ||
github.com/bsm/sarama-cluster v2.1.10+incompatible | ||
github.com/cenkalti/backoff v2.0.0+incompatible | ||
github.com/cespare/xxhash v1.0.0 | ||
github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd | ||
github.com/OneOfOne/xxhash v1.2.7 // indirect | ||
github.com/Shopify/sarama v1.26.1 | ||
github.com/armon/go-metrics v0.3.3 // indirect | ||
github.com/bsm/sarama-cluster v2.1.15+incompatible | ||
github.com/cenkalti/backoff v2.2.1+incompatible | ||
github.com/cespare/xxhash v1.1.0 | ||
github.com/davecgh/go-spew v1.1.1 | ||
github.com/eapache/go-resiliency v1.0.0 | ||
github.com/eapache/go-xerial-snappy v0.0.0-20160609142408-bb955e01b934 | ||
github.com/eapache/queue v1.0.2 | ||
github.com/go-kit/kit v0.6.0 | ||
github.com/golang/protobuf v1.2.0 | ||
github.com/golang/snappy v0.0.0-20170215233205-553a64147049 | ||
github.com/hashicorp/consul v1.0.3 | ||
github.com/hashicorp/errwrap v1.0.0 | ||
github.com/hashicorp/go-immutable-radix v1.0.0 | ||
github.com/hashicorp/go-memdb v0.0.0-20171005030753-75ff99613d28 | ||
github.com/hashicorp/go-msgpack v0.5.5 | ||
github.com/hashicorp/go-multierror v1.0.0 | ||
github.com/hashicorp/go-sockaddr v1.0.0 | ||
github.com/hashicorp/golang-lru v0.5.0 | ||
github.com/hashicorp/memberlist v0.1.3 | ||
github.com/hashicorp/raft v1.1.1 | ||
github.com/frankban/quicktest v1.9.0 // indirect | ||
github.com/fsnotify/fsnotify v1.4.9 // indirect | ||
github.com/go-kit/kit v0.10.0 | ||
github.com/golang/protobuf v1.4.0 // indirect | ||
github.com/hashicorp/consul/sdk v0.4.0 | ||
github.com/hashicorp/go-hclog v0.12.2 // indirect | ||
github.com/hashicorp/go-memdb v1.2.1 | ||
github.com/hashicorp/go-msgpack v1.1.5 // indirect | ||
github.com/hashicorp/go-multierror v1.1.0 // indirect | ||
github.com/hashicorp/go-sockaddr v1.0.2 // indirect | ||
github.com/hashicorp/memberlist v0.2.0 | ||
github.com/hashicorp/raft v1.1.2 | ||
github.com/hashicorp/raft-boltdb v0.0.0-20191021154308-4207f1bf0617 | ||
github.com/hashicorp/serf v0.8.5 | ||
github.com/inconshreveable/mousetrap v1.0.0 | ||
github.com/matttproud/golang_protobuf_extensions v1.0.1 | ||
github.com/miekg/dns v1.0.14 | ||
github.com/mitchellh/go-testing-interface v0.0.0-20171004221916-a61a99592b77 | ||
github.com/opentracing/opentracing-go v1.0.2 | ||
github.com/pierrec/lz4 v1.0.1 | ||
github.com/pierrec/xxHash v0.1.1 | ||
github.com/pkg/errors v0.8.1 | ||
github.com/pmezard/go-difflib v1.0.0 | ||
github.com/prometheus/client_golang v0.9.2 | ||
github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910 | ||
github.com/prometheus/common v0.0.0-20181126121408-4724e9255275 | ||
github.com/prometheus/procfs v0.0.0-20181204211112-1dc9a6cbc91a | ||
github.com/rcrowley/go-metrics v0.0.0-20161128210544-1f30fe9094a5 | ||
github.com/hashicorp/serf v0.9.0 | ||
github.com/klauspost/compress v1.10.5 // indirect | ||
github.com/kr/text v0.2.0 // indirect | ||
github.com/mattn/go-colorable v0.1.6 // indirect | ||
github.com/miekg/dns v1.1.29 // indirect | ||
github.com/mitchellh/go-testing-interface v1.14.0 | ||
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e // indirect | ||
github.com/onsi/ginkgo v1.12.0 // indirect | ||
github.com/onsi/gomega v1.9.0 // indirect | ||
github.com/opentracing/opentracing-go v1.1.0 | ||
github.com/pierrec/lz4 v2.5.2+incompatible // indirect | ||
github.com/pkg/errors v0.9.1 | ||
github.com/prometheus/client_golang v1.5.1 // indirect | ||
github.com/prometheus/procfs v0.0.11 // indirect | ||
github.com/rcrowley/go-metrics v0.0.0-20200313005456-10cdbea86bc0 // indirect | ||
github.com/satori/go.uuid v1.2.0 | ||
github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529 | ||
github.com/spf13/cobra v0.0.1 | ||
github.com/spf13/pflag v1.0.0 | ||
github.com/stretchr/testify v1.3.0 | ||
github.com/spaolacci/murmur3 v1.1.0 // indirect | ||
github.com/spf13/cobra v1.0.0 | ||
github.com/spf13/pflag v1.0.5 // indirect | ||
github.com/stretchr/testify v1.5.1 | ||
github.com/tj/go-gracefully v0.0.0-20141227061038-005c1d102f1b | ||
github.com/travisjeffery/go-dynaport v0.0.0-20171203090423-24009f4f2f49 | ||
github.com/tysontate/gommap v0.0.0-20131202084435-e87a6e482c2c | ||
github.com/uber/jaeger-client-go v2.11.2+incompatible | ||
github.com/uber/jaeger-lib v1.3.1 | ||
github.com/ugorji/go v0.0.0-20180112141927-9831f2c3ac10 | ||
golang.org/x/net v0.0.0-20181201002055-351d144fa1fc | ||
golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5 | ||
upspin.io v0.0.0-20180517055408-63f1073c7a3a | ||
github.com/travisjeffery/go-dynaport v1.0.0 | ||
github.com/tysontate/gommap v0.0.0-20190103205956-899e1273fb5c | ||
github.com/uber/jaeger-client-go v2.23.0+incompatible | ||
github.com/uber/jaeger-lib v2.2.0+incompatible | ||
github.com/ugorji/go/codec v1.1.7 | ||
go.uber.org/atomic v1.6.0 // indirect | ||
golang.org/x/crypto v0.0.0-20200423211502-4bdfaf469ed5 // indirect | ||
golang.org/x/lint v0.0.0-20200302205851-738671d3881b // indirect | ||
golang.org/x/net v0.0.0-20200425230154-ff2c4b7c35a0 // indirect | ||
golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a // indirect | ||
golang.org/x/sys v0.0.0-20200420163511-1957bb5e6d1f // indirect | ||
golang.org/x/tools v0.0.0-20200426102838-f3a5411a4c3b // indirect | ||
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f // indirect | ||
launchpad.net/gocheck v0.0.0-20140225173054-000000000087 // indirect | ||
upspin.io v0.0.0-20200124224713-5ddde7b8e6ff | ||
) |
Oops, something went wrong.