Explorar el Código

build Docker image without poetry

highing666 hace 2 años
padre
commit
cf594b4eec
Se han modificado 3 ficheros con 83 adiciones y 18 borrados
  1. 8 18
      Dockerfile
  2. 31 0
      Dockerfile.old
  3. 44 0
      requirements.txt

+ 8 - 18
Dockerfile

@@ -1,30 +1,20 @@
-# syntax=docker/dockerfile:1
+FROM python:3.10
 
-# FROM tiangolo/uvicorn-gunicorn-fastapi:python3.8
-FROM tiangolo/uvicorn-gunicorn:python3.9
+WORKDIR /code
 
-WORKDIR /app
+COPY ./requirements.txt /code/requirements.txt
 
-# Install Poetry
-RUN curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | POETRY_HOME=/opt/poetry python && \
-    cd /usr/local/bin && \
-    ln -s /opt/poetry/bin/poetry && \
-    poetry config virtualenvs.create false
+RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
 
-# Copy poetry.lock* in case it doesn't exist in the repo
-COPY pyproject.toml poetry.lock* /app/
+COPY ./app /code/app
 
-# Allow installing dev dependencies to run tests
-ARG INSTALL_DEV=false
-RUN bash -c "if [ $INSTALL_DEV == 'true' ] ; then poetry install --no-root ; else poetry install --no-root --no-dev ; fi"
+RUN mkdir -p /code/ml_models
 
-COPY ./app /app/app
-RUN mkdir -p /app/ml_models
-ENV PYTHONPATH=/app
+ENV PYTHONPATH=/code
 
 EXPOSE 8002
 
-COPY .env_pro /app/.env
+COPY .env_pro /code/.env
 
 ENV TZ=Asia/Shanghai
 

+ 31 - 0
Dockerfile.old

@@ -0,0 +1,31 @@
+# syntax=docker/dockerfile:1
+
+# FROM tiangolo/uvicorn-gunicorn-fastapi:python3.8
+FROM tiangolo/uvicorn-gunicorn:python3.9
+
+WORKDIR /app
+
+# Install Poetry
+RUN curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | POETRY_HOME=/opt/poetry python && \
+    cd /usr/local/bin && \
+    ln -s /opt/poetry/bin/poetry && \
+    poetry config virtualenvs.create false
+
+# Copy poetry.lock* in case it doesn't exist in the repo
+COPY pyproject.toml poetry.lock* /app/
+
+# Allow installing dev dependencies to run tests
+ARG INSTALL_DEV=false
+RUN bash -c "if [ $INSTALL_DEV == 'true' ] ; then poetry install --no-root ; else poetry install --no-root --no-dev ; fi"
+
+COPY ./app /app/app
+RUN mkdir -p /app/ml_models
+ENV PYTHONPATH=/app
+
+EXPOSE 8002
+
+COPY .env_pro /app/.env
+
+ENV TZ=Asia/Shanghai
+
+CMD ["uvicorn", "app.main:app", "--log-level", "info", "--host", "0.0.0.0", "--port", "8002"]

+ 44 - 0
requirements.txt

@@ -0,0 +1,44 @@
+anyio==3.6.1
+arrow==1.2.2
+async-timeout==4.0.2
+certifi==2022.6.15
+charset-normalizer==2.1.0
+click==8.1.3
+Deprecated==1.2.13
+fastapi==0.79.0
+grpcio==1.47.0
+grpcio-tools==1.47.0
+h11==0.12.0
+httpcore==0.15.0
+httpx==0.23.0
+idna==3.3
+joblib==1.1.0
+loguru==0.6.0
+mmh3==3.0.0
+numpy==1.23.2
+packaging==21.3
+pandas==1.4.3
+protobuf==3.20.1
+psycopg2-binary==2.9.3
+pydantic==1.9.2
+pymilvus==2.1.1
+pyparsing==3.0.9
+python-dateutil==2.8.2
+python-dotenv==0.20.0
+pytz==2022.2.1
+redis==4.3.4
+requests==2.28.1
+rfc3986==1.5.0
+scikit-learn==1.1.2
+scipy==1.9.0
+six==1.16.0
+sniffio==1.2.0
+SQLAlchemy==1.4.40
+starlette==0.19.1
+tencentcloud-sdk-python==3.0.715
+threadpoolctl==3.1.0
+typing_extensions==4.3.0
+ujson==5.4.0
+urllib3==1.26.11
+uvicorn==0.18.2
+wrapt==1.14.1