Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Added Docker multiarch build #65

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
12 changes: 9 additions & 3 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
.glide/
.idea/
_output/
docker
docs
example
bin/
docker/
docs/
example/
test/
*.md
.gitignore
Makefile
.travis.yml
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ vendor
## IntelliJ
.idea
*.iml

docker/*/Dockerfile.*
60 changes: 60 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# TODO: arm64v8 is broken
archs = amd64 arm32v6 # arm64v8
operator = nats-operator
reloader = nats-server-config-reloader
tag = $(shell git describe --abbrev=0 --tags | sed 's/v//g')

amd64_args = --arch amd64
arm32v6_args = --arch arm --variant v6
# TODO: arm64v8 is broken
# arm64v8_args = --arch arm64 --variant v8

_ensure_repo:
@test ! $(repo) &&\
echo repo must be set. >&2 &&\
exit 1 ||\
true

.PHONY: operator
operator: _ensure_repo
@- $(foreach a,$(archs), \
sed 's/FROM /FROM $a\//g' docker/operator/Dockerfile > docker/operator/Dockerfile.$a; \
docker build --tag $(repo)/$(operator):$a-$(tag) --file docker/operator/Dockerfile.$a .; \
)

.PHONY: reloader
reloader: _ensure_repo
@- $(foreach a,$(archs), \
sed 's/FROM /FROM $a\//g' docker/reloader/Dockerfile > docker/reloader/Dockerfile.$a; \
docker build --tag $(repo)/$(reloader):$a-$(tag) --file docker/reloader/Dockerfile.$a .; \
)

.PHONY: push-operator
push-operator: operator
@- $(foreach a,$(archs), \
docker push $(repo)/$(operator):$a-$(tag); \
)
docker manifest create $(repo)/$(operator):$(tag) $(foreach a,$(archs), $(repo)/$(operator):$a-$(tag)) || \
docker manifest create --amend $(repo)/$(operator):$(tag) $(foreach a,$(archs), $(repo)/$(operator):$a-$(tag))
@- $(foreach a,$(archs), \
docker manifest annotate \
$(repo)/$(operator):$(tag) \
$(repo)/$(operator):$a-$(tag) \
--os linux $($a_args); \
)
docker manifest push $(repo)/$(operator):$(tag)

.PHONY: push-reloader
push-reloader: reloader
@- $(foreach a,$(archs), \
docker push $(repo)/$(reloader):$a-$(tag); \
)
docker manifest create $(repo)/$(reloader):$(tag) $(foreach a,$(archs), $(repo)/$(reloader):$a-$(tag)) || \
docker manifest create --amend $(repo)/$(reloader):$(tag) $(foreach a,$(archs), $(repo)/$(reloader):$a-$(tag))
@- $(foreach a,$(archs), \
docker manifest annotate \
$(repo)/$(reloader):$(tag) \
$(repo)/$(reloader):$a-$(tag) \
--os linux $($a_args); \
)
docker manifest push $(repo)/$(reloader):$(tag)
3 changes: 2 additions & 1 deletion docker/operator/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ FROM golang:1.10-alpine3.8 AS builder
WORKDIR $GOPATH/src/github.com/nats-io/nats-operator/
RUN apk add --update git
RUN go get -u github.com/golang/dep/cmd/dep
COPY . .
COPY Gopkg.lock Gopkg.toml ./
RUN dep ensure -v -vendor-only
COPY . .
RUN CGO_ENABLED=0 go build -ldflags "-X github.com/nats-io/nats-operator/version.GitSHA=`git rev-parse --short HEAD`" -installsuffix cgo -o /nats-operator ./cmd/operator/main.go

FROM alpine:3.8
Expand Down
3 changes: 2 additions & 1 deletion docker/reloader/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ FROM golang:1.10-alpine3.8 AS builder
WORKDIR $GOPATH/src/github.com/nats-io/nats-operator/
RUN apk add --update git
RUN go get -u github.com/golang/dep/cmd/dep
COPY . .
COPY Gopkg.lock Gopkg.toml ./
RUN dep ensure -v -vendor-only
COPY . .
RUN CGO_ENABLED=0 go build -ldflags "-X github.com/nats-io/nats-operator/version.GitSHA=`git rev-parse --short HEAD`" -installsuffix cgo -o /nats-server-config-reloader ./cmd/reloader/main.go

FROM alpine:3.8
Expand Down