chore: update dockerfiles and docker-build workflows to fix releases (#4317)

* bash -x

* bash verbose

* combine bash calls in uv run

* combined python script

* relative dir

* pass args correctly

* pass args correctly

* function name

* fix arg order

* merge base and main

* remove nightly -ep docker image for now

* set up uv in the get-version job in docker-build.yml

* v prefix for version in build job

* use inputs.nightly_tag_main for checkout actions

* mount root project metadata for base build

* fix comment

* continued dockerfile fixes for workspaces setup

* fix path

* ruff check fix
This commit is contained in:
Sebastián Estévez 2024-10-31 07:16:26 -04:00 • committed by GitHub
commit c1097d2dde
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 93 additions and 31 deletions

View file

@ -103,6 +103,9 @@ jobs:
ref: ${{ inputs.nightly_tag_main || github.ref }} ref: ${{ inputs.nightly_tag_main || github.ref }}
persist-credentials: true persist-credentials: true
- name: "Setup Environment"
uses: ./.github/actions/setup-uv
- name: Get Version from Input - name: Get Version from Input
if: ${{ inputs.version != '' }} if: ${{ inputs.version != '' }}
id: get-version-input id: get-version-input
@ -150,6 +153,10 @@ jobs:
id: get-version-base id: get-version-base
run: | run: |
version=$(uv tree | grep 'langflow-base' | awk '{print $3}' | sed 's/^v//') version=$(uv tree | grep 'langflow-base' | awk '{print $3}' | sed 's/^v//')
if [ -z "$version" ]; then
echo "Failed to extract version from uv tree output"
exit 1
fi
echo version=$version echo version=$version
echo version=$version >> $GITHUB_OUTPUT echo version=$version >> $GITHUB_OUTPUT
- name: Get Version Main - name: Get Version Main
@ -208,7 +215,8 @@ jobs:
- name: Check out the code at a specific ref - name: Check out the code at a specific ref
uses: actions/checkout@v4 uses: actions/checkout@v4
with: with:
ref: ${{ needs.get-version.outputs.version || github.ref }} ref: ${{ inputs.nightly_tag_main || github.ref }}
#ref: ${{ needs.get-version.outputs.version && format('v{0}', needs.get-version.outputs.version) || github.ref }}
persist-credentials: true persist-credentials: true
- name: "Setup Environment" - name: "Setup Environment"
uses: ./.github/actions/setup-uv uses: ./.github/actions/setup-uv
@ -284,7 +292,7 @@ jobs:
- name: Check out the code at a specific ref - name: Check out the code at a specific ref
uses: actions/checkout@v4 uses: actions/checkout@v4
with: with:
ref: ${{ needs.get-version.outputs.version || github.ref }} ref: ${{ inputs.nightly_tag_main || github.ref }}
- name: Set up Docker Buildx - name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3 uses: docker/setup-buildx-action@v3
@ -332,7 +340,7 @@ jobs:
- name: Check out the code at a specific ref - name: Check out the code at a specific ref
uses: actions/checkout@v4 uses: actions/checkout@v4
with: with:
ref: ${{ needs.get-version.outputs.version || github.ref }} ref: ${{ inputs.nightly_tag_main || github.ref }}
- name: "Setup Environment" - name: "Setup Environment"
uses: ./.github/actions/setup-uv uses: ./.github/actions/setup-uv

View file

@ -16,7 +16,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
defaults: defaults:
run: run:
shell: bash shell: bash -ex -o pipefail {0}
permissions: permissions:
# Required to create tag # Required to create tag
contents: write contents: write
@ -69,17 +69,10 @@ jobs:
git config --global user.email "bot-nightly-builds@langflow.org" git config --global user.email "bot-nightly-builds@langflow.org"
git config --global user.name "Langflow Bot" git config --global user.name "Langflow Bot"
BASE_TAG="${{ steps.generate_base_tag.outputs.base_tag }}"
echo "Updating base project version to $BASE_TAG"
uv run ./scripts/ci/update_pyproject_name.py langflow-base-nightly base
uv run ./scripts/ci/update_pyproject_version.py $BASE_TAG base
# Use the main tag created earlier
MAIN_TAG="${{ steps.generate_main_tag.outputs.main_tag }}" MAIN_TAG="${{ steps.generate_main_tag.outputs.main_tag }}"
echo "Updating main project version to $MAIN_TAG" BASE_TAG="${{ steps.generate_base_tag.outputs.base_tag }}"
uv run ./scripts/ci/update_pyproject_version.py $MAIN_TAG main echo "Updating base project version to $BASE_TAG and updating main project version to $MAIN_TAG"
uv run ./scripts/ci/update_pyproject_name.py langflow-nightly main uv run ./scripts/ci/update_pyproject_combined.py main $MAIN_TAG $BASE_TAG
uv run ./scripts/ci/update_uv_dependency.py $BASE_TAG
uv lock uv lock
cd src/backend/base && uv lock && cd ../../.. cd src/backend/base && uv lock && cd ../../..

View file

@ -222,16 +222,13 @@ jobs:
nightly_tag_main: ${{ inputs.nightly_tag_main }} nightly_tag_main: ${{ inputs.nightly_tag_main }}
secrets: inherit secrets: inherit
call_docker_build_main_ep: # Not currently supported, let's add it later
name: Call Docker Build Workflow for Langflow with Entrypoint # call_docker_build_main_ep:
if: always() && ${{ inputs.build_docker_ep == 'true' }} # name: Call Docker Build Workflow for Langflow with Entrypoint
needs: [release-nightly-main] # if: always() && ${{ inputs.build_docker_ep == 'true' }}
uses: ./.github/workflows/docker-build.yml # needs: [release-nightly-main]
with: # uses: ./.github/workflows/docker-build.yml
release_type: main-ep # with:
nightly_tag_main: ${{ inputs.nightly_tag_main }} # release_type: main-ep
secrets: inherit # nightly_tag_main: ${{ inputs.nightly_tag_main }}
# secrets: inherit

View file

@ -33,10 +33,14 @@ RUN apt-get update \
&& rm -rf /var/lib/apt/lists/* && rm -rf /var/lib/apt/lists/*
# Install the project's dependencies using the lockfile and settings # Install the project's dependencies using the lockfile and settings
# We need to mount the root uv.lock and pyproject.toml to build the base with uv because we're still using uv workspaces
RUN --mount=type=cache,target=/root/.cache/uv \ RUN --mount=type=cache,target=/root/.cache/uv \
--mount=type=bind,source=src/backend/base/README.md,target=src/backend/base/README.md \ --mount=type=bind,source=src/backend/base/README.md,target=src/backend/base/README.md \
--mount=type=bind,source=src/backend/base/uv.lock,target=src/backend/base/uv.lock \ --mount=type=bind,source=src/backend/base/uv.lock,target=src/backend/base/uv.lock \
--mount=type=bind,source=src/backend/base/pyproject.toml,target=src/backend/base/pyproject.toml \ --mount=type=bind,source=src/backend/base/pyproject.toml,target=src/backend/base/pyproject.toml \
--mount=type=bind,source=uv.lock,target=uv.lock \
--mount=type=bind,source=README.md,target=README.md \
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \
cd src/backend/base && uv sync --frozen --no-install-project --no-dev --no-editable cd src/backend/base && uv sync --frozen --no-install-project --no-dev --no-editable
ADD ./src /app/src ADD ./src /app/src
@ -48,7 +52,14 @@ RUN npm install \
&& cp -r build /app/src/backend/base/langflow/frontend \ && cp -r build /app/src/backend/base/langflow/frontend \
&& rm -rf /tmp/src/frontend && rm -rf /tmp/src/frontend
ADD ./src/backend/base /app/src/backend/base
WORKDIR /app/src/backend/base WORKDIR /app/src/backend/base
# again we need these because of workspaces
ADD ./pyproject.toml /app/pyproject.toml
ADD ./uv.lock /app/uv.lock
ADD ./src/backend/base/pyproject.toml /app/src/backend/base/pyproject.toml
ADD ./src/backend/base/uv.lock /app/src/backend/base/uv.lock
ADD ./src/backend/base/README.md /app/src/backend/base/README.md
RUN --mount=type=cache,target=/root/.cache/uv \ RUN --mount=type=cache,target=/root/.cache/uv \
uv sync --frozen --no-dev --no-editable uv sync --frozen --no-dev --no-editable
@ -59,10 +70,11 @@ RUN --mount=type=cache,target=/root/.cache/uv \
FROM python:3.12.3-slim AS runtime FROM python:3.12.3-slim AS runtime
RUN useradd user -u 1000 -g 0 --no-create-home --home-dir /app/data RUN useradd user -u 1000 -g 0 --no-create-home --home-dir /app/data
COPY --from=builder --chown=1000 /app/src/backend/base/.venv /app/src/backend/base/.venv # and we use the venv at the root because workspaces
COPY --from=builder --chown=1000 /app/.venv /app/.venv
# Place executables in the environment at the front of the path # Place executables in the environment at the front of the path
ENV PATH="/app/src/backend/base/.venv/bin:$PATH" ENV PATH="/app/.venv/bin:$PATH"
LABEL org.opencontainers.image.title=langflow LABEL org.opencontainers.image.title=langflow
LABEL org.opencontainers.image.authors=['Langflow'] LABEL org.opencontainers.image.authors=['Langflow']

View file

@ -0,0 +1,52 @@
#!/usr/bin/env python
# scripts/ci/update_pyproject_combined.py
import sys
from pathlib import Path
from update_pyproject_name import update_pyproject_name
from update_pyproject_name import update_uv_dep as update_name_uv_dep
from update_pyproject_version import update_pyproject_version
from update_uv_dependency import update_uv_dep as update_version_uv_dep
# Add the current directory to the path so we can import the other scripts
current_dir = Path(__file__).resolve().parent
sys.path.append(str(current_dir))
def main():
"""Universal update script that handles both base and main updates in a single run.
Usage:
update_pyproject_combined.py main <main_tag> <base_tag>
"""
arg_count = 4
if len(sys.argv) != arg_count:
print("Usage:")
print(" update_pyproject_combined.py main <main_tag> <base_tag>")
sys.exit(1)
mode = sys.argv[1]
if mode != "main":
print("Only 'main' mode is supported")
print("Usage: update_pyproject_combined.py main <main_tag> <base_tag>")
sys.exit(1)
main_tag = sys.argv[2]
base_tag = sys.argv[3]
# First handle base package updates
update_pyproject_name("src/backend/base/pyproject.toml", "langflow-base-nightly")
update_name_uv_dep("pyproject.toml", "langflow-base-nightly")
update_pyproject_version("src/backend/base/pyproject.toml", base_tag)
# Then handle main package updates
update_pyproject_name("pyproject.toml", "langflow-nightly")
update_name_uv_dep("pyproject.toml", "langflow-nightly")
update_pyproject_version("pyproject.toml", main_tag)
# Update dependency version (strip 'v' prefix if present)
base_version = base_tag.lstrip("v")
update_version_uv_dep(base_version)
if __name__ == "__main__":
main()