Compare commits

..
15 Commits
Author SHA1 Message Date
brian 09d1e52298 Merge pull request 'Update CI to work with new network architecture' (#3) from update-CI-to-new-network-architecture into main
Reviewed-on: #3
2026-01-13 13:24:02 +01:00
Brian Bjarke Jensen a1c5e7c3a3 changed to use secret for docker registry 2026-01-13 13:22:05 +01:00
Brian Bjarke Jensen 07b5c11f43 improved readme
Daily Update Pipeline / get-mlflow-full-base-image-digest (push) Failing after 17s
Daily Update Pipeline / get-mlflow-digest (push) Successful in 8s
Daily Update Pipeline / decide-to-build (push) Successful in 1s
Daily Update Pipeline / build-and-publish (push) Has been skipped
2025-10-04 21:33:40 +02:00
Brian Bjarke Jensen 244692118b corrected ci step references 2025-10-04 21:28:08 +02:00
Brian Bjarke Jensen b235d05df3 updated to docker pull inspect approach 2025-10-04 21:23:36 +02:00
Brian Bjarke Jensen a8548c6dd9 fixed step references and added label setting 2025-10-04 19:56:45 +02:00
Brian Bjarke Jensen a0d13c61a7 simplified Dockerfile by moving labels to CI 2025-10-04 19:56:23 +02:00
Brian Bjarke Jensen 00d46837ae added printint of labels and check for should build
Daily Update Pipeline / decide-to-build (push) Successful in 5s
Daily Update Pipeline / build-and-publish (push) Has been skipped
Daily Update Pipeline / get-mlflow-full-base-image-digest (push) Failing after 50s
Daily Update Pipeline / get-mlflow-digest (push) Successful in 10s
2025-10-04 00:14:27 +02:00
Brian Bjarke Jensen e8b858b5a4 fixed variable reference 2025-10-04 00:10:45 +02:00
Brian Bjarke Jensen 99522eb651 fixed variable reference 2025-10-04 00:08:53 +02:00
Brian Bjarke Jensen 1ee95b9fd6 added option to skip base image check 2025-10-04 00:06:40 +02:00
Brian Bjarke Jensen d83df74763 added step to get registry token 2025-10-03 23:47:00 +02:00
Brian Bjarke Jensen 0c8ea42b74 added ci runner token to env 2025-10-03 23:42:44 +02:00
Brian Bjarke Jensen dffb9d8af1 corrected endpoint and added auth 2025-10-03 23:40:01 +02:00
Brian Bjarke Jensen 8fb8d80d94 updated workflow to check for base image digest of mlflow-full 2025-10-03 23:35:32 +02:00
3 changed files with 243 additions and 40 deletions
+90 -35
View File
@@ -5,54 +5,100 @@ on:
# Runs every day at 3:00 AM UTC # Runs every day at 3:00 AM UTC
- cron: '0 3 * * *' - cron: '0 3 * * *'
workflow_dispatch: # Allows manual triggering workflow_dispatch: # Allows manual triggering
inputs:
skip_image_check:
description: 'Skip image check and force build'
required: false
default: 'false'
type: choice
options:
- 'true'
- 'false'
jobs: jobs:
check-images: get-mlflow-full-base-image-digest:
if: github.event.inputs.skip_image_check != 'true'
runs-on: ubuntu-latest runs-on: ubuntu-latest
outputs: outputs:
base_image_digest: ${{ steps.mlflow-base.outputs.base_image_digest }} base_image_digest: ${{ steps.mlflow-full.outputs.base_image_digest }}
should_build: ${{ steps.decision.outputs.should_build }} success: ${{ steps.mlflow-full.outputs.success }}
steps: steps:
- name: Log in to Gitea Container Registry - name: Get MLflow-full base image digest
run: |
mkdir -p ~/.docker
echo '{"insecure-registries": ["10.0.0.2:3000"]}' > ~/.docker/config.json
echo "${{ secrets.CI_RUNNER_TOKEN }}" | docker login 10.0.0.2:3000 --username "${{ gitea.actor }}" --password-stdin
- name: Check MLflow-full image
id: mlflow-full id: mlflow-full
env:
CI_RUNNER_TOKEN: ${{ secrets.CI_RUNNER_TOKEN }}
run: | run: |
MANIFEST=$(docker manifest inspect "gitea.gt-proj.com/brian/mlflow-full:latest" 2>/dev/null || echo "{}") # Configure Docker for insecure registry
if [ "$MANIFEST" != "{}" ]; then mkdir -p ~/.docker
DIGEST=$(echo "$MANIFEST" | jq -r '.manifests[]? | select(.platform.architecture == "amd64" and .platform.os == "linux") | .digest // empty') echo '{
echo "digest=$DIGEST" >> $GITHUB_OUTPUT "auths": {},
echo "manifest_found=true" >> $GITHUB_OUTPUT "insecure-registries": ["${{ secrets.DOCKER_REGISTRY }}"]
echo "Manifest found for MLflow-full image with digest: $DIGEST" }' > ~/.docker/config.json
# Login to internal registry
echo "${{ secrets.CI_RUNNER_TOKEN }}" | docker login ${{ secrets.DOCKER_REGISTRY }} --username "${{ gitea.actor }}" --password-stdin
# Pull and inspect the image
if docker pull ${{ secrets.DOCKER_REGISTRY }}/brian/mlflow-full:latest 2>/dev/null; then
BASE_IMAGE_DIGEST=$(docker inspect ${{ secrets.DOCKER_REGISTRY }}/brian/mlflow-full:latest | jq -r '.[0].Config.Labels["org.opencontainers.image.base.digest"] // empty')
if [ -n "$BASE_IMAGE_DIGEST" ] && [ "$BASE_IMAGE_DIGEST" != "null" ]; then
echo "base_image_digest=$BASE_IMAGE_DIGEST" >> $GITHUB_OUTPUT
echo "success=true" >> $GITHUB_OUTPUT
echo "Base image digest from MLflow-full image: $BASE_IMAGE_DIGEST"
else
echo "success=false" >> $GITHUB_OUTPUT
echo "No base image digest label found"
fi
else else
echo "manifest_found=false" >> $GITHUB_OUTPUT echo "success=false" >> $GITHUB_OUTPUT
echo "MLflow-full image not found" echo "Failed to pull MLflow-full image - this might be the first run"
fi fi
- name: Check MLflow base image get-mlflow-digest:
runs-on: ubuntu-latest
outputs:
digest: ${{ steps.mlflow-base.outputs.digest }}
success: ${{ steps.mlflow-base.outputs.success }}
steps:
- name: Get MLflow base image digest
id: mlflow-base id: mlflow-base
if: steps.mlflow-full.outputs.manifest_found == 'true'
run: | run: |
MANIFEST=$(docker manifest inspect ghcr.io/mlflow/mlflow:latest 2>/dev/null || echo "{}") MANIFEST=$(docker manifest inspect ghcr.io/mlflow/mlflow:latest 2>/dev/null || echo "{}")
if [ "$MANIFEST" != "{}" ]; then if [ "$MANIFEST" != "{}" ]; then
DIGEST=$(echo "$MANIFEST" | jq -r '.manifests[]? | select(.platform.architecture == "amd64" and .platform.os == "linux") | .digest // empty') DIGEST=$(echo "$MANIFEST" | jq -r '.manifests[]? | select(.platform.architecture == "amd64" and .platform.os == "linux") | .digest // empty')
echo "digest=$DIGEST" >> $GITHUB_OUTPUT echo "digest=$DIGEST" >> $GITHUB_OUTPUT
echo "manifest_found=true" >> $GITHUB_OUTPUT echo "success=true" >> $GITHUB_OUTPUT
echo "Manifest found for MLflow base image with digest: $DIGEST" echo "Digest found for MLflow base image: $DIGEST"
else else
echo "manifest_found=false" >> $GITHUB_OUTPUT echo "success=false" >> $GITHUB_OUTPUT
echo "MLflow base image not found" echo "MLflow base image not found"
fi fi
decide-to-build:
if: always() # Run regardless of dependency status
needs:
- get-mlflow-full-base-image-digest
- get-mlflow-digest
runs-on: ubuntu-latest
outputs:
should_build: ${{ steps.decision.outputs.should_build }}
steps:
- name: Build decision - name: Build decision
id: decision id: decision
run: | run: |
if [ "${{ steps.mlflow-base.outputs.manifest_found }}" == "true" ] && \ if [ "${{ github.event.inputs.skip_image_check }}" == "true" ]; then
[ "${{ steps.mlflow-full.outputs.manifest_found }}" == "true" ]; then echo "Image check skipped, forcing build"
echo "✅ Both MLflow base and MLflow-full images found"
echo "should_build=true" >> $GITHUB_OUTPUT echo "should_build=true" >> $GITHUB_OUTPUT
elif [ "${{ steps.mlflow-base.outputs.manifest_found }}" != "true" ]; then elif [ "${{ needs.get-mlflow-digest.outputs.success }}" == "true" ] && \
[ "${{ needs.get-mlflow-full-base-image-digest.outputs.success }}" == "true" ]; then
echo "✅ Both MLflow base and MLflow-full images found"
if [ "${{ needs.get-mlflow-digest.outputs.digest }}" != "${{ needs.get-mlflow-full-base-image-digest.outputs.base_image_digest }}" ]; then
echo "Base image digest has changed"
echo "should_build=true" >> $GITHUB_OUTPUT
else
echo "Base image digest is unchanged"
echo "should_build=false" >> $GITHUB_OUTPUT
fi
elif [ "${{ needs.get-mlflow-base.outputs.success }}" != "true" ]; then
echo "❌ MLflow base image not found" echo "❌ MLflow base image not found"
echo "should_build=false" >> $GITHUB_OUTPUT echo "should_build=false" >> $GITHUB_OUTPUT
else else
@@ -60,8 +106,10 @@ jobs:
echo "should_build=false" >> $GITHUB_OUTPUT echo "should_build=false" >> $GITHUB_OUTPUT
fi fi
build-and-publish: build-and-publish:
needs: check-images if: needs.decide-to-build.outputs.should_build == 'true'
if: needs.check-images.outputs.should_build == 'true' needs:
- get-mlflow-digest
- decide-to-build
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout repository - name: Checkout repository
@@ -70,7 +118,7 @@ jobs:
uses: docker/setup-buildx-action@v3 uses: docker/setup-buildx-action@v3
with: with:
config-inline: | config-inline: |
[registry."10.0.0.2:3000"] [registry."${{ secrets.DOCKER_REGISTRY }}"]
http = true http = true
insecure = true insecure = true
- name: Log in to Gitea Container Registry - name: Log in to Gitea Container Registry
@@ -79,21 +127,28 @@ jobs:
mkdir -p ~/.docker mkdir -p ~/.docker
echo '{ echo '{
"auths": {}, "auths": {},
"insecure-registries": ["10.0.0.2:3000"] "insecure-registries": ["${{ secrets.DOCKER_REGISTRY }}"]
}' > ~/.docker/config.json }' > ~/.docker/config.json
# Login using direct docker command # Login using direct docker command
echo "${{ secrets.CI_RUNNER_TOKEN }}" | docker login 10.0.0.2:3000 --username "${{ gitea.actor }}" --password-stdin echo "${{ secrets.CI_RUNNER_TOKEN }}" | docker login ${{ secrets.DOCKER_REGISTRY }} --username "${{ gitea.actor }}" --password-stdin
- name: Extract metadata - name: Extract metadata
id: meta id: meta
uses: docker/metadata-action@v5 uses: docker/metadata-action@v5
with: with:
images: 10.0.0.2:3000/${{ gitea.repository_owner }}/${{ gitea.event.repository.name }} images: ${{ secrets.DOCKER_REGISTRY }}/${{ gitea.repository_owner }}/${{ gitea.event.repository.name }}
tags: | tags: |
type=schedule,pattern={{date 'YYYYMMDD'}} type=schedule,pattern={{date 'YYYYMMDD'}}
type=raw,value=latest type=raw,value=latest
labels: | labels: |
base-image.digest=${{ needs.check-images.outputs.base_image_digest }} org.opencontainers.image.title=mlflow-full
org.opencontainers.image.description=MLflow with PostgreSQL support
org.opencontainers.image.authors=Brian Jensen
org.opencontainers.image.vendor=Brian Jensen
org.opencontainers.image.licenses=Apache-2.0
org.opencontainers.image.base.name=ghcr.io/mlflow/mlflow:latest
org.opencontainers.image.base.digest=${{ needs.get-mlflow-digest.outputs.digest }}
maintainer=Brian Jensen
- name: Build and push Docker image - name: Build and push Docker image
id: build-publish id: build-publish
uses: docker/build-push-action@v5 uses: docker/build-push-action@v5
@@ -104,10 +159,10 @@ jobs:
labels: ${{ steps.meta.outputs.labels }} labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha cache-from: type=gha
cache-to: type=gha,mode=max cache-to: type=gha,mode=max
build-args: |
BASE_IMAGE_DIGEST=${{ needs.check-images.outputs.base_image_digest }}
- name: Update deployment info - name: Update deployment info
run: | run: |
echo "Docker image built and pushed successfully at $(date)" echo "Docker image built and pushed successfully at $(date)"
echo "Image tags:" echo "Image tags:"
echo "${{ steps.meta.outputs.tags }}" echo "${{ steps.meta.outputs.tags }}"
echo "Image labels:"
echo "${{ steps.meta.outputs.labels }}"
-4
View File
@@ -1,9 +1,5 @@
FROM ghcr.io/mlflow/mlflow:latest FROM ghcr.io/mlflow/mlflow:latest
# Set a labels for traceability
LABEL build-date="$(date -u +'%Y-%m-%dT%H:%M:%SZ')" \
maintainer="Brian Jensen"
# Use --no-cache-dir to avoid storing pip cache in the image # Use --no-cache-dir to avoid storing pip cache in the image
RUN pip install --no-cache-dir \ RUN pip install --no-cache-dir \
psycopg2-binary psycopg2-binary
+153 -1
View File
@@ -1,3 +1,155 @@
# mlflow-full # mlflow-full
MLFlow docker container with support for Postgres. Implements extra environment variables for convenience. MLFlow docker container with support for Postgres. Implements extra environment variables for convenience.
## Running the Container
### Basic Usage
```bash
# Run with default settings
docker run -p 5000:5000 gitea.gt-proj.com/brian/mlflow-full:latest
```
### With PostgreSQL Backend
```bash
# Using environment variables
docker run -p 5000:5000 \
-e MLFLOW_BACKEND_STORE_URI="postgresql://user:password@host:5432/mlflow" \
-e MLFLOW_DEFAULT_ARTIFACT_ROOT="s3://my-bucket/mlflow-artifacts" \
gitea.gt-proj.com/brian/mlflow-full:latest
```
### Complete Example with Docker Compose
```yaml
version: '3.8'
services:
postgres:
image: postgres:15
environment:
POSTGRES_DB: mlflow
POSTGRES_USER: mlflow
POSTGRES_PASSWORD: mlflow_password
volumes:
- postgres_data:/var/lib/postgresql/data
ports:
- "5432:5432"
mlflow:
image: gitea.gt-proj.com/brian/mlflow-full:latest
ports:
- "5000:5000"
environment:
MLFLOW_BACKEND_STORE_URI: postgresql://mlflow:mlflow_password@postgres:5432/mlflow
MLFLOW_DEFAULT_ARTIFACT_ROOT: /mlflow/artifacts
MLFLOW_HOST: 0.0.0.0
MLFLOW_PORT: 5000
volumes:
- mlflow_artifacts:/mlflow/artifacts
depends_on:
- postgres
volumes:
postgres_data:
mlflow_artifacts:
```
### Environment Variables
| Variable | Description | Default |
|----------|-------------|---------|
| `MLFLOW_BACKEND_STORE_URI` | Database connection string | `sqlite:///mlflow.db` |
| `MLFLOW_DEFAULT_ARTIFACT_ROOT` | Artifact storage location | `./mlruns` |
| `MLFLOW_HOST` | Host to bind the server | `0.0.0.0` |
| `MLFLOW_PORT` | Port to bind the server | `5000` |
### Advanced Examples
#### With S3 Artifact Storage
```bash
docker run -p 5000:5000 \
-e MLFLOW_BACKEND_STORE_URI="postgresql://user:password@host:5432/mlflow" \
-e MLFLOW_DEFAULT_ARTIFACT_ROOT="s3://my-mlflow-bucket/artifacts" \
-e AWS_ACCESS_KEY_ID="your-access-key" \
-e AWS_SECRET_ACCESS_KEY="your-secret-key" \
-e AWS_DEFAULT_REGION="us-west-2" \
gitea.gt-proj.com/brian/mlflow-full:latest
```
#### With Custom Server Arguments
```bash
docker run -p 5000:5000 \
-e MLFLOW_BACKEND_STORE_URI="postgresql://user:password@host:5432/mlflow" \
gitea.gt-proj.com/brian/mlflow-full:latest \
--host 0.0.0.0 \
--port 5000 \
--workers 4 \
--expose-prometheus /metrics
```
### Kubernetes Deployment
```yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: mlflow-server
spec:
replicas: 1
selector:
matchLabels:
app: mlflow-server
template:
metadata:
labels:
app: mlflow-server
spec:
containers:
- name: mlflow-server
image: gitea.gt-proj.com/brian/mlflow-full:latest
ports:
- containerPort: 5000
env:
- name: MLFLOW_BACKEND_STORE_URI
value: "postgresql://mlflow:password@postgres-service:5432/mlflow"
- name: MLFLOW_DEFAULT_ARTIFACT_ROOT
value: "s3://mlflow-artifacts"
---
apiVersion: v1
kind: Service
metadata:
name: mlflow-service
spec:
selector:
app: mlflow-server
ports:
- port: 5000
targetPort: 5000
type: LoadBalancer
```
## Features
- 🐘 **PostgreSQL Support**: Pre-installed `psycopg2-binary` for PostgreSQL connectivity
- 🏷️ **OCI Labels**: Fully compliant with OCI image specification
- 🔄 **Auto-updates**: Daily builds when the base MLflow image is updated
- 📦 **Lightweight**: Based on official MLflow container
## Building Locally
```bash
# Clone the repository
git clone https://gitea.gt-proj.com/brian/mlflow-full.git
cd mlflow-full
# Build the image
docker build -t mlflow-full:local .
# Run your local build
docker run -p 5000:5000 mlflow-full:local
```