Skip to content
Open
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
15 changes: 15 additions & 0 deletions .env.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# connection settings
DOMAIN_NAME=localhost
SERVICE_NAME=mlflow
SERVICE_PORT=5000
# tell the user where they are logging into
REALM=testsite
# required for letsencrypt certificate email updates
EMAIL_ADDRESS=

# database settings
POSTGRES_USER=
POSTGRES_PASSWORD=
POSTGRES_HOST=
POSTGRES_PORT=
POSTGRES_DB=
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -131,3 +131,5 @@ dmypy.json

# Pyre type checker
.pyre/
.history/
.devcontainer/
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# MLflow Production Docker
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

git issues

# traefik-basic-auth

Traefik in Docker with HTTP basic auth configured.
MLflow Production Docker

A production ready<sup>1</sup> docker-compose deployment of MLflow using Traefik with HTTP Basic Auth.

Expand Down Expand Up @@ -38,6 +41,15 @@ SERVICE_PORT=5000
REALM=testsite
# required for letsencrypt certificate email updates
EMAIL_ADDRESS=example@example.com
# Database settings
POSTGRES_USER=
POSTGRES_PASSWORD=
POSTGRES_HOST=
POSTGRES_PORT=
POSTGRES_DB=
# Mlflow settings
MLFLOW_ARTIFACT_URI=s3://bucket-name/
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not in the env sample

# If using bentoml for deployment
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

```

Finally write a `traefik.yml` config file using the `.env` variables:
Expand Down
14 changes: 14 additions & 0 deletions dockerfiles/mlflow/dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
FROM python:3.8-slim-buster

ENV PYTHONBUFFERED 1

COPY requirements.txt /
RUN pip install -r requirements.txt

COPY ./entrypoint /entrypoint
RUN sed -i 's/\r$//g' /entrypoint && chmod +x /entrypoint

COPY ./start /start
RUN sed -i 's/\r$//g' /start && chmod +x /start

ENTRYPOINT [ "/entrypoint" ]
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
ENTRYPOINT [ "/entrypoint" ]
ENTRYPOINT [ "/entrypoint" ]
CMD ["/start"]

15 changes: 15 additions & 0 deletions entrypoint
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash

set -euo pipefail

export DATABASE_URL="postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${POSTGRES_HOST}:${POSTGRES_PORT}/${POSTGRES_DB}"


until nc -z postgres:5432 > /dev/null 2>&1; do
>&2 echo 'Sleeping till postgres is ready...'
sleep 1
done
>&2 echo 'PostgreSQL is available'
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
>&2 echo 'PostgreSQL is available'
echo 'PostgreSQL is available'

this isnt an error, should go to stdout



exec "$@"
47 changes: 47 additions & 0 deletions local.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@

---
version: "3"

volumes:
traefik_acme_data: {}
local_postgres_data: {}

services:
traefik:
build:
context: .
dockerfile: ./dockerfiles/traefik/Dockerfile
image: mlflow_production_traefik
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image names clash with prod file, will cause overwrite

restart: always
volumes:
- traefik_acme_data:/etc/traefik/acme/
- ./config/.htpasswd:/etc/traefik/.htpasswd:ro
- ./config/traefik.yml:/etc/traefik/traefik.yml:ro
ports:
- "0.0.0.0:80:8080"
- "0.0.0.0:443:8443"


mlflow:
build:
context: .
dockerfile: ./dockerfiles/mlflow/Dockerfile
image: mlflow_production_server
restart: always
command: /start
ports:
- "5000:5000"
depends_on:
- postgres
env_file:
- .env

postgres:
image: postgres:11.8
restart: always
env_file:
- .env
ports:
- "5432:5432"
volumes:
- local_postgres_data:/var/lib/postgresql/data
Comment on lines +39 to +47
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is the only change over the other file, just drop in a new docker-compose-local.yml file and can run docker-compose up with both rather than copy paste

30 changes: 30 additions & 0 deletions production.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
version: "3"

volumes:
traefik_acme_data: {}

services:
traefik:
build:
context: .
dockerfile: ./dockerfiles/traefik/Dockerfile
image: mlflow_production_traefik
restart: always
volumes:
- traefik_acme_data:/etc/traefik/acme/
- ./config/.htpasswd:/etc/traefik/.htpasswd:ro
- ./config/traefik.yml:/etc/traefik/traefik.yml:ro
ports:
- "0.0.0.0:80:8080"
- "0.0.0.0:443:8443"

mlflow:
build:
context: .
dockerfile: ./dockerfiles/mlflow/Dockerfile
image: mlflow_production_server
restart: always
command: /start
env_file:
- .env
52 changes: 52 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
alembic==1.4.1
azure-core==1.8.1
azure-storage-blob==12.5.0
boto3==1.15.3
botocore==1.18.3
certifi==2020.6.20
cffi==1.14.3
chardet==3.0.4
click==7.1.2
cloudpickle==1.6.0
cryptography==3.1.1
databricks-cli==0.11.0
docker==4.3.1
entrypoints==0.3
Flask==1.1.2
gitdb==4.0.5
GitPython==3.1.8
gorilla==0.3.0
gunicorn==20.0.4
idna==2.10
isodate==0.6.0
itsdangerous==1.1.0
Jinja2==2.11.2
jmespath==0.10.0
Mako==1.1.3
MarkupSafe==1.1.1
mlflow==1.11.0
msrest==0.6.19
numpy==1.19.2
oauthlib==3.1.0
pandas==1.1.2
prometheus-client==0.8.0
prometheus-flask-exporter==0.18.0
protobuf==3.13.0
psycopg2-binary==2.8.6
pycparser==2.20
python-dateutil==2.8.1
python-editor==1.0.4
pytz==2020.1
PyYAML==5.3.1
querystring-parser==1.2.4
requests==2.24.0
requests-oauthlib==1.3.0
s3transfer==0.3.3
six==1.15.0
smmap==3.0.4
SQLAlchemy==1.3.13
sqlparse==0.3.1
tabulate==0.8.7
urllib3==1.25.10
websocket-client==0.57.0
Werkzeug==1.0.1
13 changes: 13 additions & 0 deletions start
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

set -o errexit
set -o nounset
set -o pipefail

DB_URI=postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${POSTGRES_HOST}:${POSTGRES_PORT}/${POSTGRES_DB}
mlflow db upgrade $DB_URI

mlflow server \
--backend-store-uri ${DB_URI} \
--default-artifact-root ${MLFLOW_ARTIFACT_URI} \
--host 0.0.0.0