Compare commits

..
30 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
Brian Bjarke Jensen bb18ae7514 updated to check digest version of base image 2025-10-03 22:55:47 +02:00
Brian Bjarke Jensen a53a0ab1f2 added labels for traceability 2025-10-03 22:55:47 +02:00
Brian Bjarke Jensen 868404b8c0 Merge pull request 'removed "main" version when tagging and pushing image' (#1) from fix-docker-image-versions into main
Daily Update Pipeline / build-and-publish (push) Successful in 1m31s
Reviewed-on: #1
2025-09-25 15:34:57 +02:00
Brian Bjarke Jensen 1e879541df removed "main" version when tagging and pushing image 2025-09-25 14:26:57 +02:00
Brian Bjarke Jensen eb489c0263 tried direct login to docker registry
Daily Update Pipeline / build-and-publish (push) Successful in 47s
2025-09-23 15:26:41 +02:00
Brian Bjarke Jensen ac1e42916e adapted to containerized runner 2025-09-23 15:15:22 +02:00
Brian Bjarke Jensen 9917047ef1 allowed docker to use insecure registries 2025-09-23 15:12:21 +02:00
Brian Bjarke Jensen a674228652 allowed insecure locally accessed registry 2025-09-23 15:10:13 +02:00
Brian Bjarke Jensen c66a8281f7 push docker image to local repo 2025-09-23 15:06:29 +02:00
Brian Bjarke Jensen a0ed61549e disabled local caching to reduce image size 2025-09-23 15:06:18 +02:00
3 changed files with 288 additions and 17 deletions
+132 -15
View File
@@ -5,37 +5,152 @@ 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:
get-mlflow-full-base-image-digest:
if: github.event.inputs.skip_image_check != 'true'
runs-on: ubuntu-latest
outputs:
base_image_digest: ${{ steps.mlflow-full.outputs.base_image_digest }}
success: ${{ steps.mlflow-full.outputs.success }}
steps:
- name: Get MLflow-full base image digest
id: mlflow-full
env:
CI_RUNNER_TOKEN: ${{ secrets.CI_RUNNER_TOKEN }}
run: |
# 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 "success=false" >> $GITHUB_OUTPUT
echo "Failed to pull MLflow-full image - this might be the first run"
fi
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
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 "success=true" >> $GITHUB_OUTPUT
echo "Digest found for MLflow base image: $DIGEST"
else
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 [ "${{ github.event.inputs.skip_image_check }}" == "true" ]; then
echo "Image check skipped, forcing build"
echo "should_build=true" >> $GITHUB_OUTPUT
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
echo "❌ MLflow-full image not found"
echo "should_build=false" >> $GITHUB_OUTPUT
fi
build-and-publish: build-and-publish:
if: needs.decide-to-build.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
uses: actions/checkout@v4 uses: actions/checkout@v4
- name: Set up Docker Buildx - name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3 uses: docker/setup-buildx-action@v3
- name: Log in to Gitea Container Registry
uses: docker/login-action@v3
with: with:
registry: gitea.gt-proj.com config-inline: |
username: ${{ gitea.actor }} [registry."${{ secrets.DOCKER_REGISTRY }}"]
password: ${{ secrets.CI_RUNNER_TOKEN }} http = true
insecure = true
- name: Log in to Gitea Container Registry
run: |
# Configure Docker to allow insecure registry for this session
mkdir -p ~/.docker
echo '{
"auths": {},
"insecure-registries": ["${{ secrets.DOCKER_REGISTRY }}"]
}' > ~/.docker/config.json
# Login using direct docker command
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: gitea.gt-proj.com/${{ gitea.repository_owner }}/${{ gitea.event.repository.name }} images: ${{ secrets.DOCKER_REGISTRY }}/${{ gitea.repository_owner }}/${{ gitea.event.repository.name }}
tags: | tags: |
type=ref,event=branch
type=ref,event=pr
type=schedule,pattern={{date 'YYYYMMDD'}} type=schedule,pattern={{date 'YYYYMMDD'}}
type=raw,value=latest,enable={{is_default_branch}} 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 - name: Build and push Docker image
id: build-publish
uses: docker/build-push-action@v5 uses: docker/build-push-action@v5
with: with:
context: . context: .
@@ -44,8 +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
- 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: ${{ steps.meta.outputs.tags }}" echo "Image tags:"
echo "${{ steps.meta.outputs.tags }}"
echo "Image labels:"
echo "${{ steps.meta.outputs.labels }}"
+3 -1
View File
@@ -1,5 +1,7 @@
FROM ghcr.io/mlflow/mlflow:latest FROM ghcr.io/mlflow/mlflow:latest
RUN pip install psycopg2-binary # Use --no-cache-dir to avoid storing pip cache in the image
RUN pip install --no-cache-dir \
psycopg2-binary
ENTRYPOINT [ "mlflow", "server" ] ENTRYPOINT [ "mlflow", "server" ]
+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
```