feat: loading all images from docker hub option

This commit is contained in:
Yassine Sallemi 2024-09-20 18:28:55 +01:00
parent 165fcbde64
commit 509dc2381b
5 changed files with 42 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

@ -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
@ -30,8 +34,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
@ -40,12 +38,7 @@ services:
hexabot-frontend: hexabot-frontend:
container_name: frontend container_name: frontend
build: image: hexabot-ui:latest
context: ../
dockerfile: ./frontend/Dockerfile
args:
- NEXT_PUBLIC_API_ORIGIN=${NEXT_PUBLIC_API_ORIGIN}
- NEXT_PUBLIC_SSO_ENABLED=${NEXT_PUBLIC_SSO_ENABLED}
env_file: .env env_file: .env
ports: ports:
- ${APP_FRONTEND_PORT}:8080 - ${APP_FRONTEND_PORT}:8080
@ -75,12 +68,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: