This commit is contained in:
Jeff Vandrew Jr 2019-02-19 22:45:55 -05:00
parent bf00b3d3da
commit 12967055f6
2 changed files with 95 additions and 22 deletions

View File

@ -1,38 +1,71 @@
version: 2
jobs:
build:
machine:
docker_layer_caching: true
steps:
- checkout
# Everytimes if a tag of specific format is push on git, a docker image is created and pushed to dockerhub
# eg. You tag v1.0, then the docker image $DOCKERHUB_REPO:1.0 will be built and push to docker hub.
# Requires: $DOCKERHUB_USER, $DOCKERHUB_PASS, $DOCKERHUB_REPO defined
publish_linuxamd64:
# Define in CircleCi Project Variables: $DOCKERHUB_REPO, $DOCKERHUB_USER, $DOCKERHUB_PASS
# Publish jobs require those variables
publish_docker_linuxamd64:
machine:
docker_layer_caching: true
steps:
- checkout
- run:
command: |
LATEST_TAG="${CIRCLE_TAG:1}"
DOCKERHUB_DESTINATION="$DOCKERHUB_REPO:$LATEST_TAG-amd64"
DOCKERHUB_DOCKEFILE="Dockerfile"
#
echo "Pushing $DOCKERHUB_DOCKEFILE to dockerhub repository $DOCKERHUB_DESTINATION"
cd docker-compose-generator
sudo docker login --username=$DOCKERHUB_USER --password=$DOCKERHUB_PASS
sudo docker build --pull -t "$DOCKERHUB_DESTINATION" -f "$DOCKERHUB_DOCKEFILE" .
sudo docker push $DOCKERHUB_DESTINATION
# Push a manifest like image, we support only amd64 now, so no need to create real manifest
DOCKERHUB_DESTINATION="$DOCKERHUB_REPO:$LATEST_TAG"
sudo docker tag "$DOCKERHUB_DESTINATION-amd64" "$DOCKERHUB_DESTINATION"
sudo docker push "$DOCKERHUB_DESTINATION"
sudo docker build --pull -t $DOCKERHUB_REPO:latest-amd64 -f linuxamd64.Dockerfile .
sudo docker push $DOCKERHUB_REPO:latest-amd64
publish_docker_linuxarm32v7:
machine:
docker_layer_caching: true
steps:
- checkout
- run:
command: |
sudo docker run --rm --privileged multiarch/qemu-user-static:register --reset
#
cd docker-compose-generator
sudo docker login --username=$DOCKERHUB_USER --password=$DOCKERHUB_PASS
sudo docker build --pull -t $DOCKERHUB_REPO:latest-arm32v7 -f linuxarm32v7.Dockerfile .
sudo docker push $DOCKERHUB_REPO:latest-arm32v7
publish_docker_multiarch:
machine:
enabled: true
image: circleci/classic:201808-01
steps:
- run:
command: |
# Turn on Experimental features
sudo mkdir $HOME/.docker
sudo sh -c 'echo "{ \"experimental\": \"enabled\" }" >> $HOME/.docker/config.json'
#
sudo docker login --username=$DOCKERHUB_USER --password=$DOCKERHUB_PASS
#
sudo docker manifest create --amend $DOCKERHUB_REPO:latest $DOCKERHUB_REPO:latest-amd64 $DOCKERHUB_REPO:latest-arm32v7
sudo docker manifest annotate $DOCKERHUB_REPO:latest $DOCKERHUB_REPO:latest-amd64 --os linux --arch amd64
sudo docker manifest annotate $DOCKERHUB_REPO:latest $DOCKERHUB_REPO:latest-arm32v7 --os linux --arch arm --variant v7
sudo docker manifest push $DOCKERHUB_REPO:latest -p
workflows:
version: 2
publish:
jobs:
- publish_linuxamd64:
- publish_docker_linuxamd64:
filters:
branches:
ignore: /.*/
tags:
only: /v[0-9]+(\.[0-9]+)*/
- publish_docker_linuxarm32v7:
filters:
branches:
ignore: /.*/
tags:
only: /v[0-9]+(\.[0-9]+)*/
- publish_docker_multiarch:
requires:
- publish_docker_linuxamd64
- publish_docker_linuxarm32v7
filters:
branches:
ignore: /.*/

40
.circleci/old.yml Normal file
View File

@ -0,0 +1,40 @@
version: 2
jobs:
build:
machine:
docker_layer_caching: true
steps:
- checkout
# Everytimes if a tag of specific format is push on git, a docker image is created and pushed to dockerhub
# eg. You tag v1.0, then the docker image $DOCKERHUB_REPO:1.0 will be built and push to docker hub.
# Requires: $DOCKERHUB_USER, $DOCKERHUB_PASS, $DOCKERHUB_REPO defined
publish_linuxamd64:
machine:
docker_layer_caching: true
steps:
- checkout
- run:
command: |
LATEST_TAG="${CIRCLE_TAG:1}"
DOCKERHUB_DESTINATION="$DOCKERHUB_REPO:$LATEST_TAG-amd64"
DOCKERHUB_DOCKEFILE="Dockerfile"
#
echo "Pushing $DOCKERHUB_DOCKEFILE to dockerhub repository $DOCKERHUB_DESTINATION"
sudo docker login --username=$DOCKERHUB_USER --password=$DOCKERHUB_PASS
sudo docker build --pull -t "$DOCKERHUB_DESTINATION" -f "$DOCKERHUB_DOCKEFILE" .
sudo docker push $DOCKERHUB_DESTINATION
# Push a manifest like image, we support only amd64 now, so no need to create real manifest
DOCKERHUB_DESTINATION="$DOCKERHUB_REPO:$LATEST_TAG"
sudo docker tag "$DOCKERHUB_DESTINATION-amd64" "$DOCKERHUB_DESTINATION"
sudo docker push "$DOCKERHUB_DESTINATION"
workflows:
version: 2
publish:
jobs:
- publish_linuxamd64:
filters:
branches:
ignore: /.*/
tags:
only: /v[0-9]+(\.[0-9]+)*/