Skip to content

Commit

Permalink
BAI-1503 add modelscan build to github workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
PE39806 committed Nov 28, 2024
1 parent 56517a8 commit 137a756
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 4 deletions.
50 changes: 49 additions & 1 deletion .github/workflows/build.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,34 @@ jobs:
name: bailo_frontend
path: /tmp/bailo_frontend.tar

build_modelscan:
runs-on: ubuntu-latest
timeout-minutes: 20

steps:
# Clone repository
- uses: actions/checkout@v3

# Setup BuildX
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Build modelscan image
uses: docker/build-push-action@v3
with:
context: modelscan
file: lib/modelscan_api/Dockerfile
tags: bailo_modelscan:latest
cache-from: type=gha,scope=modelscan
cache-to: type=gha,mode=max,scope=modelscan
outputs: type=docker,dest=/tmp/bailo_modelscan.tar

- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: bailo_modelscan
path: /tmp/bailo_modelscan.tar

unit_testing:
runs-on: ubuntu-latest

Expand Down Expand Up @@ -134,6 +162,11 @@ jobs:
with:
name: bailo_frontend
path: /tmp
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: bailo_modelscan
path: /tmp

- name: Start minikube
uses: medyagh/setup-minikube@master
Expand All @@ -146,6 +179,7 @@ jobs:
eval $(minikube -p minikube docker-env)
docker load -i /tmp/bailo_backend.tar
docker load -i /tmp/bailo_frontend.tar
docker load -i /tmp/bailo_modelscan.tar
# Install dependencies
- run: npm ci
Expand Down Expand Up @@ -193,6 +227,8 @@ jobs:
frontendTag: latest
backendRepository: "bailo_backend"
backendTag: latest
modelscanRepository: "bailo_modelscan"
modelscanTag: latest
# Used for k8s not openshift
ingress:
enabled: false
Expand Down Expand Up @@ -287,14 +323,20 @@ jobs:
with:
name: bailo_frontend
path: /tmp
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: bailo_modelscan
path: /tmp

- name: Load image
run: |
docker load --input /tmp/bailo_frontend.tar
docker load --input /tmp/bailo_backend.tar
docker load --input /tmp/bailo_modelscan.tar
docker image ls -a
rm -rf /tmp/bailo_frontend.tar /tmp/bailo_backend.tar
rm -rf /tmp/bailo_frontend.tar /tmp/bailo_backend.tar /tmp/bailo_modelscan.tar
# Create logs directory
- run: mkdir logs
Expand Down Expand Up @@ -407,11 +449,17 @@ jobs:
with:
name: bailo_frontend
path: /tmp
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: bailo_modelscan
path: /tmp

- name: Load image
run: |
docker load --input /tmp/bailo_frontend.tar
docker load --input /tmp/bailo_backend.tar
docker load --input /tmp/bailo_modelscan.tar
docker image ls -a
# Create logs directory
Expand Down
2 changes: 2 additions & 0 deletions frontend/pages/docs/administration/helm/configuration.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ image:
frontendTag: 'v2.1.2'
backendRepository: '<docker registry>'
backendTag: 'v2.1.2'
modelscanRepository: '<docker registry>'
modelscanTag: 'v1.0.0'
```
To create these images, follow the instructions in [Building Bailo Images](../building-the-bailo-image).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ frontend and one for the backend.
# Bailo uses a monorepo, so images should be built from the root directory
$ docker build -t "bailo-backend" -f ./backend/Dockerfile .
$ docker build -t "bailo-frontend" -f ./frontend/Dockerfile .
$ docker build -t "bailo-modelscan" -f ./lib/modelscan_api/Dockerfile .
```

Ensure you do not use the development Dockerfiles (called `Dockerfile.dev`) as they expect the application to be mounted
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ spec:
- name: modelscanport
containerPort: 3311
protocol: TCP
image: {{ .Values.modelscan.image }}
image: "{{ .Values.image.modelscanRepository }}:{{ .Values.image.modelscanTag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
resources:
requests:
memory: "100Mi"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ spec:
- port: {{ .Values.modelscan.port }}
targetPort: {{ .Values.modelscan.port }}
protocol: TCP
name: http
name: {{ .Values.modelscan.protocol }}
selector:
name: modelscan
{{- end }}
4 changes: 3 additions & 1 deletion infrastructure/helm/bailo/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ image:
frontendTag: imageTag
backendRepository: "backend-image-registry.location"
backendTag: imageTag
modelscanRepository: "modelscan-image-registry.location"
modelscanTag: imageTag
pullPolicy: IfNotPresent
imagePullSecrets: []

Expand Down Expand Up @@ -299,7 +301,7 @@ clamav:

modelscan:
enabled: false
image: bailo-modelscan
protocol: http
port: 3311
accessModes:
- ReadWriteOnce
Expand Down
1 change: 1 addition & 0 deletions lib/modelscan_api/bailo_modelscan_api/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class Settings(BaseSettings):
Bailo ModelScan API allows for easy programmatic interfacing with ProtectAI's ModelScan package to scan and detect potential threats within files stored in Bailo.
You can upload files and view modelscan's result."""
# Update frontend/pages/docs/administration/helm/configuration.mdx if bumping this.
app_version: str = "1.0.0"
# download_dir is used if it evaluates, otherwise a temporary directory is used.
download_dir: Optional[str] = None
Expand Down

0 comments on commit 137a756

Please sign in to comment.