Skip to content
New issue

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

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

Already on GitHub? # to your account

feat: add a Dockerfile #6

Merged
Merged
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
17 changes: 17 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
FROM python:3.11 AS builder
SHELL ["/bin/bash", "-c"]
WORKDIR /app
COPY requirements.txt requirements.txt
RUN python3 -m venv .venv && source .venv/bin/activate && pip install -r requirements.txt
COPY . .
RUN source .venv/bin/activate && pip install .

FROM python:3.11 AS runner
SHELL ["/bin/bash", "-c"]
WORKDIR /app
COPY --from=builder /app/.venv /app/.venv
COPY workdir/model.json model.json
COPY workdir/data.csv data.csv
ENV VIRTUAL_ENV="/app/.venv"
ENV PATH="${VIRTUAL_ENV}/bin:${PATH}"
CMD ["python3", "-m", "fm_training_estimator.ui.cli", "--model_path", "model.json", "--lookup_data_path", "data.csv", "input.json"]
10 changes: 10 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
IMAGE ?= icr.io/ftplatform/fm_training_estimator:latest

.PHONY: build
build: lint fmt install
tox -e build
Expand Down Expand Up @@ -37,3 +39,11 @@ run-cli:
.PHONY: run-api
run-api:
python -m fm_training_estimator.ui.api ./workdir/data.csv ./workdir/model.json --use_model_features=True

.PHONY: cbuild
cbuild:
docker build -t ${IMAGE} -f Dockerfile .

.PHONY: cpush
cpush:
docker push ${IMAGE}
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,22 @@ make run-web-ui
This will start the UI on `localhost:3000` port.

(The web ui has other options, not covered in this simple setup. If you want to skip the model whitelisting or change the port, directly run the UI as shown in the README in the `./fm_training_estimator/ui` folder.)

### Container Image

To build the estimator container image:

1. Make sure both `model.json` and `data.csv` files are present in the `workdir` folder.

2. Use this command to build and push the image:

```shell
make cbuild
make cpush # If you want to push to the container registry
```

3. Use this command to run the image:

```shell
docker run --rm -it -v "/path/to/input.json:/app/input.json" icr.io/ftplatform/fm_training_estimator:latest
```