Flowise icon indicating copy to clipboard operation
Flowise copied to clipboard

Dockerfile fix to run on Hugging Face

Open lucianotonet opened this issue 2 years ago • 7 comments

lucianotonet avatar Aug 03 '23 09:08 lucianotonet

hey @lucianotonet can you elaborate what is this PR for?

HenryHengZJ avatar Aug 03 '23 16:08 HenryHengZJ

Objective of the Change

The existing Dockerfile needed adjustments to run on Hugging Face Spaces. This pull request introduces changes to make the Dockerfile more flexible and optimized for deployment in that specific environment.

Changes Made

  1. Added Build Arguments: Introduced build arguments like FLOWISE_PATH, PORT, PASSPHRASE, DATABASE_PATH, APIKEY_PATH, SECRETKEY_PATH, and LOG_PATH to allow customization at build time.
  2. Consolidated Dependency Installation: Combined the installation of dependencies like git, python3, py3-pip, make, g++, build-base, cairo-dev, pango-dev, chromium into a single RUN command.
  3. Environment Variables Configuration: Defined environment variables using the build arguments to make the Dockerfile more dynamic.
  4. Flowise Directories Configuration: Created and configured necessary directories for Flowise, including permissions.

Detailed Changes

+ ARG FLOWISE_PATH=/usr/local/lib/node_modules/flowise
+ ARG PORT=7860
+ ARG PASSPHRASE=
+ ARG DATABASE_PATH=/root/.flowise
+ ARG APIKEY_PATH=/root/.flowise
+ ARG SECRETKEY_PATH=/root/.flowise
+ ARG LOG_PATH=/root/.flowise/logs
+ RUN apk add --no-cache git python3 py3-pip make g++ build-base cairo-dev pango-dev chromium
+ ENV PORT=$PORT
+ ENV PASSPHRASE=$PASSPHRASE
+ ENV DATABASE_PATH=$DATABASE_PATH
+ ENV APIKEY_PATH=$APIKEY_PATH
+ ENV SECRETKEY_PATH=$SECRETKEY_PATH
+ ENV LOG_PATH=$LOG_PATH
+ RUN mkdir -p $FLOWISE_PATH && chmod -R 777 $FLOWISE_PATH
+ RUN mkdir -p $LOG_PATH && chmod -R 777 $LOG_PATH
+ RUN mkdir -p $FLOWISE_PATH/uploads && chmod -R 777 $FLOWISE_PATH/uploads
+ CMD ["npx", "flowise", "start"]
- RUN apk add --no-cache git
- RUN apk add --no-cache python3 py3-pip make g++
- RUN apk add --no-cache build-base cairo-dev pango-dev
- RUN apk add --no-cache chromium
- CMD "flowise"

Impact

These changes ensure that the project can be run on Hugging Face Spaces, expanding deployment possibilities. By optimizing the Dockerfile, users can now quickly start the application without the need to make corrections to the Dockerfile or even set any environment var. This enhances the user experience and makes the Dockerfile more maintainable and user-friendly.

lucianotonet avatar Aug 04 '23 02:08 lucianotonet

@lucianotonet tried running HF space got this error: image

HenryHengZJ avatar Aug 06 '23 21:08 HenryHengZJ

Hi @HenryHengZJ. Thank you for pointing that out 👍 The Dockerfile has been updated. I tested it on HF Spaces and now it works. You can see here. But, it still needs to set PORT=7860 on Settings > Variables and Secrets. That's very important! Also, I will make sure to update the instructions that I have made on your Docs here accordingly with this one.

lucianotonet avatar Aug 07 '23 00:08 lucianotonet

thanks @lucianotonet it works now! https://huggingface.co/spaces/FlowiseAI/Flowise

Can we make another folder on Flowise like huggingface_space with the 3 files like here?

This is because the Dockerfile inside docker folder is used for docker-compose image. Modifying this file causes docker-compose up -d not working. Prefer to have separate folder just for HF Space

HenryHengZJ avatar Aug 07 '23 13:08 HenryHengZJ

Hi @lucianotonet just wondering if this PR is still relevant/live or if it needs to be adjusted because of changes since last message - it's quite old and if it's been superceded by other changes perhaps it should be closed off here so that the outstanding live PR count can be kept low for better admin engagement? Thanks.

deep-pipeline avatar May 20 '24 11:05 deep-pipeline

Hey @deep-pipeline It requires review and testing, but currently, I lack the time. I will do it as soon as possible.

lucianotonet avatar May 20 '24 20:05 lucianotonet

image

@deep-pipeline I tested and it seems to be working on Hugging Face as expected.

https://huggingface.co/spaces/lucianotonet/Flowise

PS how to work with authentication and private data? Where can I learn about it?

lucianotonet avatar May 21 '24 08:05 lucianotonet