Search code examples
dockerdockerfilemlflowpython-poetry

COPY files - next to Dockerfile - don't work and block docker build


I'm trying to building a docker container with mlflow server inside, with poetry toml file for dependency.(the two toml are exactly the same, it was just a way to try to figure out)
tree:

├── docker-entrypoint.sh
├── Dockerfile
├── files
│ └── pyproject.toml
├── git.sh
├── pyproject.toml
└── README.md

as you can see, my toml file is next to Dockerfile COPY pyproject.toml ./ don't work nevertheless

Dockerfile

FROM python:3.6.10-alpine3.10 as base
LABEL maintainer=""

ENV PYTHONFAULTHANDLER 1 
ENV    PYTHONHASHSEED random 
ENV    PYTHONUNBUFFERED 1

ENV MLFLOW_HOME ./ 
ENV SERVER_PORT 5000   
ENV    MLFLOW_VERSION 0.7.0 
ENV    SERVER_HOST 0.0.0.0  
ENV    FILE_STORE ${MLFLOW_HOME}/fileStore  
ENV    ARTIFACT_STORE ${MLFLOW_HOME}/artifactStore 
ENV PIP_DEFAULT_TIMEOUT 100
ENV    PIP_DISABLE_PIP_VERSION_CHECK on
ENV    PIP_NO_CACHE_DIR  off 
ENV    POETRY_VERSION  1.0.0 

WORKDIR ${MLFLOW_HOME}

FROM base as builder

RUN apk update  \
    && apk add --no-cache make gcc musl-dev python3-dev libffi-dev openssl-dev subversion
#download project file from github  repo 
RUN    svn export https://github.com/MChrys/QuickSign/trunk/  \
    && pip install poetry==${POETRY_VERSION} \
    && mkdir -p ${FILE_STORE}  \
    && mkdir -p ${ARTIFACT_STORE}\
    && python -m venv /venv

COPY  pyproject.toml ./
RUN poetry export -f requirements.txt | /venv/bin/pip install -r  --allow-root-install /dev/stdin 

COPY . .
RUN poetry build && /venv/bin/pip install dist/*.whl

FROM base as final

RUN apk add --no-cache libffi libpq
COPY --from=builder /venv /venv
COPY docker-entrypoint.sh ./

EXPOSE $SERVER_PORT

VOLUME ["${FILE_STORE}", "${ARTIFACT_STORE}"]

CMD ["./docker-entrypoint.sh"]

the build command :

docker build - < Dockerfile

I get this error :

Step 21/32 : COPY  pyproject.toml ./
COPY failed: stat /var/lib/docker/tmp/docker-builder335195979/pyproject.toml: no such file or   directory

pyproject.toml

requires = ["poetry>=1.0.0", "mlflow>=0.7.0", "python>=3.6"]
build-backend = "poetry.masonry.api"

[tool.poetry]
name = "Sign"
description = ""
version = "1.0.0"
readme = "README.md"
authors = [
  ""
]

license = "MIT"


[tool.poetry.dependencies]
python = "3.6"
numpy = "1.14.3"
scipy = "*"
pandas = "0.22.0"
scikit-learn = "0.19.1"
cloudpickle = "*"
mlflow ="0.7.0"
tensorflow = "^2.0.0"


[tool.poetry.dev-dependencies]

pylint = "*"
docker-compose = "^1.25.0"
docker-image-size-limit = "^0.2.0"
tomlkit = "^0.5.8"

docker-entrypoint.sh

#!/bin/sh

set -e

. /venv/bin/activate

mlflow server \
    --file-store $FILE_STORE \
    --default-artifact-root $ARTIFACT_STORE \
    --host $SERVER_HOST \
    --port $SERVER_PORT


if i add RUN pwd; ls just befor the first COPY I obtain :

Step 20/31 : RUN pwd; ls
 ---> Running in e8ec36dd6ca8
/
artifactStore
bin
dev
etc
fileStore
home
lib
media
mnt
opt
proc
root
run
sbin
srv
sys
tmp
trunk
usr
var
venv
Removing intermediate container e8ec36dd6ca8
 ---> d7bba641bd7c
Step 21/31 : COPY  pyproject.toml ./
COPY failed: stat /var/lib/docker/tmp/docker-builder392824737/pyproject.toml: no such file or directory


Solution

  • Try docker build -t test .

    instead of docker build - < Dockerfile