Skip to content

Commit

Permalink
clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
aniketmaurya committed Sep 26, 2024
1 parent eef9cf9 commit d59347f
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions src/litserve/docker_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
# limitations under the License.
import logging
import os
import sys
import warnings
import litserve as ls

Expand Down Expand Up @@ -48,11 +47,14 @@ def color(text, color_code, action_code=None):


REQUIREMENTS_FILE = "requirements.txt"
DOCKERFILE_TEMPLATE = """
FROM python:3.10-slim
DOCKERFILE_TEMPLATE = """FROM python:3.10-slim
WORKDIR /app
COPY . /app
####### Put any installation commands here #######
# RUN apt-get update && apt-get install -y <package-name>
COPY . /app
# Install litserve and requirements
RUN pip install --no-cache-dir litserve=={version} {requirements}
EXPOSE {port}
CMD ["python", "/app/{server_path}"]
Expand All @@ -76,21 +78,15 @@ def build(server_path: str, port: int = 8000):
port (int, optional): The port to expose in the Docker container. Defaults to 8000.
"""
files = []
requirements = ""
if os.path.exists(REQUIREMENTS_FILE):
requirements = f"-r {REQUIREMENTS_FILE}"
files.append(REQUIREMENTS_FILE)
else:
warnings.warn(
f"requirements.txt not found at {os.getcwd()}. "
f"Make sure to install the required packages in the Dockerfile."
f"Make sure to install the required packages in the Dockerfile.",
UserWarning,
)
files.append(server_path) # TODO: Make it flexible
for file in files:
if not os.path.exists(file):
logger.error(f"File not found: {file}")
sys.exit(1)

version = ls.__version__
dockerfile_content = DOCKERFILE_TEMPLATE.format(
Expand Down

0 comments on commit d59347f

Please sign in to comment.