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

Support ARM/ARM64/AMD64 architectures #311

Closed
wants to merge 1 commit into from
Closed
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
85 changes: 85 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
name: build

on: [push]

jobs:
agent:
runs-on: ubuntu-latest
env:
REVISION: $(git rev-parse HEAD)
steps:
- name: Checkout
uses: actions/checkout@v1

- name: Set up Docker Buildx
id: buildx
uses: crazy-max/ghaction-docker-buildx@v1
with:
version: latest

- name: Login to GitHub Docker Registry
run: echo "${DOCKERHUB_PASSWORD}" | docker login -u "${DOCKERHUB_USERNAME}" --password-stdin
env:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }}

- name: Build Agent Container Image Non-Master
if: github.ref != 'refs/heads/master'
run: |
docker buildx build \
--platform linux/amd64,linux/arm64,linux/arm/v7 \
--build-arg=REVISION=${{ env.REVISION }} \
--tag raspbernetes/launcher-agent:${{ github.sha }} \
-f docker/agent.Dockerfile \
. \
--push
- name: Build Agent Container Image Master
if: github.ref == 'refs/heads/master'
run: |
docker buildx build \
--platform linux/amd64,linux/arm64,linux/arm/v7 \
--build-arg=REVISION=${{ env.REVISION }} \
--tag raspbernetes/launcher-agent:latest \
-f docker/agent.Dockerfile \
. \
--push
service:
runs-on: ubuntu-latest
env:
REVISION: $(git rev-parse HEAD)
steps:
- name: Checkout
uses: actions/checkout@v1

- name: Set up Docker Buildx
id: buildx
uses: crazy-max/ghaction-docker-buildx@v1
with:
version: latest

- name: Login to GitHub Docker Registry
run: echo "${DOCKERHUB_PASSWORD}" | docker login -u "${DOCKERHUB_USERNAME}" --password-stdin
env:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }}

- name: Build Service Container Image Non-Master
if: github.ref != 'refs/heads/master'
run: |
docker buildx build \
--platform linux/amd64,linux/arm64,linux/arm/v7 \
--build-arg=REVISION=${{ env.REVISION }} \
--tag raspbernetes/launcher-service:${{ github.sha }} \
-f docker/service.Dockerfile \
. \
--push
- name: Build Service Container Image Master
if: github.ref == 'refs/heads/master'
run: |
docker buildx build \
--platform linux/amd64,linux/arm64,linux/arm/v7 \
--build-arg=REVISION=${{ env.REVISION }} \
--tag raspbernetes/launcher-service:latest \
-f docker/service.Dockerfile \
. \
--push
29 changes: 13 additions & 16 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ GIT_VERSION :=$(shell git describe --always --long --dirty)
GIT_HASH :=$(shell git rev-parse HEAD)
IMAGE_TAG:=$(shell ./docker/image-tag)

LOCAL_GOARCH ?= $(shell go env GOARCH)
LOCAL_GOOS ?= $(shell go env GOOS)

# We can't install go packages on CircleCI without being root (or using sudo).
# Because the compilation is done only once there, it doesn't matter if we
# don't install the packages.
Expand All @@ -37,11 +40,12 @@ docker/Dockerfile.service: docker/Dockerfile.service.in Makefile
@echo Generating $@
@sed -e 's/@@GIT_HASH@@/$(GIT_HASH)/g' < $< > $@.tmp && mv $@.tmp $@

build/.%.done: docker/Dockerfile.%
mkdir -p ./build/docker/$*
cp -r $^ ./build/docker/$*/
${DOCKER} build --build-arg=revision=$(GIT_HASH) -t weaveworks/launcher-$* -t weaveworks/launcher-$*:$(IMAGE_TAG) -f build/docker/$*/Dockerfile.$* ./build/docker/$*
touch $@
# Temproarily disable in favor of CI docker buildx
# build/.%.done: docker/Dockerfile.%
# mkdir -p ./build/docker/$*
# cp -r $^ ./build/docker/$*/
# ${DOCKER} build --build-arg=revision=$(GIT_HASH) -t weaveworks/launcher-$* -t weaveworks/launcher-$*:$(IMAGE_TAG) -f build/docker/$*/Dockerfile.$* ./build/docker/$*
# touch $@

#
# Vendoring
Expand All @@ -62,12 +66,11 @@ lint:
#
# Agent
#

build/.agent.done: build/agent build/kubectl

