Merge pull request #50 from Hexastack/feat/loading-remote-images

Feat: Loading docker images from Docker Hub
This commit is contained in:
Mohamed Marrouchi 2024-09-20 18:39:12 +01:00 committed by GitHub
commit f84726a371
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 62 additions and 36 deletions

View File

@ -1,5 +1,4 @@
# Default path setup COMPOSE_FILES := -f ./docker/docker-compose.yml
COMPOSE_FILES := -f ./docker/docker-compose.yml -f ./docker/docker-compose.dev.yml
# Function to add service files # Function to add service files
define add_service define add_service
@ -8,7 +7,7 @@ define add_service
ifneq ($(wildcard ./docker/docker-compose.$(1).prod.yml),) ifneq ($(wildcard ./docker/docker-compose.$(1).prod.yml),)
COMPOSE_FILES += -f ./docker/docker-compose.$(1).prod.yml COMPOSE_FILES += -f ./docker/docker-compose.$(1).prod.yml
endif endif
else else ifeq ($(DEV_MODE), true)
COMPOSE_FILES += -f ./docker/docker-compose.$(1).yml COMPOSE_FILES += -f ./docker/docker-compose.$(1).yml
ifneq ($(wildcard ./docker/docker-compose.$(1).dev.yml),) ifneq ($(wildcard ./docker/docker-compose.$(1).dev.yml),)
COMPOSE_FILES += -f ./docker/docker-compose.$(1).dev.yml COMPOSE_FILES += -f ./docker/docker-compose.$(1).dev.yml
@ -17,18 +16,20 @@ define add_service
endef endef
# Check if services are specified and add corresponding compose files # Function to set up COMPOSE_FILES
ifneq ($(NGINX),) define compose_files
$(eval $(call add_service,nginx)) ifeq ($(1), true)
endif ifneq ($(wildcard ./docker/docker-compose.dev.yml),)
COMPOSE_FILES += -f ./docker/docker-compose.dev.yml
ifneq ($(NLU),) endif
$(eval $(call add_service,nlu)) endif
endif ifneq ($(NGINX),)
$(eval $(call add_service,nginx))
ifneq ($(SMTP4DEV),) endif
$(eval $(call add_service,smtp4dev)) ifneq ($(NLU),)
endif $(eval $(call add_service,nlu))
endif
endef
# Ensure .env file exists and matches .env.example # Ensure .env file exists and matches .env.example
check-env: check-env:
@ -43,16 +44,21 @@ init:
cp ./docker/.env.example ./docker/.env cp ./docker/.env.example ./docker/.env
dev: check-env dev: check-env
$(eval $(call compose_files,true))
docker compose $(COMPOSE_FILES) up -d docker compose $(COMPOSE_FILES) up -d
start: check-env start: check-env
docker compose $(COMPOSE_FILES) up -d --build $(eval $(call compose_files,false))
docker compose $(COMPOSE_FILES) up -d
stop: check-env stop: check-env
$(eval $(call compose_files,true))
docker compose $(COMPOSE_FILES) down docker compose $(COMPOSE_FILES) down
destroy: check-env destroy: check-env
$(eval $(call compose_files,true))
docker compose $(COMPOSE_FILES) down -v docker compose $(COMPOSE_FILES) down -v
migrate-up: migrate-up:
$(eval $(call compose_files,false))
docker-compose $(COMPOSE_FILES) up --no-deps -d database-init docker-compose $(COMPOSE_FILES) up --no-deps -d database-init

View File

@ -1,4 +1,5 @@
# Hexabot # Hexabot
![App Screenshot](https://www.hexabot.ai/assets/images/screencast.gif) ![App Screenshot](https://www.hexabot.ai/assets/images/screencast.gif)
## Description ## Description
@ -20,6 +21,7 @@
- **Inbox & Handover:** Provides a real-time chat window where conversations can be monitored and handed over to human agents when necessary. - **Inbox & Handover:** Provides a real-time chat window where conversations can be monitored and handed over to human agents when necessary.
## Directory Structure ## Directory Structure
- **frontend:** The admin panel built with React/Next.js for managing chatbot configurations and flows. - **frontend:** The admin panel built with React/Next.js for managing chatbot configurations and flows.
- **api:** The backend API built with NestJS and connected to MongoDB for data storage and management. - **api:** The backend API built with NestJS and connected to MongoDB for data storage and management.
- **widget:** A React-based live chat widget that can be embedded into any website to provide real-time interaction. - **widget:** A React-based live chat widget that can be embedded into any website to provide real-time interaction.
@ -27,6 +29,7 @@
- **docker:** A set of Docker Compose files for deploying the entire solution, making it easy to run Hexabot in any environment. - **docker:** A set of Docker Compose files for deploying the entire solution, making it easy to run Hexabot in any environment.
## Prerequisites ## Prerequisites
To ensure Hexabot runs smoothly, you'll need the following: To ensure Hexabot runs smoothly, you'll need the following:
- **Docker:** We recommend using Docker to start the app since multiple services are required (MongoDB, Redis, Prometheus, etc.). All the necessary Docker Compose files are located in the docker folder. - **Docker:** We recommend using Docker to start the app since multiple services are required (MongoDB, Redis, Prometheus, etc.). All the necessary Docker Compose files are located in the docker folder.
@ -35,28 +38,37 @@ To ensure Hexabot runs smoothly, you'll need the following:
## Installation ## Installation
1. **Clone the Repository:** 1. **Clone the Repository:**
```bash ```bash
$ git clone https://github.com/hexastack/hexabot.git $ git clone https://github.com/hexastack/hexabot.git
``` ```
2. **Environment Setup:** To configure the environment variables, use the Makefile at the root folder for initialization: 2. **Environment Setup:** To configure the environment variables, use the Makefile at the root folder for initialization:
```bash ```bash
$ make init $ make init
``` ```
This will copy the `.env.example` file to `.env` in the `./docker` directory if the file does not already exist. This will copy the `.env.example` file to `.env` in the `./docker` directory if the file does not already exist.
3. **Running the Application:** Once your environment is set up, you can start the app. Use either of the following commands: 3. **Running the Application:** Once your environment is set up, you can start the app. Use either of the following commands:
```bash ```bash
$ make start $ make start
``` ```
or for development mode: or for development mode:
```bash ```bash
$ make dev $ make dev
``` ```
**Note:** The first time you run the app, Docker will take some time to download all the required images. **Note:** The first time you run the app, Docker will take some time to download all the required images.
## Usage ## Usage
UI Admin Panel is accessible via http://localhost:8080, the default credentials are : UI Admin Panel is accessible via http://localhost:8080, the default credentials are :
- **Username:** admin@admin.admin - **Username:** admin@admin.admin
- **Password:** adminadmin - **Password:** adminadmin
@ -65,18 +77,20 @@ Live Chat Widget is accessible via http://localhost:5173
## Commands ## Commands
- `make init` : Copies the .env.example file to .env in the ./docker directory if .env does not exist. This is usually used for initial setup. - `make init` : Copies the .env.example file to .env in the ./docker directory if .env does not exist. This is usually used for initial setup.
- `make dev` : Starts all configured Docker services in development mode. It first checks the .env file for completeness against .env.example. - `make dev` : Starts all configured Docker services in development mode. It first checks the .env file for completeness against .env.example and builds the docker images locally.
- `make start` : Similar to dev, but explicitly builds the Docker images before starting the services. This target also checks the .env file for required variables. - `make start` : Starts all configured Docker services by loading all images from Docker Hub. This target also checks the .env file for required variables.
- `make stop` : Stops all running Docker services defined in the compose files. - `make stop` : Stops all running Docker services defined in the compose files.
- `make destroy` : Stops all services and removes all volumes associated with the Docker compose setup, ensuring a clean state. - `make destroy` : Stops all services and removes all volumes associated with the Docker compose setup, ensuring a clean state.
- `make check-env` : Checks if the ./docker/.env file exists and contains all the necessary environment variables as defined in ./docker/.env.example. If the file does not exist, it is created from the example. It also lists missing variables if any. - `make check-env` : Checks if the ./docker/.env file exists and contains all the necessary environment variables as defined in ./docker/.env.example. If the file does not exist, it is created from the example. It also lists missing variables if any.
Example on how to start the stack by adding the Nginx service : Example on how to start the stack by adding the Nginx service :
```sh ```sh
make start NGINX=1 make start NGINX=1
``` ```
## Documentation ## Documentation
For detailed information on how to get started, as well as in-depth user and developer guides, please refer to our full documentation available in the docs folder or visit the [Documentation](https://docs.hexabot.ai). For detailed information on how to get started, as well as in-depth user and developer guides, please refer to our full documentation available in the docs folder or visit the [Documentation](https://docs.hexabot.ai).
You can also find specific documentation for different components of the project in the following locations: You can also find specific documentation for different components of the project in the following locations:
@ -87,15 +101,16 @@ You can also find specific documentation for different components of the project
- [NLU Engine Documentation](nlu/README.md) - [NLU Engine Documentation](nlu/README.md)
## Contributing ## Contributing
We welcome contributions from the community! Whether you want to report a bug, suggest new features, or submit a pull request, your input is valuable to us. We welcome contributions from the community! Whether you want to report a bug, suggest new features, or submit a pull request, your input is valuable to us.
Please refer to our contribution policy first : [How to contribute to Hexabot](./CONTRIBUTING.md) Please refer to our contribution policy first : [How to contribute to Hexabot](./CONTRIBUTING.md)
[![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-2.1-4baaaa.svg)](./CODE_OF_CONDUCT.md) [![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-2.1-4baaaa.svg)](./CODE_OF_CONDUCT.md)
Feel free to join us on [Discord](https://discord.gg/rNb9t2MFkG) Feel free to join us on [Discord](https://discord.gg/rNb9t2MFkG)
## License ## License
This software is licensed under the GNU Affero General Public License v3.0 (AGPLv3) with the following additional terms: This software is licensed under the GNU Affero General Public License v3.0 (AGPLv3) with the following additional terms:
1. The name "Hexabot" is a trademark of Hexastack. You may not use this name in derivative works without express written permission. 1. The name "Hexabot" is a trademark of Hexastack. You may not use this name in derivative works without express written permission.

View File

@ -2,12 +2,16 @@ version: "3.8"
services: services:
database-init: database-init:
build:
context: ../api
volumes: volumes:
- ../api/src:/app/src - ../api/src:/app/src
- ../api/migrations:/app/migrations - ../api/migrations:/app/migrations
# - ../api/node_modules:/app/node_modules # - ../api/node_modules:/app/node_modules
api: api:
build:
context: ../api
ports: ports:
- ${API_PORT}:3000 - ${API_PORT}:3000
- 9229:9229 # vscode debug port - 9229:9229 # vscode debug port
@ -35,8 +39,15 @@ services:
ME_CONFIG_MONGODB_ADMINPASSWORD: ${MONGO_PASSWORD} ME_CONFIG_MONGODB_ADMINPASSWORD: ${MONGO_PASSWORD}
ME_CONFIG_MONGODB_URL: ${MONGO_URI} ME_CONFIG_MONGODB_URL: ${MONGO_URI}
hexabot-frontend:
container_name: frontend
build:
context: ../
dockerfile: ./frontend/Dockerfile
widget: widget:
build: build:
context: ../widget
target: development target: development
volumes: volumes:
- ../widget/src:/app/src - ../widget/src:/app/src

View File

@ -2,5 +2,8 @@ version: "3.9"
services: services:
nlu-api: nlu-api:
build:
context: ../nlu
dockerfile: Dockerfile
ports: ports:
- ${NLP_PORT}:5000 - ${NLP_PORT}:5000

View File

@ -10,9 +10,7 @@ services:
nlu-api: nlu-api:
container_name: nlu-api container_name: nlu-api
build: image: hexabot-nlu:latest
context: ../nlu
dockerfile: Dockerfile
env_file: .env env_file: .env
networks: networks:
- nlp-network - nlp-network

View File

@ -3,8 +3,7 @@ version: "3.9"
services: services:
database-init: database-init:
container_name: database-init container_name: database-init
build: image: hexabot-api:latest
context: ../api
command: sh -c "npm run cache:init && npm run migrate prune && npm run migrate up" command: sh -c "npm run cache:init && npm run migrate prune && npm run migrate up"
env_file: .env env_file: .env
networks: networks:
@ -15,8 +14,7 @@ services:
api: api:
container_name: api container_name: api
build: image: hexabot-api:latest
context: ../api
env_file: .env env_file: .env
ports: ports:
- ${API_PORT}:3000 - ${API_PORT}:3000
@ -69,12 +67,7 @@ services:
widget: widget:
container_name: widget container_name: widget
build: image: hexabot-widget:latest
context: ../widget
args:
REACT_APP_WIDGET_API_URL: ${REACT_APP_WIDGET_API_URL}
REACT_APP_WIDGET_CHANNEL: ${REACT_APP_WIDGET_CHANNEL}
REACT_APP_WIDGET_TOKEN: ${REACT_APP_WIDGET_TOKEN}
networks: networks:
- app-network - app-network
depends_on: depends_on: