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

Add multiarch support #12

Closed
wants to merge 24 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
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
67 changes: 67 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
sudo: required

language: generic

services:
- docker

env:
global:
- qemu_version=4.0.0-2
- target_version=1.1.2
matrix:
- target_arch=amd64 qemu_arch=x86_64
- target_arch=armv7 qemu_arch=arm
# - target_arch=armv6 qemu_arch=arm <------ NOT SUPPORTED BY DEBIAN STRETCH BASE IMAGE
- target_arch=arm64 qemu_arch=aarch64

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 install docker-ce
- mkdir $HOME/.docker
- 'echo "{" > $HOME/.docker/config.json'
- 'echo " \"experimental\": \"enabled\"" >> $HOME/.docker/config.json'
- 'echo "}" >> $HOME/.docker/config.json'
- sudo service docker restart
- git clone https://github.com/sstephenson/bats.git
Copy link
Contributor

@anagno anagno Jul 5, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello Everyone,

Out of curiosity. Is there a specific reason that the old bats was preferred and not the new repository (https://github.com/bats-core/bats-core)? Apparently the sstephenson/bats is abandoned (sstephenson/bats#248) and a new community has already emerge (sstephenson/bats#150).

Also I would pin the checkout to a specific version/release, so you are certain that something is broken in your build and not in your build scripts :)

KR,

Vasileios

Update: Nevermind. I saw that in the documentation of the image we are also using the old version.

- cd bats
- sudo ./install.sh /usr/local
- cd ..

install:
- docker run --rm --privileged multiarch/qemu-user-static:register
- curl -sLO https://github.com/multiarch/qemu-user-static/releases/download/v${qemu_version}/qemu-${qemu_arch}-static.tar.gz;
- tar -xzvf qemu-${qemu_arch}-static.tar.gz;
- mv qemu-${qemu_arch}-static image/
- make build ARCH=${target_arch}

script:
- docker run -d --name test_image osixia/light-baseimage-${target_arch}:${target_version} sleep 10
- sleep 5
- sudo docker ps | grep -q test_image

after_success:
- if [ -z "$DOCKER_USER" ]; then
echo "PR build, skipping Docker Hub push";
else
docker login -u "$DOCKER_USER" -p "$DOCKER_PASS";
make tag-latest push push-latest ARCH=${target_arch};
fi

jobs:
include:
- stage: deploy
install: skip
script: skip
after_success:
- if [ -z "$DOCKER_USER" ]; then
echo "PR build, skipping Docker Hub push";
else
docker login -u "$DOCKER_USER" -p "$DOCKER_PASS";
docker manifest create osixia/light-baseimage:${target_version} osixia/light-baseimage-armv7:${target_version} osixia/light-baseimage-arm64:${target_version} osixia/light-baseimage-amd64:${target_version};
docker manifest create osixia/light-baseimage:latest osixia/light-baseimage-armv7:latest osixia/light-baseimage-amd64:latest osixia/light-baseimage-arm64:latest;
docker manifest push osixia/light-baseimage:${target_version};
docker manifest push osixia/light-baseimage:latest;
fi
13 changes: 7 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@
NAME = osixia/light-baseimage
VERSION = 1.1.2
ARCH = amd64

.PHONY: build build-nocache test tag-latest push push-latest release git-tag-version

build:
docker build -t $(NAME):$(VERSION) --rm image
docker build -f image/Dockerfile.$(ARCH) -t $(NAME)-$(ARCH):$(VERSION) --rm image

build-nocache:
docker build -t $(NAME):$(VERSION) --no-cache --rm image
docker build -f image/Dockerfile.$(ARCH) -t $(NAME)-$(ARCH):$(VERSION) --no-cache --rm image

test:
env NAME=$(NAME) VERSION=$(VERSION) bats test/test.bats
env NAME=$(NAME)-$(ARCH) VERSION=$(VERSION) bats test/test.bats

tag-latest:
docker tag $(NAME):$(VERSION) $(NAME):latest
docker tag $(NAME)-$(ARCH):$(VERSION) $(NAME)-$(ARCH):latest

push:
docker push $(NAME):$(VERSION)
docker push $(NAME)-$(ARCH):$(VERSION)

push-latest:
docker push $(NAME):latest
docker push $(NAME)-$(ARCH):latest

release: build test tag-latest push push-latest

Expand Down
12 changes: 12 additions & 0 deletions image/Dockerfile.amd64
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM debian:stretch-slim

#COPY qemu-x86_64-static /usr/bin

COPY . /container
RUN /container/build.sh

ENV LANG="en_US.UTF-8" \
LANGUAGE="en_US:en" \
LC_ALL="en_US.UTF-8"

ENTRYPOINT ["/container/tool/run"]
12 changes: 12 additions & 0 deletions image/Dockerfile.arm64
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM arm64v8/debian:stretch-slim

COPY qemu-aarch64-static /usr/bin

COPY . /container
RUN /container/build.sh

ENV LANG="en_US.UTF-8" \
LANGUAGE="en_US:en" \
LC_ALL="en_US.UTF-8"

ENTRYPOINT ["/container/tool/run"]
12 changes: 12 additions & 0 deletions image/Dockerfile.armv7
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM arm32v7/debian:stretch-slim

COPY qemu-arm-static /usr/bin

COPY . /container
RUN /container/build.sh

ENV LANG="en_US.UTF-8" \
LANGUAGE="en_US:en" \
LC_ALL="en_US.UTF-8"

ENTRYPOINT ["/container/tool/run"]
File renamed without changes.