docker: force python version to 3.12.3 (#2148)

* docker: force python version to 3.12.3

* also fixes pydantic

* remove ci build - too slow

* use lock file for deps

* use poetry.lock

* use poetry.lock
This commit is contained in:
Nicolò Boschi 2024-06-12 15:09:46 +02:00 • committed by GitHub
commit 968ec28fbc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 22 additions and 23 deletions

View file

@ -24,6 +24,7 @@ env:
jobs: jobs:
test-docker: test-docker:
runs-on: ubuntu-latest runs-on: ubuntu-latest
name: Test docker images
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- name: Build image - name: Build image
@ -61,20 +62,3 @@ jobs:
docker build -t langflowai/langflow-frontend:latest-dev \ docker build -t langflowai/langflow-frontend:latest-dev \
-f docker/frontend/build_and_push_frontend.Dockerfile \ -f docker/frontend/build_and_push_frontend.Dockerfile \
. .
test-multi-arch-build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
id: qemu
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
push: false
file: ./docker/build_and_push.Dockerfile
platforms: "linux/amd64,linux/arm64/v8"
tags: langflowai/langflow:latest-dev

View file

@ -7,8 +7,9 @@
# Used to build deps + create our virtual environment # Used to build deps + create our virtual environment
################################ ################################
# force platform to the current architecture to increase build speed time on multi-platform builds # 1. use python:3.12.3-slim as the base image until https://github.com/pydantic/pydantic-core/issues/1292 gets resolved
FROM --platform=$BUILDPLATFORM python:3.12-slim as builder-base # 2. do not add --platform=$BUILDPLATFORM because the pydantic binaries must be resolved for the final architecture
FROM python:3.12.3-slim as builder-base
ENV PYTHONDONTWRITEBYTECODE=1 \ ENV PYTHONDONTWRITEBYTECODE=1 \
\ \
@ -51,15 +52,27 @@ COPY pyproject.toml poetry.lock README.md ./
COPY src/ ./src COPY src/ ./src
COPY scripts/ ./scripts COPY scripts/ ./scripts
RUN python -m pip install requests --user && cd ./scripts && python update_dependencies.py RUN python -m pip install requests --user && cd ./scripts && python update_dependencies.py
# 1. Install the dependencies using the current poetry.lock file to create reproducible builds
# 2. Do not install dev dependencies
# 3. Install all the extras to ensure all optionals are installed as well
# 4. --sync to ensure nothing else is in the environment
# 5. Build the wheel and install "langflow" package (mainly for version)
# Note: moving to build and installing the wheel will make the docker images not reproducible.
RUN $POETRY_HOME/bin/poetry lock --no-update \ RUN $POETRY_HOME/bin/poetry lock --no-update \
# install current lock file with fixed dependencies versions \
# do not install dev dependencies \
&& $POETRY_HOME/bin/poetry install --without dev --sync -E deploy -E couchbase -E cassio \
&& $POETRY_HOME/bin/poetry build -f wheel \ && $POETRY_HOME/bin/poetry build -f wheel \
&& $POETRY_HOME/bin/poetry run pip install dist/*.whl --force-reinstall && $POETRY_HOME/bin/poetry run pip install dist/*.whl
################################ ################################
# RUNTIME # RUNTIME
# Setup user, utilities and copy the virtual environment only # Setup user, utilities and copy the virtual environment only
################################ ################################
FROM python:3.12-slim as runtime # 1. use python:3.12.3-slim as the base image until https://github.com/pydantic/pydantic-core/issues/1292 gets resolved
FROM python:3.12.3-slim as runtime
RUN apt-get -y update \ RUN apt-get -y update \
&& apt-get install --no-install-recommends -y \ && apt-get install --no-install-recommends -y \

View file

@ -10,7 +10,9 @@
# PYTHON-BASE # PYTHON-BASE
# Sets up all our shared environment variables # Sets up all our shared environment variables
################################ ################################
FROM python:3.12-slim as python-base
# use python:3.12.3-slim as the base image until https://github.com/pydantic/pydantic-core/issues/1292 gets resolved
FROM python:3.12.3-slim as python-base
# python # python
ENV PYTHONUNBUFFERED=1 \ ENV PYTHONUNBUFFERED=1 \

View file

@ -5,7 +5,7 @@
# BUILDER-BASE # BUILDER-BASE
################################ ################################
# force platform to the current architecture to increase build speed time on multi-platform builds # 1. force platform to the current architecture to increase build speed time on multi-platform builds
FROM --platform=$BUILDPLATFORM node:lts-bookworm-slim as builder-base FROM --platform=$BUILDPLATFORM node:lts-bookworm-slim as builder-base
COPY src/frontend /frontend COPY src/frontend /frontend