Skip to content

Commit

Permalink
Implement multiarch (#31)
Browse files Browse the repository at this point in the history
* Build multi-arch amd64, arm64, armv6, armv7 with buildx

* Uses mariadb 10.4, as 10.3 was failing with arm64 tests

* Update README.md

* Fixes #30
  • Loading branch information
roblandry authored Feb 23, 2020
1 parent b41e6c5 commit d2f6f05
Show file tree
Hide file tree
Showing 3 changed files with 116 additions and 66 deletions.
134 changes: 83 additions & 51 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,62 +1,94 @@
os:
- linux

os: linux
dist: xenial

sudo: required
language: generic

env:
global:
- NAME=lychee-laravel
- REPO=lycheeorg/lychee-laravel

matrix:
- DOCKER_REPO=lycheeorg/lychee-laravel
jobs:
- secure: "FXXbM8yDCuf9h17rAyO63XCgI2wJ5EKROY3u1MNxudz54sz3VloZ/SNnVqzdjzYPX9LXfCxVpaDhNLmQtNbqYXg4WBq+5ZuuS0efxFgVaBK0HK6lVoS3/BsJR/U1cglag0Apn2wjFgL3j7d2ZREeG7WIEuDHW5QWcVWhFGWvcAG9JRChFostdde1wbZ6SLTTW2SZFypoRThIdh5PCOnX1oCCmfzeTiCy74uTaiOkkOWsseWeDBy09UrDsFDKd8WX9R7E7g9arv4f9tjzmk1ikQM6Bnfa4YONsY9NjiKFS7/1qfXqg6Z5WfuNr+tW90KrXlk3quCPTn9PEThfqJkgS3BcsLwdhM0OUPx0BXml3RFzYl7jrtj6Wg1vSh6JJIrCh6YrBvg62qRgBs8VPI7QJ60VC56QjhZCiH1YjkjKF0+vVSygC6oJ8wsSciFGu3Cfi4ix6K8iCN90URr6YGl7WOANgfzBTwil/w1Q3IKmzNj6K2UWD+Dm92k/7dkJ2/N5gZ8LUmqhxs5nRzLBZvm77xp/ykRtadP5MHC6HTVHBM6f4tfe6jLWWSi4D8GzQX5sN6Xd2VhvifFsxQeexobhxA918ZjxvUgXHP8mng/WUYccr8DJQmom6uyXpqNpVXGRbjW4CVmgLGBZ05+lgBEmqkyEiXggNRcZipi4E9FICys="

language: php

php:
- '7.2'

services:
- docker

addons:
mariadb: '10.3'

before_install:
- mysql -e 'create database homestead_test;'
- chmod +x deploy.sh

install:
- docker build --pull -t $REPO':'$TRAVIS_BUILD_NUMBER .
- docker run -d --name=$NAME -e PUID=1000 -e PGID=1000 -e PHP_TZ=America/New_York
-e DB_CONNECTION=mysql -e DB_HOST=mariadb -e DB_PORT=3306 -e DB_DATABASE=homestead_test
-e DB_USERNAME=root -e DB_PASSWORD= -p 127.0.0.1:80:80 $REPO':'$TRAVIS_BUILD_NUMBER
jobs:
include:

before_script:
# Build and push to staging
- stage: build
before_install:
# Setup multi-arch builds
- curl -fsSL https://get.docker.com | sh
- echo '{"experimental":"enabled"}' | sudo tee /etc/docker/daemon.json
- mkdir -p $HOME/.docker
- echo '{"experimental":"enabled"}' | sudo tee $HOME/.docker/config.json
- sudo service docker start
install:
- docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
- docker buildx create --name xbuilder --use
script:
- docker login -u $REGISTRY_USER -p $REGISTRY_PASS
- echo "Building mulit arch and pushing testing"
- docker buildx build
--progress plain
--platform linux/arm/v7,linux/arm/v6,linux/arm64,linux/amd64
-t $DOCKER_REPO':testing'
--push
.

script:
- docker ps -a | awk '{print $NF}' | grep -w $NAME | cat
# Pull images and test them
- stage: "Test amd64"
arch: amd64
addons:
mariadb: '10.4'
services: docker
before_install:
- sudo mysql -e 'create database homestead_test;'
install:
- docker run -d --name=$NAME -e PUID=1000 -e PGID=1000 -e PHP_TZ=America/New_York
-e DB_CONNECTION=mysql -e DB_HOST=mariadb -e DB_PORT=3306 -e DB_DATABASE=homestead_test
-e DB_USERNAME=root -e DB_PASSWORD= -p 127.0.0.1:80:80 $DOCKER_REPO':testing'
script:
- docker ps -a | awk '{print $NF}' | grep -w $NAME | cat
after_script:
- docker stop $NAME && docker rm $NAME

# after_success:
# - ./deploy.sh
deploy:
- provider: script
script: ./deploy.sh
skip_cleanup: true
on:
branch: master
- provider: script
script: ./deploy.sh
skip_cleanup: true
on:
tags: true
- provider: script
script: ./deploy.sh
skip_cleanup: true
on:
all_branches: true
# Pull images and test them
- stage: "Test arm64"
arch: arm64
addons:
mariadb: '10.4'
services: docker
before_install:
- sudo mysql -e 'create database homestead_test;'
install:
- docker run -d --name=$NAME -e PUID=1000 -e PGID=1000 -e PHP_TZ=America/New_York
-e DB_CONNECTION=mysql -e DB_HOST=mariadb -e DB_PORT=3306 -e DB_DATABASE=homestead_test
-e DB_USERNAME=root -e DB_PASSWORD= -p 127.0.0.1:80:80 $DOCKER_REPO':testing'
script:
- docker ps -a | awk '{print $NF}' | grep -w $NAME | cat
after_script:
- docker stop $NAME && docker rm $NAME

after_script:
- docker stop $NAME && docker rm $NAME
# Finally Push tags and master
- stage: deploy
before_install:
- curl -fsSL https://get.docker.com | sh
- echo '{"experimental":"enabled"}' | sudo tee /etc/docker/daemon.json
- mkdir -p $HOME/.docker
- echo '{"experimental":"enabled"}' | sudo tee $HOME/.docker/config.json
- sudo service docker start
install:
- docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
- docker buildx create --name xbuilder --use
deploy:
- provider: script
on:
branch: master
script: ./deploy.sh
- provider: script
on:
tags: true
script: ./deploy.sh
- provider: script
on:
all_branches: true
script: ./deploy.sh
21 changes: 17 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
[![Build Status](https://img.shields.io/travis/com/LycheeOrg/Lychee-Laravel-Docker/master.svg?style=flat)](https://travis-ci.com/LycheeOrg/Lychee-Laravel-Docker)
[![Docker Pulls](https://img.shields.io/docker/pulls/lycheeorg/lychee-laravel.svg?style=flat)](https://hub.docker.com/r/lycheeorg/lychee-laravel)
[![Release](https://img.shields.io/github/release/LycheeOrg/Lychee-Laravel-Docker.svg?style=flat)](https://github.com/LycheeOrg/Lychee-Laravel-Docker/releases)
![Last Commit](https://img.shields.io/github/last-commit/LycheeOrg/Lychee-Laravel-Docker.svg?style=flat)
[![Build Status][build-status-shield]](https://travis-ci.com/LycheeOrg/Lychee-Laravel-Docker)
[![Docker Pulls][docker-pulls-shield]](https://hub.docker.com/r/lycheeorg/lychee-laravel)
[![Release][release-shield]](https://github.com/LycheeOrg/Lychee-Laravel-Docker/releases)
![Last Commit][last-commit-shield]

![Supports amd64 Architecture][amd64-shield]
![Supports aarch64 Architecture][aarch64-shield]
![Supports armhf Architecture][armhf-shield]
![Supports armv7 Architecture][armv7-shield]

## Notice: Dockerhub repository has been migrated to [lycheeorg/lychee-laravel](https://hub.docker.com/r/lycheeorg/lychee-laravel)
**Make sure you update your docker-compose files accordingly**
Expand Down Expand Up @@ -101,3 +106,11 @@ Instead, we recommend to use the `PHP_VALUE` directive of PHP-FPM to override sp
3. Add a new line and set your new parameter
4. Mount your new file to `/etc/nginx/nginx.conf`

[aarch64-shield]: https://img.shields.io/badge/aarch64-yes-success.svg?style=flat
[amd64-shield]: https://img.shields.io/badge/amd64-yes-success.svg?style=flat
[armhf-shield]: https://img.shields.io/badge/armhf-yes-success.svg?style=flat
[armv7-shield]: https://img.shields.io/badge/armv7-yes-success.svg?style=flat
[build-status-shield]: https://img.shields.io/travis/com/LycheeOrg/Lychee-Laravel-Docker/master.svg?style=flat
[docker-pulls-shield]: https://img.shields.io/docker/pulls/lycheeorg/lychee-laravel.svg?style=flat
[last-commit-shield]: https://img.shields.io/github/last-commit/LycheeOrg/Lychee-Laravel-Docker.svg?style=flat
[release-shield]: https://img.shields.io/github/release/LycheeOrg/Lychee-Laravel-Docker.svg?style=flat
27 changes: 16 additions & 11 deletions deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,26 @@ docker login -u $REGISTRY_USER -p $REGISTRY_PASS

# if its a tagged version
if [[ -n "$TRAVIS_TAG" ]]; then
echo "Pushing tagged version and latest"
docker tag $REPO':'$TRAVIS_BUILD_NUMBER $REPO':latest'
docker tag $REPO':'$TRAVIS_BUILD_NUMBER $REPO':'$TRAVIS_TAG
docker push $REPO':'$TRAVIS_TAG
docker push $REPO':latest'
echo "Building mulit arch and pushing tagged version and latest"
docker buildx build \
--progress plain \
--platform linux/arm/v7,linux/arm/v6,linux/arm64,linux/amd64 \
-t $DOCKER_REPO':latest' \
-t $DOCKER_REPO':'$TRAVIS_TAG \
--push \
.

# if its a merged pr or nightly
elif [[ "$TRAVIS_BRANCH" == "master" && "$TRAVIS_PULL_REQUEST" == "false" ]]; then
echo "Pushing dev"
docker tag $REPO':'$TRAVIS_BUILD_NUMBER $REPO':dev'
docker push $REPO':dev'
echo "Building mulit arch and pushing dev"
docker buildx build \
--progress plain \
--platform linux/arm/v7,linux/arm/v6,linux/arm64,linux/amd64 \
-t $DOCKER_REPO':dev' \
--push \
.

# if a pr is created, or anything otherwise
else
echo "Pushing testing"
docker tag $REPO':'$TRAVIS_BUILD_NUMBER $REPO':testing'
docker push $REPO':testing'
echo "Nothing to push"
fi

0 comments on commit d2f6f05

Please sign in to comment.