Skip to content

Commit 391faf7

Browse files
committed
feat: add MLflow deployment configuration for Fly.io with Docker setup
1 parent 8a65af6 commit 391faf7

File tree

2 files changed

+49
-0
lines changed

2 files changed

+49
-0
lines changed

infra/mlflow/Dockerfile

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Use uma imagem Python leve
2+
FROM python:3.9-slim
3+
4+
# Instale o mlflow
5+
RUN pip install --no-cache-dir mlflow gunicorn
6+
7+
# Crie o diretório onde os dados do volume serão montados
8+
RUN mkdir /mlflow-data
9+
10+
# Exponha a porta padrão do mlflow
11+
EXPOSE 5000
12+
13+
# Garanta que o Gunicorn faça bind corretamente para o proxy do Fly
14+
ENV GUNICORN_CMD_ARGS="--bind 0.0.0.0:5000 --workers 2 --timeout 180"
15+
16+
# Comando para iniciar o servidor mlflow
17+
CMD ["mlflow", "server", "--host", "0.0.0.0", "--port", "5000", "--backend-store-uri", "sqlite:////mlflow-data/mlflow.db", "--default-artifact-root", "/mlflow-data/artifacts"]

infra/mlflow/fly.toml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# fly.toml
2+
app = "spamguard-mlflow"
3+
primary_region = "iad"
4+
5+
[build]
6+
dockerfile = "Dockerfile"
7+
8+
[vm]
9+
cpu_kind = "shared"
10+
cpus = 1
11+
memory_mb = 1024
12+
13+
[mounts]
14+
source="mlflow_data"
15+
destination="/mlflow-data"
16+
17+
# A configuração de serviços abaixo garante uma única máquina que pode ser suspensa.
18+
[[services]]
19+
internal_port = 5000
20+
protocol = "tcp"
21+
22+
# Estas linhas garantem que a máquina desligue quando ociosa e ligue ao receber uma solicitação.
23+
auto_stop_machines = true
24+
auto_start_machines = true
25+
26+
[[services.ports]]
27+
handlers = ["http"]
28+
port = 80
29+
30+
[[services.ports]]
31+
handlers = ["tls", "http"]
32+
port = 443

0 commit comments

Comments
 (0)