Open mostopalove opened 1 year ago
The problem was in Dockerfile. We should run this command at the beginning of file:
RUN apt-get install pkg-config libxml2-dev libxmlsec1-dev libxmlsec1-openssl -y
This is the correct version:
FROM python:3.10 as python-base
# SET ENV #
ENV PYTHONBUFFERED=1 \
PIP_NO_CACHE_DIR="off" \
POETRY_VERSION=1.4.0 \
POETRY_HOME="/opt/poetry" \
POETRY_VIRTUALENVS_IN_PROJECT=true \
POETRY_NO_INTERACTION=1 \
PYSETUP_PATH="/app" \
VENV_PATH="/app/.venv"
ENV PATH="$POETRY_HOME/bin:$VENV_PATH/bin:$PATH"
RUN apt-get install pkg-config libxml2-dev libxmlsec1-dev libxmlsec1-openssl -y
FROM python-base as builder-base
# Build arg credentials
ARG DOCKER_JFROG_USER
ARG DOCKER_JFROG_PASS
RUN apt-get update && apt-get install --no-install-recommends -y curl \
&& curl -sSL https://install.python-poetry.org | python
ARG APP_TO_BUILD
WORKDIR $PYSETUP_PATH
COPY poetry.lock pyproject.toml ./
RUN python -m venv $VENV_PATH
RUN . ${VENV_PATH}/bin/activate
RUN pip install -U pip
RUN poetry install
FROM python-base as production
COPY --from=builder-base $PYSETUP_PATH $PYSETUP_PATH
COPY . $PYSETUP_PATH
CMD ["uvicorn", "fast_api_service.main:app", "--host", "0.0.0.0", "--port", "3001", "--reload", "--timeout-keep-alive", "60"]
I'm trying to start my FastAPI server from a docker container, but it failed due to the following error:
Locally it works. I think I missed something in Dockerfile. This is my
pyproject.toml
:And here
Dockerfile
:I tried everything, but nothing helps, please help me figure it out