Skip to content
Open
Show file tree
Hide file tree
Changes from 17 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 68 additions & 7 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ version: 2.1
orbs:
slack: circleci/slack@4.13.3
ms-teams: cloudradar-monitoring/ms-teams@0.0.1
env:
BASE_REPO: opencti
jobs:
ensure_formatting:
docker:
Expand Down Expand Up @@ -48,7 +50,57 @@ jobs:
- ms-teams/report:
only_on_fail: true
webhook_url: $MS_TEAMS_WEBHOOK_URL
build:
build-container-python-3-11:
docker:
- image: cimg/base:stable-20.04
steps:
- checkout
- setup_remote_docker
- run:
name: Build opencti/python-client-container
command: |
docker run --privileged --rm tonistiigi/binfmt --install all
CIRCLE_TAG=${CIRCLE_TAG:-nightly}
echo "CIRCLE_TAG=${CIRCLE_TAG}"
echo "$DOCKERHUB_PASS" | docker login -u "$DOCKERHUB_USERNAME" --password-stdin
docker buildx create --platform linux/amd64,linux/arm64 --use --name mybuilder || true
docker buildx inspect mybuilder --bootstrap
docker buildx build . \
--platform linux/amd64,linux/arm64 \
-t ${{ env.BASE_REPO }}/client-python-3-11:${CIRCLE_TAG} \
-t ${{ env.BASE_REPO }}client-python-3-11:latest \
--build-arg BASE_IMAGE="python:3.11-alpine3.20"

- run:
name: Push image to regsitry
command: docker push ${{ env.BASE_REPO }}/client-python-3-11:latest --all-tags

build-container-python-3-12:
docker:
- image: cimg/base:stable-20.04
steps:
- checkout
- setup_remote_docker
- run:
name: Build opencti/python-client
command: |
docker run --privileged --rm tonistiigi/binfmt --install all
CIRCLE_TAG=${CIRCLE_TAG:-nightly}
echo "CIRCLE_TAG=${CIRCLE_TAG}"
echo "$DOCKERHUB_PASS" | docker login -u "$DOCKERHUB_USERNAME" --password-stdin
docker buildx create --platform linux/amd64,linux/arm64 --use --name mybuilder || true
docker buildx inspect mybuilder --bootstrap
docker buildx build . \
--platform linux/amd64,linux/arm64 \
-t ${{ env.BASE_REPO }}/client-python-3-12:${CIRCLE_TAG} \
-t ${{ env.BASE_REPO }}/client-python-3-12:latest \
--build-arg BASE_IMAGE="python:3.12-alpine3.20"

- run:
name: Push image to regsitry
command: docker push ${{ env.BASE_REPO }}/client-python-3-12:latest --all-tags

build-library:
working_directory: ~/opencti-client
docker:
- image: cimg/python:3.12
Expand Down Expand Up @@ -144,26 +196,35 @@ workflows:
filters:
tags:
only: /.*/
- build:
- build-container-python-3-11:
requires:
- build-library
filters:
tags:
only: /[0-9]+(\.[0-9]+)+(\.[0-9]+)?\.?(\w)*/
- build-container-python-3-12:
requires:
- build-library
filters:
tags:
only: /[0-9]+(\.[0-9]+)+(\.[0-9]+)?\.?(\w)*/
- build-library:
filters:
tags:
only: /[0-9]+(\.[0-9]+)+(\.[0-9]+)?\.?(\w)*/
branches:
ignore: /.*/
requires:
- ensure_formatting
- linter
- deploy:
requires:
- build
- build-library
filters:
tags:
only: /[0-9]+(\.[0-9]+)+(\.[0-9]+)?\.?(\w)*/
branches:
ignore: /.*/
- notify_rolling:
requires:
- build
- build-library
- notify:
requires:
- deploy
Expand Down
13 changes: 13 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
ARG BASE_IMAGE="python:3.12-alpine3.20"
FROM ${BASE_IMAGE}

# Install Python modules
# hadolint ignore=DL3003
COPY ./requirements.txt /opt/requirements.txt

RUN apk --no-cache add git build-base libmagic libffi-dev && \
pip3 install --no-cache-dir -r /opt/requirements.txt && \
apk del git build-base && rm /opt/requirements.txt

RUN adduser -D -g '' app
USER app