Compare commits
30
Commits
083245793a
..
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
09d1e52298 | ||
|
|
a1c5e7c3a3 | ||
|
|
07b5c11f43 | ||
|
|
244692118b | ||
|
|
b235d05df3 | ||
|
|
a8548c6dd9 | ||
|
|
a0d13c61a7 | ||
|
|
00d46837ae | ||
|
|
e8b858b5a4 | ||
|
|
99522eb651 | ||
|
|
1ee95b9fd6 | ||
|
|
d83df74763 | ||
|
|
0c8ea42b74 | ||
|
|
dffb9d8af1 | ||
|
|
8fb8d80d94 | ||
|
|
cd55d0f60b | ||
|
|
cb41fabd09 | ||
|
|
7d562f6851 | ||
|
|
666a2ebf7e | ||
|
|
f9c58dcd6d | ||
|
|
bb18ae7514 | ||
|
|
a53a0ab1f2 | ||
|
|
868404b8c0 | ||
|
|
1e879541df | ||
|
|
eb489c0263 | ||
|
|
ac1e42916e | ||
|
|
9917047ef1 | ||
|
|
a674228652 | ||
|
|
c66a8281f7 | ||
|
|
a0ed61549e |
+132
-15
@@ -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
@@ -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" ]
|
||||||
|
|||||||
@@ -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
|
||||||
|
```
|
||||||
|
|||||||
Reference in New Issue
Block a user