Flowise/Dockerfile

71 lines
1.8 KiB
Docker

# syntax=docker/dockerfile:1
# Comments are provided throughout this file to help you get started.
# If you need more help, visit the Dockerfile reference guide at
# https://docs.docker.com/go/dockerfile-reference/
FROM node:20-alpine as base
WORKDIR /app
RUN apk add --update libc6-compat python3 make g++
# needed for pdfjs-dist
RUN apk add --no-cache build-base cairo-dev pango-dev
# Install Chromium
RUN apk add --no-cache chromium
#install PNPM globaly
RUN npm install -g pnpm turbo@1
RUN pnpm config set store-dir ~/.pnpm-store
ENV PUPPETEER_SKIP_DOWNLOAD=true
ENV PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium-browser
################################################################################
# Prune projects
FROM base AS pruner
COPY . .
RUN turbo prune --scope=flowise --docker
################################################################################
# Create a stage for building the application.
FROM base as build
COPY --from=pruner /app/out/json/ .
# First install the dependencies (as they change less often)
RUN --mount=type=cache,id=pnpm,target=~/.pnpm-store pnpm install
# Copy the rest of the source files into the image.
COPY --from=pruner /app/out/full/ .
# Run the build script.
RUN --mount=type=cache,target=/app/node_modules/.cache pnpm run build --filter flowise
# Prune the dev dependencies
#RUN --mount=type=cache,id=pnpm,target=~/.pnpm-store pnpm prune --prod --no-optional
################################################################################
FROM base AS runner
ENV NODE_ENV production
COPY --from=build /app .
WORKDIR /app/packages/server
# Expose the port that the application listens on.
EXPOSE 4000
COPY update_ui_env.sh /docker-entrypoint.d/update_ui_env.sh
RUN chmod +x /docker-entrypoint.d/update_ui_env.sh
# Run the application.
ENTRYPOINT ["/docker-entrypoint.d/update_ui_env.sh"]
CMD ["pnpm", "start"]