Ameya Bhave
Ameya Bhave

Reputation: 107

Install poetry in environments in Azure ML

I am creating an environment which has poetry installed, in Azure ML. I am totally new to docker and don't understand venv much either.

Below is the code I have written in the docker file:

FROM mcr.microsoft.com/azureml/openmpi4.1.0-ubuntu20.04
RUN pip install azureml-mlflow
FROM python:3.11-alpine as base

ARG DEV=false
ENV VIRTUAL_ENV=/app/.venv \
    PATH="/app/.venv/bin:$PATH"

RUN apk update && \
    apk add libpq


FROM base as builder

ENV POETRY_NO_INTERACTION=1 \
    POETRY_VIRTUALENVS_IN_PROJECT=1 \
    POETRY_VIRTUALENVS_CREATE=1 \
    POETRY_CACHE_DIR=/tmp/poetry_cache

RUN apk update && \
    apk add musl-dev build-base gcc gfortran openblas-dev

WORKDIR /app

# Install Poetry
RUN pip install poetry==1.6.1

# Install the app
COPY pyproject.toml poetry.lock ./
RUN if [ $DEV ]; then \
      poetry install --with dev --no-root && rm -rf $POETRY_CACHE_DIR; \
    else \
      poetry install --without dev --no-root && rm -rf $POETRY_CACHE_DIR; \
    fi


FROM base as runtime

COPY --from=builder ${VIRTUAL_ENV} ${VIRTUAL_ENV}

COPY src ./src

WORKDIR /app/src

ENTRYPOINT ["python", "-m", "app.main"]

I got an error saying this:

2024-12-05T21:11:06: COPY failed: file not found in build context or excluded by .dockerignore: stat pyproject.toml: file does not exist

What am I doing wrong here? I have not uploaded anything into any folders on Azure ML

Please help

Upvotes: 0

Views: 96

Answers (1)

JayashankarGS
JayashankarGS

Reputation: 7985

You add your pyproject.toml, poetry.lock into your docker context folder.

enter image description here

Above is where you can upload or create new environment giving the folder.

Here, in my case i given folder consists of Dockerfile and requirements.txt similarly your folder should contain below files and folder.

pyproject.toml,poetry.lock and src

Upvotes: 1

Related Questions