Skip to content

Commit 1a6f43f

Browse files
hyobanautofix-ci[bot]lyzno1
authored andcommitted
build: include vinext in docker build (langgenius#34535)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: yyh <92089059+lyzno1@users.noreply.github.com> Co-authored-by: yyh <yuanyouhuilyz@gmail.com>
1 parent 04a8d9c commit 1a6f43f

11 files changed

Lines changed: 37 additions & 15 deletions

docker/.env.example

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1173,6 +1173,9 @@ MAX_ITERATIONS_NUM=99
11731173
# The timeout for the text generation in millisecond
11741174
TEXT_GENERATION_TIMEOUT_MS=60000
11751175

1176+
# Enable the experimental vinext runtime shipped in the image.
1177+
EXPERIMENTAL_ENABLE_VINEXT=false
1178+
11761179
# Allow rendering unsafe URLs which have "data:" scheme.
11771180
ALLOW_UNSAFE_DATA_SCHEME=false
11781181

docker/docker-compose-template.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ services:
161161
NEXT_PUBLIC_COOKIE_DOMAIN: ${NEXT_PUBLIC_COOKIE_DOMAIN:-}
162162
SENTRY_DSN: ${WEB_SENTRY_DSN:-}
163163
NEXT_TELEMETRY_DISABLED: ${NEXT_TELEMETRY_DISABLED:-0}
164+
EXPERIMENTAL_ENABLE_VINEXT: ${EXPERIMENTAL_ENABLE_VINEXT:-false}
164165
TEXT_GENERATION_TIMEOUT_MS: ${TEXT_GENERATION_TIMEOUT_MS:-60000}
165166
CSP_WHITELIST: ${CSP_WHITELIST:-}
166167
ALLOW_EMBED: ${ALLOW_EMBED:-false}

docker/docker-compose.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -509,6 +509,7 @@ x-shared-env: &shared-api-worker-env
509509
MAX_PARALLEL_LIMIT: ${MAX_PARALLEL_LIMIT:-10}
510510
MAX_ITERATIONS_NUM: ${MAX_ITERATIONS_NUM:-99}
511511
TEXT_GENERATION_TIMEOUT_MS: ${TEXT_GENERATION_TIMEOUT_MS:-60000}
512+
EXPERIMENTAL_ENABLE_VINEXT: ${EXPERIMENTAL_ENABLE_VINEXT:-false}
512513
ALLOW_UNSAFE_DATA_SCHEME: ${ALLOW_UNSAFE_DATA_SCHEME:-false}
513514
MAX_TREE_DEPTH: ${MAX_TREE_DEPTH:-50}
514515
PGDATA: ${PGDATA:-/var/lib/postgresql/data/pgdata}
@@ -870,6 +871,7 @@ services:
870871
NEXT_PUBLIC_COOKIE_DOMAIN: ${NEXT_PUBLIC_COOKIE_DOMAIN:-}
871872
SENTRY_DSN: ${WEB_SENTRY_DSN:-}
872873
NEXT_TELEMETRY_DISABLED: ${NEXT_TELEMETRY_DISABLED:-0}
874+
EXPERIMENTAL_ENABLE_VINEXT: ${EXPERIMENTAL_ENABLE_VINEXT:-false}
873875
TEXT_GENERATION_TIMEOUT_MS: ${TEXT_GENERATION_TIMEOUT_MS:-60000}
874876
CSP_WHITELIST: ${CSP_WHITELIST:-}
875877
ALLOW_EMBED: ${ALLOW_EMBED:-false}

web/Dockerfile

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ COPY . .
4242

4343
WORKDIR /app/web
4444
ENV NODE_OPTIONS="--max-old-space-size=4096"
45-
RUN pnpm build
45+
RUN pnpm build && pnpm build:vinext
4646

4747

4848
# production stage
@@ -56,6 +56,7 @@ ENV APP_API_URL=http://127.0.0.1:5001
5656
ENV MARKETPLACE_API_URL=https://marketplace.dify.ai
5757
ENV MARKETPLACE_URL=https://marketplace.dify.ai
5858
ENV PORT=3000
59+
ENV EXPERIMENTAL_ENABLE_VINEXT=false
5960
ENV NEXT_TELEMETRY_DISABLED=1
6061

6162
# set timezone
@@ -73,9 +74,10 @@ RUN addgroup -S -g ${dify_uid} dify && \
7374

7475
WORKDIR /app
7576

76-
COPY --from=builder --chown=dify:dify /app/web/public ./web/public
77-
COPY --from=builder --chown=dify:dify /app/web/.next/standalone ./
78-
COPY --from=builder --chown=dify:dify /app/web/.next/static ./web/.next/static
77+
COPY --from=builder --chown=dify:dify /app/web/public ./targets/next/web/public
78+
COPY --from=builder --chown=dify:dify /app/web/.next/standalone ./targets/next/
79+
COPY --from=builder --chown=dify:dify /app/web/.next/static ./targets/next/web/.next/static
80+
COPY --from=builder --chown=dify:dify /app/web/dist/standalone ./targets/vinext
7981

8082
COPY --chown=dify:dify --chmod=755 web/docker/entrypoint.sh ./entrypoint.sh
8183

web/app/components/workflow/hooks/__tests__/use-workflow-interactions.spec.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,12 +111,16 @@ vi.mock('../use-workflow-history', () => ({
111111

112112
vi.mock('../../utils', async importOriginal => ({
113113
...(await importOriginal<typeof import('../../utils')>()),
114-
getLayoutForChildNodes: (...args: unknown[]) => mockGetLayoutForChildNodes(...args),
115-
getLayoutByELK: (...args: unknown[]) => mockGetLayoutByELK(...args),
116114
initialNodes: (nodes: unknown[], edges: unknown[]) => mockInitialNodes(nodes, edges),
117115
initialEdges: (edges: unknown[], nodes: unknown[]) => mockInitialEdges(edges, nodes),
118116
}))
119117

118+
vi.mock('../../utils/elk-layout', async importOriginal => ({
119+
...(await importOriginal<typeof import('../../utils/elk-layout')>()),
120+
getLayoutForChildNodes: (...args: unknown[]) => mockGetLayoutForChildNodes(...args),
121+
getLayoutByELK: (...args: unknown[]) => mockGetLayoutByELK(...args),
122+
}))
123+
120124
describe('use-workflow-interactions exports', () => {
121125
it('re-exports the split workflow interaction hooks', () => {
122126
expect(workflowInteractionExports.useWorkflowInteractions).toBeTypeOf('function')

web/app/components/workflow/hooks/use-workflow-organize.helpers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { Node } from '../types'
2-
import type { LayoutResult } from '../utils'
2+
import type { LayoutResult } from '../utils/elk-layout'
33
import { produce } from 'immer'
44
import {
55
CUSTOM_NODE,

web/app/components/workflow/hooks/use-workflow-organize.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { useWorkflowStore } from '../store'
44
import {
55
getLayoutByELK,
66
getLayoutForChildNodes,
7-
} from '../utils'
7+
} from '../utils/elk-layout'
88
import { useNodesSyncDraft } from './use-nodes-sync-draft'
99
import { useNodesReadOnly } from './use-workflow'
1010
import { useWorkflowHistory, WorkflowHistoryEvent } from './use-workflow-history'

web/app/components/workflow/utils/elk-layout.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import type {
66
Edge,
77
Node,
88
} from '@/app/components/workflow/types'
9-
import ELK from 'elkjs/lib/elk.bundled.js'
109
import { cloneDeep } from 'es-toolkit/object'
1110
import {
1211
CUSTOM_NODE,
@@ -19,7 +18,15 @@ import {
1918
BlockEnum,
2019
} from '@/app/components/workflow/types'
2120

22-
const elk = new ELK()
21+
let elk: import('elkjs/lib/elk-api').ELK | undefined
22+
23+
async function getELK() {
24+
if (!elk) {
25+
const { default: ELK } = await import('elkjs/lib/elk.bundled.js')
26+
elk = new ELK()
27+
}
28+
return elk
29+
}
2330

2431
const DEFAULT_NODE_WIDTH = 244
2532
const DEFAULT_NODE_HEIGHT = 100
@@ -473,7 +480,7 @@ export const getLayoutByELK = async (originNodes: Node[], originEdges: Edge[]):
473480
edges: elkEdges,
474481
}
475482

476-
const layoutedGraph = await elk.layout(graph)
483+
const layoutedGraph = await (await getELK()).layout(graph)
477484
const layout = collectLayout(layoutedGraph, () => true)
478485
return normaliseBounds(layout)
479486
}
@@ -571,7 +578,7 @@ export const getLayoutForChildNodes = async (
571578
edges: elkEdges,
572579
}
573580

574-
const layoutedGraph = await elk.layout(graph)
581+
const layoutedGraph = await (await getELK()).layout(graph)
575582
const layout = collectLayout(layoutedGraph, () => true)
576583
return normaliseChildLayout(layout, nodes)
577584
}

web/app/components/workflow/utils/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
export * from './common'
22
export * from './data-source'
33
export * from './edge'
4-
export * from './elk-layout'
54
export * from './gen-node-meta-data'
65
export * from './node'
76
export * from './tool'

web/docker/entrypoint.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,8 @@ export NEXT_PUBLIC_MAX_PARALLEL_LIMIT=${MAX_PARALLEL_LIMIT}
4343
export NEXT_PUBLIC_MAX_ITERATIONS_NUM=${MAX_ITERATIONS_NUM}
4444
export NEXT_PUBLIC_MAX_TREE_DEPTH=${MAX_TREE_DEPTH}
4545

46-
exec node /app/web/server.js
46+
if [ "${EXPERIMENTAL_ENABLE_VINEXT:-}" = "true" ]; then
47+
exec node /app/targets/vinext/server.js
48+
fi
49+
50+
exec node /app/targets/next/web/server.js

0 commit comments

Comments
 (0)