|
| 1 | +version: 2.1 |
| 2 | +executors: |
| 3 | + arm64_executor: |
| 4 | + machine: |
| 5 | + image: ubuntu-2204:current |
| 6 | + resource_class: arm.large |
| 7 | + environment: |
| 8 | + DOCKER_IMAGE: php74xc |
| 9 | + BINFMT_VERSION: qemu-v7.0.0-28 |
| 10 | + COMPOSER_VERSION: 1.10.27 |
| 11 | + XDEBUG_VERSION: 3.1.6 |
| 12 | + MCRYPT_VERSION: 1.0.7 |
| 13 | + amd64_executor: |
| 14 | + machine: |
| 15 | + image: ubuntu-2204:current |
| 16 | + resource_class: large |
| 17 | + environment: |
| 18 | + DOCKER_IMAGE: php74xc |
| 19 | + BINFMT_VERSION: qemu-v7.0.0-28 |
| 20 | + COMPOSER_VERSION: 1.10.27 |
| 21 | + XDEBUG_VERSION: 3.1.6 |
| 22 | + MCRYPT_VERSION: 1.0.7 |
| 23 | + DELETE_TAG_TAG: 1.0.2 |
| 24 | +jobs: |
| 25 | + test: |
| 26 | + executor: amd64_executor |
| 27 | + steps: |
| 28 | + - checkout |
| 29 | + - run: |
| 30 | + name: "Build image" |
| 31 | + command: | |
| 32 | + docker build \ |
| 33 | + --build-arg COMPOSER_VERSION=$COMPOSER_VERSION \ |
| 34 | + --build-arg XDEBUG_VERSION=$XDEBUG_VERSION \ |
| 35 | + --build-arg MCRYPT_VERSION=$MCRYPT_VERSION \ |
| 36 | + --tag $DOCKER_LOGIN/$DOCKER_IMAGE:test \ |
| 37 | + '.' |
| 38 | + - run: |
| 39 | + name: "Test image" |
| 40 | + command: | |
| 41 | + docker run --rm $DOCKER_LOGIN/$DOCKER_IMAGE:test php -v | grep 7.4.33 |
| 42 | + docker run --rm $DOCKER_LOGIN/$DOCKER_IMAGE:test php -v | grep OPcache |
| 43 | + docker run --rm $DOCKER_LOGIN/$DOCKER_IMAGE:test php -m | grep xdebug |
| 44 | + docker run --rm $DOCKER_LOGIN/$DOCKER_IMAGE:test php -r "xdebug_info();" | grep $XDEBUG_VERSION |
| 45 | + docker run --rm $DOCKER_LOGIN/$DOCKER_IMAGE:test php -m | grep pdo_pgsql |
| 46 | + docker run --rm $DOCKER_LOGIN/$DOCKER_IMAGE:test /usr/bin/composer -V | grep "1.10.27" |
| 47 | + docker run --rm $DOCKER_LOGIN/$DOCKER_IMAGE:test php -i | grep "short_open_tag => Off => Off" |
| 48 | + docker run --rm $DOCKER_LOGIN/$DOCKER_IMAGE:test php -i | grep "memory_limit => 512M => 512M" |
| 49 | + build_arm64: |
| 50 | + executor: arm64_executor |
| 51 | + steps: |
| 52 | + - checkout |
| 53 | + - run: |
| 54 | + name: "Login to Docker HUB" |
| 55 | + command: docker login -u $DOCKER_LOGIN -p $DOCKER_PASSWORD |
| 56 | + - run: |
| 57 | + name: "Install tonistiigi/binfmt" |
| 58 | + command: docker run --rm --privileged tonistiigi/binfmt:$BINFMT_VERSION --install all |
| 59 | + - run: |
| 60 | + name: "Create buildx multiarch" |
| 61 | + command: | |
| 62 | + docker buildx create \ |
| 63 | + --name multiarch \ |
| 64 | + --use \ |
| 65 | + && docker buildx inspect \ |
| 66 | + --bootstrap \ |
| 67 | + --builder \ |
| 68 | + multiarch |
| 69 | + - run: |
| 70 | + name: "Build image and push to Docker HUB" |
| 71 | + command: | |
| 72 | + docker buildx build \ |
| 73 | + --cache-to=type=inline \ |
| 74 | + --platform linux/arm/v6,linux/arm/v7,linux/arm64 \ |
| 75 | + --build-arg COMPOSER_VERSION=$COMPOSER_VERSION \ |
| 76 | + --build-arg XDEBUG_VERSION=$XDEBUG_VERSION \ |
| 77 | + --build-arg MCRYPT_VERSION=$MCRYPT_VERSION \ |
| 78 | + --tag $DOCKER_LOGIN/$DOCKER_IMAGE:cache-arm \ |
| 79 | + --push \ |
| 80 | + '.' |
| 81 | + build_amd64: |
| 82 | + executor: amd64_executor |
| 83 | + steps: |
| 84 | + - checkout |
| 85 | + - run: |
| 86 | + name: "Login to Docker HUB" |
| 87 | + command: docker login -u $DOCKER_LOGIN -p $DOCKER_PASSWORD |
| 88 | + - run: |
| 89 | + name: "Install tonistiigi/binfmt" |
| 90 | + command: docker run --rm --privileged tonistiigi/binfmt:$BINFMT_VERSION --install all |
| 91 | + - run: |
| 92 | + name: "Create buildx multiarch" |
| 93 | + command: | |
| 94 | + docker buildx create \ |
| 95 | + --name multiarch \ |
| 96 | + --use \ |
| 97 | + && docker buildx inspect \ |
| 98 | + --bootstrap \ |
| 99 | + --builder \ |
| 100 | + multiarch |
| 101 | + - run: |
| 102 | + name: "Build image and push to Docker HUB" |
| 103 | + command: | |
| 104 | + docker buildx build \ |
| 105 | + --cache-from type=registry,ref=$DOCKER_LOGIN/$DOCKER_IMAGE:cache-arm \ |
| 106 | + --platform linux/amd64,linux/arm64,linux/arm/v6,linux/arm/v7 \ |
| 107 | + --build-arg COMPOSER_VERSION=$COMPOSER_VERSION \ |
| 108 | + --build-arg XDEBUG_VERSION=$XDEBUG_VERSION \ |
| 109 | + --build-arg MCRYPT_VERSION=$MCRYPT_VERSION \ |
| 110 | + --tag $DOCKER_LOGIN/$DOCKER_IMAGE:$CIRCLE_TAG \ |
| 111 | + --tag $DOCKER_LOGIN/$DOCKER_IMAGE:latest \ |
| 112 | + --push \ |
| 113 | + "." |
| 114 | + delete_cache_arm: |
| 115 | + executor: amd64_executor |
| 116 | + steps: |
| 117 | + - run: |
| 118 | + name: "Login to Docker HUB" |
| 119 | + command: docker login -u $DOCKER_LOGIN -p $DOCKER_PASSWORD |
| 120 | + - run: |
| 121 | + name: "Remove cache arm image" |
| 122 | + command: | |
| 123 | + docker run \ |
| 124 | + -it \ |
| 125 | + --rm \ |
| 126 | + --name $DOCKER_IMAGE \ |
| 127 | + -e DOCKER_USERNAME=$DOCKER_LOGIN \ |
| 128 | + -e DOCKER_PASSWORD=$DOCKER_PASSWORD \ |
| 129 | + -e ORGANIZATION=$DOCKER_LOGIN \ |
| 130 | + -e IMAGE=$DOCKER_IMAGE \ |
| 131 | + -e TAG=cache-arm \ |
| 132 | + $DOCKER_LOGIN/$DOCKER_IMAGE:$DELETE_TAG_TAG |
| 133 | +workflows: |
| 134 | + test_and_build_images: |
| 135 | + jobs: |
| 136 | + - test: |
| 137 | + context: SECRETS |
| 138 | + filters: |
| 139 | + branches: |
| 140 | + only: |
| 141 | + - master |
| 142 | + - develop |
| 143 | + - build_arm64: |
| 144 | + context: SECRETS |
| 145 | + filters: |
| 146 | + tags: |
| 147 | + only: /.*/ |
| 148 | + branches: |
| 149 | + ignore: /.*/ |
| 150 | + - build_amd64: |
| 151 | + context: SECRETS |
| 152 | + filters: |
| 153 | + tags: |
| 154 | + only: /.*/ |
| 155 | + branches: |
| 156 | + ignore: /.*/ |
| 157 | + requires: |
| 158 | + - build_arm64 |
| 159 | + - delete_cache_arm: |
| 160 | + context: SECRETS |
| 161 | + filters: |
| 162 | + tags: |
| 163 | + only: /.*/ |
| 164 | + branches: |
| 165 | + ignore: /.*/ |
| 166 | + requires: |
| 167 | + - build_amd64 |
| 168 | + |
0 commit comments