Skip to content

Dockerise dependencies required to run tasks in dev workflow #51

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
102 changes: 16 additions & 86 deletions .github/workflows/mlflow-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,10 @@ jobs:
- name: Run Lint and Template
working-directory: applications/mlflow
run: |
# Use Taskfile to add Helm repos, lint charts and generate templates
task add:repos:helm
task update:deps:helm
task lint
task template
# Use Taskfile to lint charts and generate templates
task helm:update-deps
task helm:lint
task helm:template

- name: Upload rendered templates
if: failure()
Expand All @@ -73,80 +72,12 @@ jobs:
working-directory: applications/mlflow
run: |
# Ensure Chart.yaml and HelmChart versions are in sync
task check:versions
task versions:verify

helm-docs:
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Install Task
uses: arduino/setup-task@v1
with:
version: 3.x
repo-token: ${{ secrets.GITHUB_TOKEN }}

- name: Set up Helm
uses: azure/[email protected]
with:
version: v3.13.3

- name: Install helm-docs
run: |
HELM_DOCS_VERSION=v1.12.0
wget https://github.com/norwoodj/helm-docs/releases/download/${HELM_DOCS_VERSION}/helm-docs_${HELM_DOCS_VERSION#v}_Linux_x86_64.tar.gz -O - | tar -xz
sudo mv helm-docs /usr/local/bin/helm-docs
helm-docs --version

- name: Check Helm Documentation
working-directory: applications/mlflow
run: |
# Use Taskfile to check if helm docs are up to date
task add:repos:helm
task update:deps:helm
task docs:helm:check

- name: Generate Helm Documentation
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
working-directory: applications/mlflow
run: |
# Only generate documentation on main branch pushes
task docs:helm:generate

- name: Generate KOTS Manifest Guide
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
working-directory: applications/mlflow
run: |
# Generate KOTS manifest guide
task docs:kots:summary

- name: Create PR if docs changed
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
uses: peter-evans/create-pull-request@v5
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: "docs: update documentation"
title: "docs: update documentation"
body: |
This PR updates documentation:

- Updated Helm chart documentation based on the current templates
- Generated KOTS manifest guide for platform engineers

