044d38e390
* Auto-yield run execution to help prevent duplicate task executions * Add auto-yield config to endpoints * Refactor run execution with buffer and limits Introduced constants RUN_CHUNK_EXECUTION_BUFFER and MAX_RUN_CHUNK_EXECUTION_LIMIT. Adjusted PerformRunExecutionV2Service to use the new constants to fine-tune execution timings and buffers. * Add endpoint probing functionality Added new `RESPONSE_TIMEOUT_STATUS_CODES` in `consts.ts` to manage timeout responses. Additional functions `detectResponseIsTimeout(response: Response)` was added in `endpoint.server.ts` to detect if a response was a timeout based on the status codes from `RESPONSE_TIMEOUT_STATUS_CODES`. Update actions to use new endpoint probing endpoint service. This allows for the early probing of endpoints to determine if they're up and running. A new class `ProbeEndpointService` was created in `probeEndpoint.server.ts` which makes HTTP requests to a given endpoint and updates its properties based on the result. Finally, `detectResponseIsTimeout(response)` is used in `performRunExecutionV2.server.ts` for marking the execution as succeeded when facing a timeout. * Refactored probe method in EndpointApi class The probe method of the EndpointApi class has been refactored to remove the error handling part and it now takes a timeout sent from the client directly. The corresponding changes were also made in the ProbeEndpointService and TriggerClient objects to reflect the alterations in the probe method. The error handling related to the timeout has been removed and the responsibility of handling the timeout has been shifted to the client. Thus, the probe method has been greatly simplified. The `probeEndpoint.server.ts` file was also changed to accommodate the change in behavior of the probe result. In the `triggerClient.ts` the timeout for probe is now read from the incoming request object. For backward compatibility, if no timeout is provided in the request, the default value of 15 minutes is used. * Remove performRunExecution v1 enqueue function * Better document limits and add docs on increasing function timeouts * Upgrade webapp docker container to use 18.18.2 * force clients to yield when a run is executing in a gracefully shutting down worker * Renamed task `key` to `cacheKey` and added more task documentation * Index the `@trigger.dev/sdk` version on Endpoints
72 lines
2.9 KiB
Docker
72 lines
2.9 KiB
Docker
FROM node:18.18.2-bullseye-slim@sha256:a50436b44fe3eb2ff72696fb394ad3cae45f06cb2a7468c5ef3f012d23d9888f AS pruner
|
|
|
|
WORKDIR /triggerdotdev
|
|
|
|
COPY --chown=node:node . .
|
|
RUN npx -q turbo@1.10.9 prune --scope=webapp --docker
|
|
RUN find . -name "node_modules" -type d -prune -exec rm -rf '{}' +
|
|
|
|
# Base strategy to have layer caching
|
|
FROM node:18.18.2-bullseye-slim@sha256:a50436b44fe3eb2ff72696fb394ad3cae45f06cb2a7468c5ef3f012d23d9888f AS base
|
|
RUN apt-get update && apt-get install -y openssl dumb-init
|
|
WORKDIR /triggerdotdev
|
|
COPY --chown=node:node .gitignore .gitignore
|
|
COPY --from=pruner --chown=node:node /triggerdotdev/out/json/ .
|
|
COPY --from=pruner --chown=node:node /triggerdotdev/out/pnpm-lock.yaml ./pnpm-lock.yaml
|
|
COPY --from=pruner --chown=node:node /triggerdotdev/out/pnpm-workspace.yaml ./pnpm-workspace.yaml
|
|
|
|
## Dev deps
|
|
FROM base AS dev-deps
|
|
WORKDIR /triggerdotdev
|
|
# Corepack is used to install pnpm
|
|
RUN corepack enable
|
|
ENV NODE_ENV development
|
|
RUN pnpm install --ignore-scripts --no-frozen-lockfile
|
|
|
|
## Production deps
|
|
FROM base AS production-deps
|
|
WORKDIR /triggerdotdev
|
|
# Corepack is used to install pnpm
|
|
RUN corepack enable
|
|
ENV NODE_ENV production
|
|
RUN pnpm install --prod --no-frozen-lockfile
|
|
COPY --from=pruner --chown=node:node /triggerdotdev/packages/database/prisma/schema.prisma /triggerdotdev/packages/database/prisma/schema.prisma
|
|
# RUN pnpm add @prisma/client@5.1.1 -w
|
|
ENV NPM_CONFIG_IGNORE_WORKSPACE_ROOT_CHECK true
|
|
RUN pnpx prisma@5.4.1 generate --schema /triggerdotdev/packages/database/prisma/schema.prisma
|
|
|
|
## Builder (builds the webapp)
|
|
FROM base AS builder
|
|
WORKDIR /triggerdotdev
|
|
# Corepack is used to install pnpm
|
|
RUN corepack enable
|
|
COPY --from=pruner --chown=node:node /triggerdotdev/out/full/ .
|
|
COPY --from=dev-deps --chown=node:node /triggerdotdev/ .
|
|
COPY --chown=node:node turbo.json turbo.json
|
|
COPY --chown=node:node docker/scripts ./scripts
|
|
RUN chmod +x ./scripts/wait-for-it.sh
|
|
RUN chmod +x ./scripts/entrypoint.sh
|
|
RUN pnpm run generate
|
|
RUN pnpm run build --filter=webapp...
|
|
|
|
# Runner
|
|
FROM node:18.18.2-bullseye-slim@sha256:a50436b44fe3eb2ff72696fb394ad3cae45f06cb2a7468c5ef3f012d23d9888f AS runner
|
|
RUN apt-get update && apt-get install -y openssl
|
|
WORKDIR /triggerdotdev
|
|
RUN corepack enable
|
|
ENV NODE_ENV production
|
|
|
|
COPY --from=base /usr/bin/dumb-init /usr/bin/dumb-init
|
|
COPY --from=pruner --chown=node:node /triggerdotdev/out/full/ .
|
|
COPY --from=production-deps --chown=node:node /triggerdotdev .
|
|
COPY --from=builder --chown=node:node /triggerdotdev/apps/webapp/build/server.js ./apps/webapp/build/server.js
|
|
COPY --from=builder --chown=node:node /triggerdotdev/apps/webapp/build ./apps/webapp/build
|
|
COPY --from=builder --chown=node:node /triggerdotdev/apps/webapp/public ./apps/webapp/public
|
|
COPY --from=builder --chown=node:node /triggerdotdev/apps/webapp/prisma/seed.js ./apps/webapp/prisma/seed.js
|
|
COPY --from=builder --chown=node:node /triggerdotdev/scripts ./scripts
|
|
|
|
EXPOSE 3000
|
|
|
|
USER node
|
|
CMD ["./scripts/entrypoint.sh"]
|