Skip to content

Commit

Permalink
Add --requirements option to stort service dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonLarsen committed Feb 6, 2024
1 parent d507b8b commit bedc6fe
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
13 changes: 13 additions & 0 deletions stort/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,16 @@ def serve(checkpoints: Sequence[Tuple[str, Path]], device: str):
),
metavar="NAME PATH",
)
@click.option(
"--requirements",
"-r",
type=click.Path(
exists=True, file_okay=True, dir_okay=False, path_type=Path
),
default="requirements.txt",
help="Path to service requirements.txt. Defaults to requirements.txt.",
metavar="PATH",
)
@click.option(
"--out",
"-o",
Expand All @@ -232,8 +242,10 @@ def serve(checkpoints: Sequence[Tuple[str, Path]], device: str):
)
def service_dockerfile(
checkpoints: Sequence[Tuple[str, Path]],
requirements: Path,
out: Optional[Path] = None,
):
"""Build service Dockerfile."""
from jinja2 import Environment, PackageLoader

env = Environment(
Expand All @@ -257,6 +269,7 @@ def service_dockerfile(
env_checkpoints = {e["name"]: str(e["model_path"]) for e in ckpt_info}
output = template.render(
checkpoints=ckpt_info,
requirements=str(requirements),
env_checkpoints=json.dumps(env_checkpoints),
)

Expand Down
2 changes: 1 addition & 1 deletion stort/data/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ WORKDIR /app
RUN apt-get update && apt-get install -y git

COPY service.py ./
COPY requirements.txt ./
COPY {{ requirements }} ./requirements.txt
COPY models/* ./models/

RUN pip install -r requirements.txt
Expand Down

0 comments on commit bedc6fe

Please sign in to comment.