diff --git a/dockerfile b/dockerfile new file mode 100644 index 000000000..633a212ce --- /dev/null +++ b/dockerfile @@ -0,0 +1,16 @@ +# Use an official Python runtime as a parent image +FROM python:3.11-slim + +# Set the working directory in the container +WORKDIR /pdl + +# Copy the current directory contents into the container at /app +COPY . /pdl + +# Install any needed dependencies specified in requirements.txt +RUN pip install . +RUN pip install '.[all]' + + +# Run app.py when the container launches +ENTRYPOINT ["pdl-local"] \ No newline at end of file diff --git a/pdl/pdl_runner.py b/pdl/pdl_runner.py new file mode 100644 index 000000000..b0baf7a42 --- /dev/null +++ b/pdl/pdl_runner.py @@ -0,0 +1,36 @@ +import os +import subprocess +import sys + +WATSONX_APIKEY = "WATSONX_APIKEY=" + os.environ["WATSONX_APIKEY"] +WATSONX_URL = "WATSONX_URL=" + os.environ["WATSONX_URL"] +WATSONX_PROJECT_ID = "WATSONX_PROJECT_ID=" + os.environ["WATSONX_PROJECT_ID"] +LOCAL_DIR = os.getcwd() + ":/local" + + +def main(): + subprocess.run( + [ + "docker", + "run", + "-v", + LOCAL_DIR, + "-w", + "/local", + "-e", + WATSONX_APIKEY, + "-e", + WATSONX_URL, + "-e", + WATSONX_PROJECT_ID, + "--rm", + "-it", + "pdl-runner", + *sys.argv[1:], + ], + check=True, + ) + + +if __name__ == "__main__": + main() diff --git a/pyproject.toml b/pyproject.toml index 398fe54b8..9c185c268 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -60,4 +60,5 @@ Repository = "https://github.com/IBM/prompt-declaration-language" Issues = "https://github.com/IBM/prompt-declaration-language/issues" [project.scripts] -pdl = "pdl.pdl:main" \ No newline at end of file +pdl-local = "pdl.pdl:main" +pdl = "pdl.pdl_runner:main" \ No newline at end of file