cog
cog copied to clipboard
COPY . /src does not seem to work when using docker run
Hello guys, I have simple python project that I build successfully with cog build. I can call "cog predict" without an error. However, it throws error saying that it does not find cog.yaml under the src folder when running with the command "docker run -d --rm -p 5000:5000 image-name". So, I mount it as a volume with "docker run -d -p 5000:5000 -v /path/to/cog.yaml:/src/cog.yaml image-name", then it creates container successfully. But this time, it does return {"detail":"Not Found"} response to curl call. I checked the inside of container and I realized that predict.py is not copied to container. I feel like "COPY . /src" is not executed as expected. You can check below result of cog debug.
#syntax=docker/dockerfile:1.4
FROM python:3.10.12 as deps
COPY .cog/tmp/build3052781866/cog-0.0.1.dev-py3-none-any.whl /tmp/cog-0.0.1.dev-py3-none-any.whl
RUN --mount=type=cache,target=/root/.cache/pip pip install -t /dep /tmp/cog-0.0.1.dev-py3-none-any.whl
COPY .cog/tmp/build3052781866/requirements.txt /tmp/requirements.txt
RUN --mount=type=cache,target=/root/.cache/pip pip install -t /dep -r /tmp/requirements.txt
FROM nvidia/cuda:11.8.0-cudnn8-devel-ubuntu22.04
ENV DEBIAN_FRONTEND=noninteractive
ENV PYTHONUNBUFFERED=1
ENV LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib/x86_64-linux-gnu:/usr/local/nvidia/lib64:/usr/local/nvidia/bin
ENV NVIDIA_DRIVER_CAPABILITIES=all
RUN --mount=type=cache,target=/var/cache/apt set -eux;
apt-get update -qq;
apt-get install -qqy --no-install-recommends curl;
rm -rf /var/lib/apt/lists/;
TINI_VERSION=v0.19.0;
TINI_ARCH="$(dpkg --print-architecture)";
curl -sSL -o /sbin/tini "https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini-${TINI_ARCH}";
chmod +x /sbin/tini
ENTRYPOINT ["/sbin/tini", "--"]
ENV PATH="/root/.pyenv/shims:/root/.pyenv/bin:$PATH"
RUN --mount=type=cache,target=/var/cache/apt apt-get update -qq && apt-get install -qqy --no-install-recommends
make
build-essential
libssl-dev
zlib1g-dev
libbz2-dev
libreadline-dev
libsqlite3-dev
wget
curl
llvm
libncurses5-dev
libncursesw5-dev
xz-utils
tk-dev
libffi-dev
liblzma-dev
git
ca-certificates
&& rm -rf /var/lib/apt/lists/
RUN curl -s -S -L https://raw.githubusercontent.com/pyenv/pyenv-installer/master/bin/pyenv-installer | bash &&
git clone https://github.com/momo-lab/pyenv-install-latest.git "$(pyenv root)"/plugins/pyenv-install-latest &&
pyenv install-latest "3.10.12" &&
pyenv global $(pyenv install-latest --print "3.10.12") &&
pip install "wheel<1"
RUN --mount=type=cache,target=/var/cache/apt apt-get update -qq && apt-get install -qqy libgl1 python3.10-venv python3-tk && rm -rf /var/lib/apt/lists/*
RUN --mount=type=bind,from=deps,source=/dep,target=/dep cp -rf /dep/* $(pyenv prefix)/lib/python*/site-packages || true
RUN git clone https://@github.com/ufukpage/something.git /something
RUN chmod +x /something/setup.sh
RUN /something/setup.sh
WORKDIR /src
EXPOSE 5000
CMD ["python", "-m", "cog.server.http"]
COPY . /src
Can you help me out? Is there a mistake I cannot find? Thank you.
Also, I mounted predict.py and it works. It is not convenient however, feels like it should run without mounting those files.
This is an older version of cog (cog-0.0.1.dev), please use the newer versions