Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dockerfile fix to run on Hugging Face #690

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

lucianotonet
Copy link

No description provided.

@HenryHengZJ
Copy link
Contributor

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

Refactored Dockerfile to fix permission errors with dynamic paths
@lucianotonet
Copy link
Author

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.

@HenryHengZJ
Copy link
Contributor

@lucianotonet tried running HF space got this error:
image

Fix and optimization
@lucianotonet
Copy link
Author

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 added a commit to lucianotonet/FlowiseDocs that referenced this pull request Aug 7, 2023
@HenryHengZJ
Copy link
Contributor

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

@deep-pipeline
Copy link

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.

@lucianotonet
Copy link
Author

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

@lucianotonet
Copy link
Author

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants