diff --git a/.env-example b/.env-example new file mode 100644 index 00000000..c5e840e2 --- /dev/null +++ b/.env-example @@ -0,0 +1,7 @@ +DOCKER_PREFIX=openui +CONTAINER_NAME=openui + +# Ports +BACKEND_OPENUI_PORT=9000 +OLLAMA_OPENUI_PORT=11434 +OPENAPI_KEY=YOUR_OPENAPI_KEY diff --git a/.gitignore b/.gitignore index acd2382d..f51cb8ec 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ .DS_Store -nohup.out \ No newline at end of file +nohup.out +.env diff --git a/Makefile b/Makefile new file mode 100644 index 00000000..12289cbb --- /dev/null +++ b/Makefile @@ -0,0 +1,67 @@ +.PHONY: network remove-network list-network start stop destroy volume build list link exe composer bun bun-upgrade bun-update + +COMPOSE =sudo docker-compose +DOCKER = sudo docker +# Load .env file +DOCKER_PREFIX:= $(shell grep -E '^DOCKER_PREFIX' .env | cut -d '=' -f 2) +CONTAINER_NAME:= $(shell grep -E '^CONTAINER_NAME' .env | cut -d '=' -f 2) +BACKEND_OPENUI_PORT:= $(shell grep -E '^BACKEND_OPENUI_PORT' .env | cut -d '=' -f 2) +OLLAMA_OPENUI_PORT:= $(shell grep -E '^OLLAMA_OPENUI_PORT' .env | cut -d '=' -f 2) + +# /* +# |-------------------------------------------------------------------------- +# | docker cmds +# |-------------------------------------------------------------------------- +# */ +start: + @$(COMPOSE) up -d + +stop: + @$(COMPOSE) down + +destroy: + @$(COMPOSE) rm -v -s -f + +volume: + @$(DOCKER) volume ls + +build: + @$(COMPOSE) build + +list: + @$(COMPOSE) ps -a + +prune: + @$(DOCKER) system prune -a + +# /* +# |-------------------------------------------------------------------------- +# | Utility cmds +# |-------------------------------------------------------------------------- +# */ +link: + @echo "Creating URLs for services with '$(DOCKER_PREFIX)_' prefix..." + @SERVER_IP=$$(hostname -I | cut -d' ' -f1); \ + echo "http://$$SERVER_IP:$(BACKEND_OPENUI_PORT)"; \ + echo "http://$$SERVER_IP:$(OLLAMA_OPENUI_PORT)"; + + +exe-backend: + @$(DOCKER) exec -it ${DOCKER_PREFIX}_${CONTAINER_NAME}_OPENUI_BACKEND /bin/bash + +exe-ollama: + @$(DOCKER) exec -it ${DOCKER_PREFIX}_${CONTAINER_NAME}_OPENUI_BACKEND /bin/bash + +# Commands and their descriptions +help: + @echo "Available commands:" + @echo " make start - Starts the services" + @echo " make stop - Stops the services" + @echo " make destroy - Removes containers and volumes" + @echo " make volume - Lists Docker volumes" + @echo " make build - Builds the Docker containers" + @echo " make list - Lists all Docker containers" + @echo " make link - Creates URLs for services" + @echo " make exe-backend - Executes a bash shell in the backend container" + @echo " make exe-ollama - Executes a bash shell in the ollama container" + @echo " make help - Displays this help message" diff --git a/docker-compose.yaml b/docker-compose.yaml index 47b8cc41..5a096696 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -2,23 +2,24 @@ version: '3.8' services: ollama: + container_name: ${DOCKER_PREFIX}_${CONTAINER_NAME}_OPENI_OLLAMA image: ollama/ollama:latest ports: - - "11434:11434" + - ${OLLAMA_OPENUI_PORT}:11434 volumes: - ${OLLAMA_VOLUME_PATH:-ollama}:/root/.ollama backend: + container_name: ${DOCKER_PREFIX}_${CONTAINER_NAME}_OPENUI_BACKEND build: context: ./backend dockerfile: Dockerfile ports: - - "7878:7878" + - ${BACKEND_OPENUI_PORT}:7878 environment: - - OLLAMA_HOST=http://ollama:11434 - # Just remove `=xxx` to have the env variable passed forward - - OPENAI_API_KEY=xxx + - OLLAMA_HOST=ollama + - OPENAI_API_KEY=${OPENAPI_KEY} depends_on: - ollama volumes: - ollama: \ No newline at end of file + ollama: