Skip to content
This repository has been archived by the owner on Jul 28, 2023. It is now read-only.

Commit

Permalink
Multi architecture support for init-controller image (#68)
Browse files Browse the repository at this point in the history
* support multiple docker arch image

* have to use buildx

* trying travis

* changed default repo for deploy

* changed repo

* edited out releases on travis branch

* commented out tests

* change to use TRAVIS TAG

* removed tests

* removed test script

* install qemu

* changed script

* check contnets of package

* list contents

* list package

* changed makefile

* reverted back to allow merge into appsody

* removed return at the end of test file

* removed duplicate line at start of script

* changes from feeedback

* fixed declare
  • Loading branch information
CameronMcWilliam authored Mar 31, 2020
1 parent 3039d55 commit 1621bc3
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 10 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/controller
/build
/package
.vscode/
.vscode/
.DS_Store
9 changes: 8 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@ go_import_path: github.com/appsody/controller
services:
- docker

#Install later docker version
before_install:
- curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
- sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
- sudo apt-get update
- sudo apt-get -y -o Dpkg::Options::="--force-confnew" install docker-ce

# skip because dependencies are baked in vendor dir
install: true

Expand All @@ -35,7 +42,7 @@ deploy:
repo: appsody/controller
- provider: script
skip_cleanup: true
script: bash ./build.sh
script: ./build.sh
on:
tags: true
repo: appsody/controller
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM busybox

COPY ./package/appsody-controller /appsody-controller
ARG TARGETPLATFORM
COPY ./package/appsody-controller-$TARGETPLATFORM /appsody-controller
RUN chmod +x /appsody-controller
WORKDIR /
CMD ["cp","/appsody-controller","/.appsody/appsody-controller"]
5 changes: 3 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,13 @@ clean: ## Removes existing build artifacts in order to get a fresh build

.PHONY: build
build: ## Build binary for linux stores it in the build/ dir
GOOS=linux CGO_ENABLED=0 GOARCH=amd64 go build -o $(BUILD_PATH)/$(COMMAND) -ldflags "-X main.VERSION=$(VERSION)"
chmod u+r+x go_build.sh
./go_build.sh $(VERSION)

.PHONY: package
package: build ## Build the linux binary and stores it in package/ dir
mkdir -p $(PACKAGE_PATH)
cp -p $(BUILD_PATH)/$(COMMAND) $(PACKAGE_PATH)/
cp -ap $(BUILD_PATH)/. $(PACKAGE_PATH)/

# Auto documented help from http://marmelab.com/blog/2016/02/29/auto-documented-makefile.html
.PHONY: help
Expand Down
11 changes: 7 additions & 4 deletions build.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
#!/bin/bash


set -e
echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
docker build -t $DOCKER_ORG/init-controller:$TRAVIS_TAG -t $DOCKER_ORG/init-controller:latest .
docker push $DOCKER_ORG/init-controller
# enables experimental daemon for docker buildx: https://docs.docker.com/buildx/working-with-buildx/
# minimum docker version required for buildx is v19.03
export DOCKER_CLI_EXPERIMENTAL=enabled
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
docker buildx create --name mybuilder
docker buildx use mybuilder
docker buildx build -t $DOCKER_ORG/init-controller:$TRAVIS_TAG -t $DOCKER_ORG/init-controller:latest --platform=linux/amd64,linux/ppc64le,linux/s390x . --push
8 changes: 8 additions & 0 deletions go_build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash
set -e
for OS_ARCH in linux/amd64 linux/ppc64le linux/s390x
do
declare OS=$(echo $OS_ARCH | cut -f1 -d/)
declare ARCH=$(echo $OS_ARCH | cut -f2 -d/)
GOOS="$OS" CGO_ENABLED=0 GOARCH="$ARCH" go build -o ./build/appsody-controller-"$OS_ARCH" -ldflags "-X main.VERSION=$1"
done

0 comments on commit 1621bc3

Please sign in to comment.