Compare commits

..
20 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
Brian Bjarke Jensen cd55d0f60b moved adding label about base image digest to CI steps 2025-10-03 23:07:32 +02:00
Brian Bjarke Jensen cb41fabd09 removed unreachable step 2025-10-03 23:04:08 +02:00
Brian Bjarke Jensen 7d562f6851 corrected step output reference 2025-10-03 23:00:51 +02:00
Brian Bjarke Jensen 666a2ebf7e fixed repo reference 2025-10-03 23:00:06 +02:00
Brian Bjarke Jensen f9c58dcd6d extended logging 2025-10-03 22:58:01 +02:00
3 changed files with 245 additions and 44 deletions
+92 -37
View File
@@ -5,50 +5,100 @@ on:
# Runs every day at 3:00 AM UTC
- cron: '0 3 * * *'
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:
check-images:
get-mlflow-full-base-image-digest:
if: github.event.inputs.skip_image_check != 'true'
runs-on: ubuntu-latest
outputs:
base_image_digest: ${{ steps.mlflow-base.outputs.base_image_digest }}
should_build: ${{ steps.decision.outputs.should_build }}
base_image_digest: ${{ steps.mlflow-full.outputs.base_image_digest }}
success: ${{ steps.mlflow-full.outputs.success }}
steps:
- name: Log in to Gitea Container Registry
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
- name: Get MLflow-full base image digest
id: mlflow-full
env:
CI_RUNNER_TOKEN: ${{ secrets.CI_RUNNER_TOKEN }}
run: |
MANIFEST=$(docker manifest inspect "10.0.0.2:3000/brian/mlflow-full:latest" 2>/dev/null || echo "{}")
if [ "$MANIFEST" != "{}" ]; then
DIGEST=$(echo "$MANIFEST" | jq -r '.manifests[]? | select(.platform.architecture == "amd64" and .platform.os == "linux") | .digest // empty')
echo "digest=$DIGEST" >> $GITHUB_OUTPUT
echo "manifest_found=true" >> $GITHUB_OUTPUT
# Configure Docker for insecure registry
mkdir -p ~/.docker
echo '{
"auths": {},
"insecure-registries": ["${{ secrets.DOCKER_REGISTRY }}"]
}' > ~/.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
echo "manifest_found=false" >> $GITHUB_OUTPUT
echo "success=false" >> $GITHUB_OUTPUT
echo "Failed to pull MLflow-full image - this might be the first run"
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
if: steps.mlflow-full.outputs.found == 'true'
run: |
MANIFEST=$(docker manifest inspect ghcr.io/mlflow/mlflow:latest 2>/dev/null || echo "{}")
if [ "$MANIFEST" != "{}" ]; then
DIGEST=$(echo "$MANIFEST" | jq -r '.manifests[]? | select(.platform.architecture == "amd64" and .platform.os == "linux") | .digest // empty')
echo "digest=$DIGEST" >> $GITHUB_OUTPUT
echo "manifest_found=true" >> $GITHUB_OUTPUT
echo "success=true" >> $GITHUB_OUTPUT
echo "Digest found for MLflow base image: $DIGEST"
else
echo "manifest_found=false" >> $GITHUB_OUTPUT
echo "success=false" >> $GITHUB_OUTPUT
echo "MLflow base image not found"
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
id: decision
run: |
if [ "${{ steps.mlflow-base.outputs.manifest_found }}" == "true" ] && \
[ "${{ steps.mlflow-full.outputs.manifest_found }}" == "true" ]; then
echo "✅ Both MLflow base and MLflow-full images found"
if [ "${{ github.event.inputs.skip_image_check }}" == "true" ]; then
echo "Image check skipped, forcing build"
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 "should_build=false" >> $GITHUB_OUTPUT
else
@@ -56,22 +106,19 @@ jobs:
echo "should_build=false" >> $GITHUB_OUTPUT
fi
build-and-publish:
needs: check-images
if: needs.check-images.outputs.should_build == 'true'
if: needs.decide-to-build.outputs.should_build == 'true'
needs:
- get-mlflow-digest
- decide-to-build
runs-on: ubuntu-latest
steps:
- name: Build skipped
if: steps.build_decision.outputs.should_build == 'false'
run: |
echo "Build skipped: ${{ steps.build_decision.outputs.reason }}"
exit 1
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
config-inline: |
[registry."10.0.0.2:3000"]
[registry."${{ secrets.DOCKER_REGISTRY }}"]
http = true
insecure = true
- name: Log in to Gitea Container Registry
@@ -80,19 +127,28 @@ jobs:
mkdir -p ~/.docker
echo '{
"auths": {},
"insecure-registries": ["10.0.0.2:3000"]
"insecure-registries": ["${{ secrets.DOCKER_REGISTRY }}"]
}' > ~/.docker/config.json
# 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
id: meta
uses: docker/metadata-action@v5
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: |
type=schedule,pattern={{date 'YYYYMMDD'}}
type=raw,value=latest
labels: |
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
id: build-publish
uses: docker/build-push-action@v5
@@ -103,11 +159,10 @@ jobs:
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: |
BASE_IMAGE_DIGEST=${{ needs.check-images.outputs.base_image_digest }}
- name: Update deployment info
if: steps.build-publish.outputs.success == 'true'
run: |
echo "Docker image built and pushed successfully at $(date)"
echo "Image tags:"
echo "${{ steps.meta.outputs.tags }}"
echo "Image labels:"
echo "${{ steps.meta.outputs.labels }}"
-6
View File
@@ -1,10 +1,4 @@
FROM ghcr.io/mlflow/mlflow:latest
ARG BASE_IMAGE_DIGEST=unknown
# Set a label with the base image digest for traceability
LABEL base-image.digest="${BASE_IMAGE_DIGEST}" \
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
RUN pip install --no-cache-dir \
+152
View File
@@ -1,3 +1,155 @@
# mlflow-full
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
```