Automatically generated by the MLflow CI workflow.
branch: update-docs
base: main
labels: documentation
paths: |
applications/mlflow/charts/*/README.md
applications/mlflow/docs/KOTS_MANIFEST_GUIDE.md

create-release:
runs-on: ubuntu-22.04
needs: [lint-and-template, helm-docs]
needs: [lint-and-template]
outputs:
customer-id: ${{ steps.create-customer.outputs.customer-id }}
channel-slug: ${{ steps.create-release.outputs.channel-slug }}
Expand Down Expand Up @@ -177,10 +108,9 @@ jobs:
working-directory: applications/mlflow
run: |
# Update and package charts
task add:repos:helm
task update:deps:helm
task update:versions:chart
task package:charts
task helm:update-deps
task release:update-versions
task helm:package

# Extract MLflow chart version for reference
- name: Extract MLflow chart version
Expand All @@ -198,7 +128,7 @@ jobs:
with:
app-slug: ${{ env.APP_SLUG }}
api-token: ${{ secrets.REPLICATED_PLATFORM_EXAMPLES_TOKEN }}
yaml-dir: applications/mlflow/kots/
yaml-dir: applications/mlflow/release/
promote-channel: ci-automation-${{ github.run_id }}-${{ github.run_number }}-${{ github.run_attempt }}
version: ${{ steps.chart-version.outputs.chart_version }}

Expand Down Expand Up @@ -275,7 +205,7 @@ jobs:

# Get license ID using the task - capture only the last line of output
echo "Getting license ID..."
INSTALLATION_ID=$(CUSTOMER_NAME="$CUSTOMER_NAME" task get:license-id:customer | tail -n 1)
INSTALLATION_ID=$(CUSTOMER_NAME="$CUSTOMER_NAME" task license:get-id | tail -n 1)

# Check if we got a result
if [ -z "$INSTALLATION_ID" ]; then
Expand Down Expand Up @@ -309,7 +239,7 @@ jobs:
echo "$KUBECONFIG" > "$KUBECONFIG_FILE"

# Create namespace using taskfile
KUBECONFIG="$KUBECONFIG_FILE" task setup:namespaces
KUBECONFIG="$KUBECONFIG_FILE" task namespaces:create
env:
KUBECONFIG: ${{ steps.create-cluster.outputs.cluster-kubeconfig }}

Expand All @@ -321,7 +251,7 @@ jobs:
echo "$KUBECONFIG" > "$KUBECONFIG_FILE"

# Run task to test Helm installation
KUBECONFIG="$KUBECONFIG_FILE" MLFLOW_VALUES="${{ matrix.config.values_file }}" task test:install:helm
KUBECONFIG="$KUBECONFIG_FILE" MLFLOW_VALUES="${{ matrix.config.values_file }}" task helm:test-install
env:
KUBECONFIG: ${{ steps.create-cluster.outputs.cluster-kubeconfig }}
REPLICATED_APP: ${{ env.APP_SLUG }}
Expand All @@ -345,7 +275,7 @@ jobs:
python -m pip install mlflow numpy pandas scikit-learn pytest requests

# Run tests
task run:tests:app
task test:app
env:
KUBECONFIG: ${{ steps.create-cluster.outputs.cluster-kubeconfig }}
PORT: 5000
Expand Down Expand Up @@ -441,7 +371,7 @@ jobs:
# Try to download license
echo "Attempting to download license..."
set +e
CUSTOMER_NAME="$CUSTOMER_NAME" task download:license:customer
CUSTOMER_NAME="$CUSTOMER_NAME" task license:download
DOWNLOAD_RESULT=$?
set -e

Expand Down Expand Up @@ -616,7 +546,7 @@ jobs:
python -m pip install mlflow numpy pandas scikit-learn pytest requests

# Run tests
task run:tests:app
task test:app
env:
KUBECONFIG: ${{ steps.create-cluster.outputs.cluster-kubeconfig }}
PORT: 5000
Expand Down
29 changes: 29 additions & 0 deletions applications/mlflow/.docker/bashrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# MLflow development container .bashrc

# Set important environment variables
export SHELL=/bin/bash
export HOME=/home/devuser

# Ensure clean exit
trap 'exit 0' EXIT

# Custom prompt
export PS1="\[\033[01;32m\]mlflow-dev\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]$ "

# Useful aliases
alias k="kubectl"
alias kgp="kubectl get pods"
alias kgs="kubectl get services"
alias kgc="kubectl get configmaps"

# Define a clean exit function
clean_exit() {
echo "Exiting development shell..."
exit 0
}

# Override the exit command to ensure it always exits cleanly
alias exit="clean_exit"

# Welcome message
echo "Type 'task --list' to see available tasks"
61 changes: 61 additions & 0 deletions applications/mlflow/.docker/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#!/bin/bash
set -e

# Set essential environment variables
export SHELL=/bin/bash
export HOME=${HOME:-/home/devuser}
export USER=${USER:-devuser}

# Trap to ensure clean exit
trap 'exit 0' EXIT

# Basic initialization
echo "Initializing development environment..."

# Check for kube config and warn if none found
if [ ! -f ~/.kube/config ]; then
echo "Warning: No Kubernetes config file found."
echo "Ensure ~/.kube/config is mounted from host."
else
echo "Found Kubernetes config. Using existing configuration."
fi

# Check for Helm config and warn if not found
if [ ! -d ~/.config/helm ]; then
echo "Warning: No Helm configuration found. If you need Helm repos, please ensure ~/.config/helm is mounted."
fi

# Network mode information
NETWORK_MODE="Container network"
if [ "${HOST_NETWORK:-false}" = "true" ]; then
NETWORK_MODE="Host network (ports opened in container are accessible on host)"
fi

# Print welcome message
cat << EOF
======================================================
MLflow Development Environment
------------------------------------------------------
- All required tools are pre-installed:
* task, helm, kubectl, yq, jq, etc.
- Use 'task --list' to see available tasks
- Directories from host are mounted in /workspace

Kubernetes Setup:
- Using host's Kubernetes config

Networking:
- ${NETWORK_MODE}
======================================================
EOF

# Print environment debug information
echo "Environment:"
echo "- SHELL: $SHELL"
echo "- HOME: $HOME"
echo "- USER: $USER"
echo "- PATH: $PATH"
echo ""

# Run the command
exec "$@"
Loading
Loading