Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

build: fix api docker build (#36423)

Stephen Zhou8f197c5a0ae7
diff --git a/.github/workflows/build-push.yml b/.github/workflows/build-push.yml
index 915ed6cfe85..d35a5ae178c 100644
--- a/.github/workflows/build-push.yml
+++ b/.github/workflows/build-push.yml
@@ -35,15 +35,15 @@ jobs:
- service_name: "build-api-amd64"
image_name_env: "DIFY_API_IMAGE_NAME"
artifact_context: "api"
- build_context: "{{defaultContext}}:api"
- file: "Dockerfile"
+ build_context: "{{defaultContext}}"
+ file: "api/Dockerfile"
platform: linux/amd64
runs_on: depot-ubuntu-24.04-4
- service_name: "build-api-arm64"
image_name_env: "DIFY_API_IMAGE_NAME"
artifact_context: "api"
- build_context: "{{defaultContext}}:api"
- file: "Dockerfile"
+ build_context: "{{defaultContext}}"
+ file: "api/Dockerfile"
platform: linux/arm64
runs_on: depot-ubuntu-24.04-4
- service_name: "build-web-amd64"
@@ -117,8 +117,8 @@ jobs:
matrix:
include:
- service_name: "validate-api-amd64"
- build_context: "{{defaultContext}}:api"
- file: "Dockerfile"
+ build_context: "{{defaultContext}}"
+ file: "api/Dockerfile"
- service_name: "validate-web-amd64"
build_context: "{{defaultContext}}"
file: "web/Dockerfile"
diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml
index 5144510be52..987edc37ef4 100644
--- a/.github/workflows/docker-build.yml
+++ b/.github/workflows/docker-build.yml
@@ -6,6 +6,12 @@ on:
- "main"
paths:
- api/Dockerfile
+ - api/Dockerfile.dockerignore
+ - api/pyproject.toml
+ - api/uv.lock
+ - dify-agent/pyproject.toml
+ - dify-agent/README.md
+ - dify-agent/src/**
- web/Dockerfile
concurrency:
@@ -25,13 +31,13 @@ jobs:
- service_name: "api-amd64"
platform: linux/amd64
runs_on: depot-ubuntu-24.04-4
- context: "{{defaultContext}}:api"
- file: "Dockerfile"
+ context: "{{defaultContext}}"
+ file: "api/Dockerfile"
- service_name: "api-arm64"
platform: linux/arm64
runs_on: depot-ubuntu-24.04-4
- context: "{{defaultContext}}:api"
- file: "Dockerfile"
+ context: "{{defaultContext}}"
+ file: "api/Dockerfile"
- service_name: "web-amd64"
platform: linux/amd64
runs_on: depot-ubuntu-24.04-4
@@ -64,8 +70,8 @@ jobs:
matrix:
include:
- service_name: "api-amd64"
- context: "{{defaultContext}}:api"
- file: "Dockerfile"
+ context: "{{defaultContext}}"
+ file: "api/Dockerfile"
- service_name: "web-amd64"
context: "{{defaultContext}}"
file: "web/Dockerfile"
diff --git a/api/Dockerfile b/api/Dockerfile
index 84255789533..81296ee076b 100644
--- a/api/Dockerfile
+++ b/api/Dockerfile
@@ -22,9 +22,11 @@ RUN apt-get update \
libmpfr-dev libmpc-dev
# Install Python dependencies (workspace members under providers/vdb/)
-COPY pyproject.toml uv.lock ./
-COPY providers ./providers
-# Trust the checked-in lock during image builds; dev-only path sources live outside the api/ context.
+COPY api/pyproject.toml api/uv.lock ./
+COPY api/providers ./providers
+COPY dify-agent/pyproject.toml dify-agent/README.md /app/dify-agent/
+COPY dify-agent/src /app/dify-agent/src
+# Trust the checked-in lock during image builds; local path sources are copied from the repository context.
RUN uv sync --frozen --no-dev
# production stage
@@ -108,10 +110,10 @@ RUN python -c "import tiktoken; tiktoken.encoding_for_model('gpt2')" \
&& chown -R dify:dify ${TIKTOKEN_CACHE_DIR}
# Copy source code
-COPY --chown=dify:dify . /app/api/
+COPY --chown=dify:dify api /app/api/
# Prepare entrypoint script
-COPY --chown=dify:dify --chmod=755 docker/entrypoint.sh /entrypoint.sh
+COPY --chown=dify:dify --chmod=755 api/docker/entrypoint.sh /entrypoint.sh
ARG COMMIT_SHA
diff --git a/api/Dockerfile.dockerignore b/api/Dockerfile.dockerignore
new file mode 100644
index 00000000000..8ec1323c3f6
--- /dev/null
+++ b/api/Dockerfile.dockerignore
@@ -0,0 +1,25 @@
+*
+
+!api/
+!api/**
+!dify-agent/
+!dify-agent/pyproject.toml
+!dify-agent/README.md
+!dify-agent/src/
+!dify-agent/src/**
+
+api/.venv
+api/.venv/**
+api/.env
+api/*.env.*
+api/.idea
+api/.mypy_cache
+api/.ruff_cache
+api/storage/generate_files/*
+api/storage/privkeys/*
+api/storage/tools/*
+api/storage/upload_files/*
+api/logs
+api/*.log*
+**/__pycache__
+**/*.pyc