build/agent: $(AGENT_DEPS)
build/agent: agent/*.go
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build $(BUILDFLAGS) -o $@ $(LDFLAGS) ./agent
CGO_ENABLED=0 GOOS=$(LOCAL_GOOS) GOARCH=$(LOCAL_GOARCH) go build $(BUILDFLAGS) -o $@ $(LDFLAGS) ./agent

include docker/kubectl.version

Expand All @@ -78,29 +81,24 @@ build/kubectl: cache/kubectl-$(KUBECTL_VERSION) docker/kubectl.version

cache/kubectl-$(KUBECTL_VERSION):
mkdir -p cache
curl -L -o $@ "https://storage.googleapis.com/kubernetes-release/release/$(KUBECTL_VERSION)/bin/linux/amd64/kubectl"
curl -L -o $@ "https://storage.googleapis.com/kubernetes-release/release/$(KUBECTL_VERSION)/bin/$(LOCAL_GOOS)/$(LOCAL_GOARCH)/kubectl"

# Bootstrap
#

build/.bootstrap.done: $(BOOTSTRAP_DEPS)
build/.bootstrap.done: bootstrap/*.go
for arch in amd64; do \
for os in linux darwin; do \
CGO_ENABLED=0 GOOS=$$os GOARCH=$$arch go build $(BUILDFLAGS) -o "build/bootstrap/bootstrap_"$$os"_"$$arch $(LDFLAGS) ./bootstrap; \
done; \
done
CGO_ENABLED=0 GOOS=$(LOCAL_GOOS) GOARCH=$(LOCAL_GOARCH) go build $(BUILDFLAGS) -o "build/bootstrap/bootstrap_$(LOCAL_GOOS)_$(LOCAL_GOARCH)" $(LDFLAGS) ./bootstrap
touch $@

#
# Service
#

build/.service.done: build/service build/static

build/service: $(SERVICE_DEPS)
build/service: service/*.go
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build $(BUILDFLAGS) -o $@ $(LDFLAGS) ./service
CGO_ENABLED=0 GOOS=$(LOCAL_GOOS) GOARCH=$(LOCAL_GOARCH) go build $(BUILDFLAGS) -o $@ $(LDFLAGS) ./service

# If we are not in CircleCI, we are local so use launcher-agent
# If we are in CircleCI, only use launcher-agent if we are building master, otherwise
Expand All @@ -121,7 +119,6 @@ build/static: service/static/* service/static/agent.yaml
#
# Local integration tests
#

integration-tests: all
./integration-tests/setup/reset-local-minikube.sh
./integration-tests/setup/setup-local-minikube.sh
Expand Down
36 changes: 36 additions & 0 deletions docker/agent.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
FROM golang:1.13-alpine as build

ARG TARGETPLATFORM

ENV GO111MODULE=off \
CGO_ENABLED=0

RUN apk add --no-cache git make bash curl binutils build-base

WORKDIR /go/src/github.com/weaveworks/launcher

RUN export GOOS=$(echo ${TARGETPLATFORM} | cut -d / -f1) && \
export GOARCH=$(echo ${TARGETPLATFORM} | cut -d / -f2) && \
GOARM=$(echo ${TARGETPLATFORM} | cut -d / -f3); export GOARM=${GOARM:1} && \
git clone --depth 1 https://github.com/xunholy/launcher.git . && make all

FROM alpine:3.7

ARG REVISION

RUN apk add --no-cache ca-certificates

COPY --from=build /go/src/github.com/weaveworks/launcher/build/agent /usr/bin/launcher-agent

COPY --from=build /go/src/github.com/weaveworks/launcher/build/kubectl /usr/bin/kubectl

ENTRYPOINT ["/usr/bin/launcher-agent"]

CMD ["-help"]


LABEL maintainer="Weaveworks <help@weave.works>" \
org.opencontainers.image.title="launcher-agent" \
org.opencontainers.image.source="https://github.com/weaveworks/launcher" \
org.opencontainers.image.revision="${REVISION}" \
org.opencontainers.image.vendor="Weaveworks"
39 changes: 39 additions & 0 deletions docker/service.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
FROM golang:1.13-alpine as build

ARG TARGETPLATFORM

ENV GO111MODULE=off \
CGO_ENABLED=0

RUN apk add --no-cache git make bash curl binutils build-base

WORKDIR /go/src/github.com/weaveworks/launcher

RUN export GOOS=$(echo ${TARGETPLATFORM} | cut -d / -f1) && \
export GOARCH=$(echo ${TARGETPLATFORM} | cut -d / -f2) && \
GOARM=$(echo ${TARGETPLATFORM} | cut -d / -f3); export GOARM=${GOARM:1} && \
git clone --depth 1 https://github.com/xunholy/launcher.git . && make all

FROM alpine:3.7

ARG REVISION

WORKDIR /

COPY --from=build /go/src/github.com/weaveworks/launcher/build/service /launcher-service

RUN mkdir static

COPY --from=build /go/src/github.com/weaveworks/launcher/build/static/install.sh /static/

COPY --from=build /go/src/github.com/weaveworks/launcher/build/static/agent.yaml /static/

EXPOSE 80

ENTRYPOINT ["/launcher-service", "--bootstrap-version=936c2cf3123d720b1357d95992d5c4b648be5a39"]

LABEL maintainer="Weaveworks <help@weave.works>" \
org.opencontainers.image.title="launcher-service" \
org.opencontainers.image.source="https://github.com/weaveworks/launcher" \
org.opencontainers.image.revision="${REVISION}" \
org.opencontainers.image.vendor="Weaveworks"