From 626e1b29f828a7ff4fe1dd73a8b85b0be5929cfc Mon Sep 17 00:00:00 2001 From: Henry Date: Sat, 27 May 2023 14:32:41 +0100 Subject: [PATCH] add authrorization to npx and docker installation --- Dockerfile | 5 +++++ README.md | 14 ++++++++++++++ docker/.env.example | 4 +++- docker/README.md | 24 ++++++++++++++++++++++++ packages/server/src/commands/start.ts | 10 +++++++++- 5 files changed, 55 insertions(+), 2 deletions(-) create mode 100644 docker/README.md diff --git a/Dockerfile b/Dockerfile index a8a4c69a175..8d4518ea81c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,12 @@ # Build local monorepo image # docker build --no-cache -t flowise . + # Run image # docker run -d -p 3000:3000 flowise + +# Run image with authorization +# docker run -d -e USERNAME=user -e PASSWORD=1234 -p 3000:3000 flowise + FROM node:18-alpine RUN apk add --update libc6-compat diff --git a/README.md b/README.md index 74b04b2dec9..067a6de910a 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,12 @@ Drag & drop UI to build your customized LLM flow using [LangchainJS](https://git npx flowise start ``` + With username & password + + ```bash + npx flowise start --USERNAME=user --PASSWORD=1234 + ``` + 3. Open [http://localhost:3000](http://localhost:3000) ## 🐳 Docker @@ -38,9 +44,17 @@ Drag & drop UI to build your customized LLM flow using [LangchainJS](https://git docker build --no-cache -t flowise . ``` 2. Run image: + ```bash docker run -d --name flowise -p 3000:3000 flowise ``` + + With username & password + + ```bash + docker run -d -e USERNAME=user -e PASSWORD=1234 --name flowise -p 3000:3000 flowise + ``` + 3. Stop image: ```bash docker stop flowise diff --git a/docker/.env.example b/docker/.env.example index c0c68b1ca04..2f0e5571a0e 100644 --- a/docker/.env.example +++ b/docker/.env.example @@ -1 +1,3 @@ -PORT=3000 \ No newline at end of file +PORT=3000 +USERNAME=user +PASSWORD=1234 \ No newline at end of file diff --git a/docker/README.md b/docker/README.md new file mode 100644 index 00000000000..57f747d3799 --- /dev/null +++ b/docker/README.md @@ -0,0 +1,24 @@ +# Flowise Docker Hub Image + +Starts Flowise from [DockerHub Image](https://hub.docker.com/repository/docker/flowiseai/flowise/general) + +## Usage + +1. Create `.env` file and specify the `PORT` (refer to `.env.example`) +2. `docker-compose up -d` +3. Open [http://localhost:3000](http://localhost:3000) +4. You can bring the containers down by `docker-compose stop` + +## With Authrorization + +1. Create `.env` file and specify the `PORT`, `USERNAME`, and `PASSWORD` (refer to `.env.example`) +2. Pass `USERNAME` and `PASSWORD` to the `docker-compose.yml` file: + ``` + environment: + - PORT=${PORT} + - USERNAME=${USERNAME} + - PASSWORD=${PASSWORD} + ``` +3. `docker-compose up -d` +4. Open [http://localhost:3000](http://localhost:3000) +5. You can bring the containers down by `docker-compose stop` diff --git a/packages/server/src/commands/start.ts b/packages/server/src/commands/start.ts index 9c9e5591dd3..96456f26598 100644 --- a/packages/server/src/commands/start.ts +++ b/packages/server/src/commands/start.ts @@ -1,4 +1,4 @@ -import { Command } from '@oclif/core' +import { Command, Flags } from '@oclif/core' import path from 'path' import * as Server from '../index' import * as DataSource from '../DataSource' @@ -14,6 +14,10 @@ let processExitCode = EXIT_CODE.SUCCESS export default class Start extends Command { static args = [] + static flags = { + USERNAME: Flags.string(), + PASSWORD: Flags.string() + } async stopProcess() { console.info('Shutting down Flowise...') @@ -43,6 +47,10 @@ export default class Start extends Command { console.error('uncaughtException: ', err) }) + const { flags } = await this.parse(Start) + if (flags.USERNAME) process.env.USERNAME = flags.USERNAME + if (flags.PASSWORD) process.env.PASSWORD = flags.PASSWORD + await (async () => { try { this.log('Starting Flowise...')