Skip to content

Commit

Permalink
Merge pull request #69 from nqdao/ISSUE-39
Browse files Browse the repository at this point in the history
ISSUE-39: Parallel image build
  • Loading branch information
syyang-in-cloud authored Sep 16, 2020
2 parents 98f40cd + 6cccc9f commit 253bfb8
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 10 deletions.
12 changes: 11 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,15 @@ lauguage: minimal
service:
- docker

env:
jobs:
- DISTRO_NAME=ubuntu DISTRO_VERSION=bionic TYPE=base
- DISTRO_NAME=ubuntu DISTRO_VERSION=bionic TYPE=docker
- DISTRO_NAME=centos DISTRO_VERSION=7 TYPE=base
- DISTRO_NAME=centos DISTRO_VERSION=7 TYPE=docker

before_script:
- make prep-builder

scripts:
- make all
- make build-image
15 changes: 11 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@
IMAGE_NAME ?= ibmcloud-image-builder
IMAGE_NAME_UBUNTU ?= ibmcloud-image-builder-ubuntu
IMAGE_VERSION_LATEST ?= latest
REMOTE_BRANCH ?= master
REMOTE_BRANCH ?= main

## Options
default: all

all: build build-images cleanup
all: pre-builder build-all cleanup

build:
prep-builder:
docker build . -f Dockerfile -t $(IMAGE_NAME):$(IMAGE_VERSION_LATEST)

ubuntu-build:
docker build . -f Dockerfile.ubuntu -t $(IMAGE_NAME_UBUNTU):$(IMAGE_VERSION_LATEST)

build-images:
build-all:
docker run --privileged -v `pwd`:/ibmcloud-image-builder ${IMAGE_NAME}:${IMAGE_VERSION_LATEST} /bin/bash -c "./packer-build.sh packer/ubuntu/bionic/base "
docker run --privileged -v `pwd`:/ibmcloud-image-builder ${IMAGE_NAME}:${IMAGE_VERSION_LATEST} /bin/bash -c "./packer-build.sh packer/ubuntu/bionic/docker "
docker run --privileged -v `pwd`:/ibmcloud-image-builder ${IMAGE_NAME}:${IMAGE_VERSION_LATEST} /bin/bash -c "./packer-build.sh packer/centos/7/base "
Expand Down Expand Up @@ -43,4 +43,11 @@ centos-7-docker:
docker run --privileged -v `pwd`:/ibmcloud-image-builder ${IMAGE_NAME}:${IMAGE_VERSION_LATEST} /bin/bash -c "./packer-build.sh packer/centos/7/docker "
docker run --privileged -v `pwd`:/ibmcloud-image-builder ${IMAGE_NAME}:${IMAGE_VERSION_LATEST} /bin/bash -c "./packer-delete.sh packer/centos/7/docker "

build-image:
$(if $(DISTRO_NAME),,$(error DISTRO_NAME is not set. [ubuntu, centos]))
$(if $(DISTRO_VERSION),,$(error DISTRO_VERSION is not set.[bionic (ubuntu), 7 (centos)]))
$(if $(TYPE),,$(error TYPE is not set. [base, docker]))
docker run --privileged --rm -v `pwd`:/ibmcloud-image-builder ${IMAGE_NAME}:${IMAGE_VERSION_LATEST} /bin/bash -c "./packer-build.sh packer/${DISTRO_NAME}/${DISTRO_VERSION}/${TYPE}"
docker run --privileged --rm -v `pwd`:/ibmcloud-image-builder ${IMAGE_NAME}:${IMAGE_VERSION_LATEST} /bin/bash -c "./packer-delete.sh packer/${DISTRO_NAME}/${DISTRO_VERSION}/${TYPE}"

.PHONY: all
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ git clone git@github.com:IBM-Cloud/ibmcloud-image-builder.git
cd ibmcloud-image-builder
docker pull syibm/ibmcloud-image-builder
docker tag syibm/ibmcloud-image-builder ibmcloud-image-builder
make build-images
make build-all
```


Expand Down Expand Up @@ -133,15 +133,15 @@ $ git clone git@github.com:IBM-Cloud/ibmcloud-image-builder.git
$ cd ibmcloud-image-builder
$ docker pull syibm/ibmcloud-image-builder
$ docker tag syibm/ibmcloud-image-builder ibmcloud-image-builder
$ make build-images
$ make build-all
```

Or we can build the docker image(`make build`) locally as below:
Or we can build the docker image(`make prep-builder`) locally as below:
```
$ git clone git@github.com:IBM-Cloud/ibmcloud-image-builder.git
$ cd ibmcloud-image-builder
$ make build
$ make build-images
$ make prep-builder
$ make build-all
```

Note: If a new packer template needs to be created, then please repeat yourself.
Expand Down

0 comments on commit 253bfb8

Please sign in to comment.