Skip to content

Commit

Permalink
Add seihon for multi arch build
Browse files Browse the repository at this point in the history
  • Loading branch information
mmatur authored and traefiker committed Sep 6, 2019
1 parent 649974c commit 920849b
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 11 deletions.
15 changes: 15 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,23 @@ builds:
- -X github.com/containous/maesh/cmd/version.date={{.Date}}
goos:
- linux
- darwin
- windows
- freebsd
- openbsd
goarch:
- amd64
- 386
- arm
- arm64
goarm:
- 7
- 6
- 5

ignore:
- goos: darwin
goarch: 386

archives:
- id: maesh
Expand Down
6 changes: 5 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ before_deploy:
- curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | bash -s -- -b $GOPATH/bin ${GOLANGCI_LINT_VERSION}
- golangci-lint --version
- if ! [ "$BEFORE_DEPLOY_RUN" ]; then export BEFORE_DEPLOY_RUN=1; echo "${DOCKER_PASSWORD}" | docker login -u "${DOCKER_USERNAME}" --password-stdin; fi
# Install Docker image multi-arch builder
- curl -sfL https://raw.githubusercontent.com/ldez/seihon/master/godownloader.sh | bash -s -- -b "${GOPATH}/bin" ${SEIHON_VERSION}
- seihon --version
- docker run --rm --privileged hypriot/qemu-register
deploy:
- provider: script
skip_cleanup: true
Expand All @@ -49,7 +53,7 @@ deploy:
condition: $STABLE = true
- provider: script
skip_cleanup: true
script: make build push-docker
script: make publish-images
on:
tags: true
condition: $STABLE = true
Expand Down
11 changes: 6 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ RUN apk --no-cache --no-progress add \
&& update-ca-certificates \
&& rm -rf /var/cache/apk/*

ENV PROJECT_WORKING_DIR=/go/src/github.com/containous/maesh
WORKDIR /go/src/github.com/containous/maesh

# Download goreleaser binary to bin folder in $GOPATH
RUN curl -sfL https://install.goreleaser.com/github.com/goreleaser/goreleaser.sh | sh

WORKDIR "${PROJECT_WORKING_DIR}"
COPY go.mod go.sum "${PROJECT_WORKING_DIR}"/
RUN GO111MODULE=on GOPROXY=https://proxy.golang.org go mod download
COPY . "${PROJECT_WORKING_DIR}/"
ENV GO111MODULE on
COPY go.mod go.sum ./
RUN go mod download
COPY . .

FROM base-image as maker

Expand All @@ -38,6 +38,7 @@ FROM alpine:3.10
RUN addgroup -g 1000 -S app && \
adduser -u 1000 -S app -G app

COPY --from=base-image /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY --from=maker /go/src/github.com/containous/maesh/dist/maesh /app/

ENTRYPOINT ["/app/maesh"]
9 changes: 4 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,9 @@ test: $(DIST_DIR)
check: $(DIST_DIR) helm-lint
docker run -t --rm -v $(CURDIR):/go/src/$(PROJECT) -w /go/src/$(PROJECT) -e GO111MODULE golangci/golangci-lint:$(GOLANGCI_LINTER_VERSION) golangci-lint run --config .golangci.toml

push-docker: build
docker tag "$(DOCKER_IMAGE_NAME):latest" ${DOCKER_IMAGE_NAME}:${VERSION}
docker push ${DOCKER_IMAGE_NAME}:${VERSION}
docker push $(DOCKER_IMAGE_NAME):latest
publish-images: build
seihon publish -v "$(VERSION)" -v "latest" --image-name ${DOCKER_IMAGE_NAME} --dry-run=false --base-runtime-image=alpine:3.10


## Create packages for the release
release-packages: vendor build
Expand Down Expand Up @@ -127,6 +126,6 @@ helm-package: helm-lint pages
mv *.tgz index.md $(CURDIR)/pages/charts/
helm repo index $(CURDIR)/pages/charts/

.PHONY: local-check local-build local-test check build test push-docker \
.PHONY: local-check local-build local-test check build test publish-images \
vendor kubectl test-integration local-test-integration pages
.PHONY: helm helm-lint helm-package
39 changes: 39 additions & 0 deletions tmpl.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
FROM golang:1.13-alpine AS builder

# Package dependencies
RUN apk --no-cache --no-progress add \
bash \
gcc \
git \
make \
musl-dev \
mercurial \
curl \
tar \
ca-certificates \
tzdata \
&& update-ca-certificates \
&& rm -rf /var/cache/apk/*

WORKDIR /go/src/github.com/containous/maesh

# Download goreleaser binary to bin folder in $GOPATH
RUN curl -sfL https://install.goreleaser.com/github.com/goreleaser/goreleaser.sh | sh

ENV GO111MODULE on
COPY go.mod go.sum ./
RUN go mod download
COPY . .

RUN GOARCH={{ .GoARCH }} GOARM={{ .GoARM }} make local-build

## IMAGE
FROM {{ .RuntimeImage }}

RUN addgroup -g 1000 -S app && \
adduser -u 1000 -S app -G app

COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY --from=builder /go/src/github.com/containous/maesh/dist/maesh /app/

ENTRYPOINT ["/app/maesh"]

0 comments on commit 920849b

Please sign in to comment.