|
4 | 4 | |
5 | 5 | ms-teams: cloudradar-monitoring/[email protected] |
6 | 6 | env: |
7 | | - BASE_REPO: opencti |
| 7 | + DOCKER_REPO: opencti |
| 8 | + GHCR_REPO: ghcr.io/OpenCTI-Platform/client-python |
8 | 9 | jobs: |
9 | 10 | ensure_formatting: |
10 | 11 | docker: |
@@ -50,55 +51,41 @@ jobs: |
50 | 51 | - ms-teams/report: |
51 | 52 | only_on_fail: true |
52 | 53 | webhook_url: $MS_TEAMS_WEBHOOK_URL |
53 | | - build-container-python-3-11: |
54 | | - docker: |
55 | | - - image: cimg/base:stable-20.04 |
| 54 | + |
| 55 | + build-container: |
| 56 | + executor: docker/docker |
| 57 | + parameters: |
| 58 | + python_version: |
| 59 | + type: string |
56 | 60 | steps: |
57 | 61 | - checkout |
58 | | - - setup_remote_docker |
| 62 | + - setup_remote_docker: |
| 63 | + docker_layer_caching: true |
59 | 64 | - run: |
60 | | - name: Build opencti/python-client-container |
| 65 | + name: Setup Docker Buildx |
61 | 66 | command: | |
62 | | - docker run --privileged --rm tonistiigi/binfmt --install all |
63 | | - CIRCLE_TAG=${CIRCLE_TAG:-nightly} |
64 | | - echo "CIRCLE_TAG=${CIRCLE_TAG}" |
65 | | - echo "$DOCKERHUB_PASS" | docker login -u "$DOCKERHUB_USERNAME" --password-stdin |
66 | | - docker buildx create --platform linux/amd64,linux/arm64 --use --name mybuilder || true |
67 | | - docker buildx inspect mybuilder --bootstrap |
68 | | - docker buildx build . \ |
69 | | - --platform linux/amd64,linux/arm64 \ |
70 | | - -t ${{ env.BASE_REPO }}/client-python-3-11:${CIRCLE_TAG} \ |
71 | | - -t ${{ env.BASE_REPO }}client-python-3-11:latest \ |
72 | | - --build-arg BASE_IMAGE="python:3.11-alpine3.20" |
73 | | -
|
| 67 | + docker buildx create --driver docker-container --name multiarch --use |
| 68 | + - run: |
| 69 | + name: Login to Docker Hub |
| 70 | + command: echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin |
74 | 71 | - run: |
75 | | - name: Push image to regsitry |
76 | | - command: docker push ${{ env.BASE_REPO }}/client-python-3-11:latest --all-tags |
| 72 | + name: Login to GitHub Container Registry |
| 73 | + command: echo "$GITHUB_TOKEN" | docker login ghcr.io -u "$GITHUB_USERNAME" --password-stdin |
77 | 74 |
|
78 | | - build-container-python-3-12: |
79 | | - docker: |
80 | | - - image: cimg/base:stable-20.04 |
81 | | - steps: |
82 | | - - checkout |
83 | | - - setup_remote_docker |
84 | 75 | - run: |
85 | | - name: Build opencti/python-client |
| 76 | + name: Build and Push Alpine Multi-arch Image |
86 | 77 | command: | |
87 | | - docker run --privileged --rm tonistiigi/binfmt --install all |
88 | | - CIRCLE_TAG=${CIRCLE_TAG:-nightly} |
89 | | - echo "CIRCLE_TAG=${CIRCLE_TAG}" |
90 | | - echo "$DOCKERHUB_PASS" | docker login -u "$DOCKERHUB_USERNAME" --password-stdin |
91 | | - docker buildx create --platform linux/amd64,linux/arm64 --use --name mybuilder || true |
92 | | - docker buildx inspect mybuilder --bootstrap |
93 | | - docker buildx build . \ |
| 78 | + VERSION=${CIRCLE_TAG:-latest} |
| 79 | + PYTHON_VERSION_TAG=$(echo "<< parameters.python_version >>" | sed 's/\./-/g') |
| 80 | + docker buildx build \ |
94 | 81 | --platform linux/amd64,linux/arm64 \ |
95 | | - -t ${{ env.BASE_REPO }}/client-python-3-12:${CIRCLE_TAG} \ |
96 | | - -t ${{ env.BASE_REPO }}/client-python-3-12:latest \ |
97 | | - --build-arg BASE_IMAGE="python:3.12-alpine3.20" |
98 | | -
|
99 | | - - run: |
100 | | - name: Push image to regsitry |
101 | | - command: docker push ${{ env.BASE_REPO }}/client-python-3-12:latest --all-tags |
| 82 | + --file Dockerfile.alpine \ |
| 83 | + --tag ${{ env.DOCKER_REPO }}/client-python-${PYTHON_VERSION_TAG}:${VERSION} \ |
| 84 | + --tag ${{ env.DOCKER_REPO }}/client-python-${PYTHON_VERSION_TAG}:latest \ |
| 85 | + --tag ${{ env.GHCR_REPO }}/client-python-${PYTHON_VERSION_TAG}:${VERSION} \ |
| 86 | + --tag ${{ env.GHCR_REPO }}/client-python-${PYTHON_VERSION_TAG}:latest \ |
| 87 | + --push \ |
| 88 | + --file Dockerfile |
102 | 89 |
|
103 | 90 | build-library: |
104 | 91 | working_directory: ~/opencti-client |
@@ -196,18 +183,17 @@ workflows: |
196 | 183 | filters: |
197 | 184 | tags: |
198 | 185 | only: /.*/ |
199 | | - - build-container-python-3-11: |
200 | | - requires: |
201 | | - - build-library |
202 | | - filters: |
203 | | - tags: |
204 | | - only: /[0-9]+(\.[0-9]+)+(\.[0-9]+)?\.?(\w)*/ |
205 | | - - build-container-python-3-12: |
| 186 | + |
| 187 | + - build-container: |
| 188 | + matrix: |
| 189 | + parameters: |
| 190 | + python_version: ["3.11", "3.12"] |
206 | 191 | requires: |
207 | 192 | - build-library |
208 | 193 | filters: |
209 | 194 | tags: |
210 | 195 | only: /[0-9]+(\.[0-9]+)+(\.[0-9]+)?\.?(\w)*/ |
| 196 | + |
211 | 197 | - build-library: |
212 | 198 | filters: |
213 | 199 | tags: |
|
0 commit comments