Skip to content

Commit

Permalink
build(docker): refactor detection of OS and add support for RHEL dist…
Browse files Browse the repository at this point in the history
…ros (#211)

* build(docker): refactor detection of OS

This commit also adds support for RHEL distros

* build(install): use functions for installing dependencies

* feat(install): enhance installation script with Docker Compose version check and refactor package installation

- Refactored the installation script to include a Docker Compose version check, ensuring compatibility with version 2.0.0 or higher.
- Consolidated package installation functions into a generic install_package function to streamline the installation process for various packages like nano, curl, and make.
- Improved error handling and logging for package installations and Docker setup.

* feat(install): enhance Docker and Docker Compose checks in installation script

- Added functions to check Docker and Docker Compose installations, including version checks and guidance for installation or upgrade if necessary.
- Removed automatic installation of Docker and Docker Compose, replacing it with user guidance for manual installation.
- Updated the installation script to ensure Docker is installed and running before proceeding.

* fix: improve Docker installation checks and update Makefile

- Enhanced the Docker installation script to repeatedly prompt the user until a valid choice is made.
- Updated the Makefile to include checks for Docker Compose installation and user permissions, ensuring the user is in the docker group or running as root.

* build(install): move pre-req check after env check

* build(install): specify color meaning and change some

* build(install): provide more specific error information

Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>

* build(make): use `getent`

---------

Co-authored-by: psyray <[email protected]>
Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored Nov 4, 2024
1 parent 9b6d787 commit c839bd2
Show file tree
Hide file tree
Showing 3 changed files with 261 additions and 186 deletions.
22 changes: 15 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,21 @@ COMPOSE_FILE_DEV := docker/docker-compose.dev.yml
COMPOSE_FILE_SETUP := docker/docker-compose.setup.yml
SERVICES := db web proxy redis celery celery-beat ollama

# Check if 'docker compose' command is available, otherwise use 'docker-compose'
DOCKER_COMPOSE := $(shell if command -v docker > /dev/null && docker compose version > /dev/null 2>&1; then echo "docker compose"; else echo "docker-compose"; fi)
$(info Using: $(shell echo "$(DOCKER_COMPOSE)"))
# Check if 'docker compose' command is available, otherwise check for 'docker-compose'
DOCKER_COMPOSE := $(shell if command -v docker > /dev/null && docker compose version > /dev/null 2>&1; then echo "docker compose"; elif command -v docker-compose > /dev/null; then echo "docker-compose"; else echo ""; fi)

ifeq ($(DOCKER_COMPOSE),)
$(error Docker Compose not found. Please install Docker Compose)
endif

# Check if user is in docker group or is root
DOCKER_GROUP_CHECK := $(shell if [ -n "$$(getent group docker)" ]; then echo "yes"; else echo "no"; fi)

ifeq ($(DOCKER_GROUP_CHECK),no)
$(error This command must be run with sudo or by a user in the docker group)
endif

$(info Using: $(DOCKER_COMPOSE))

# Define common commands
DOCKER_COMPOSE_CMD := ${COMPOSE_PREFIX_CMD} ${DOCKER_COMPOSE}
Expand Down Expand Up @@ -150,10 +162,6 @@ help: ## Show this help.
@echo " make <target> (default: help)"
@echo ""
@echo "Targets:"
@awk 'BEGIN {FS = ":.*##"; printf " \033[36m%-15s\033[0m %s\n", "Target", "Description"}' $(MAKEFILE_LIST)
@awk 'BEGIN {FS = ":.*##"} /^[a-zA-Z_-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 }' $(MAKEFILE_LIST)
@echo ""
@echo "Special commands:"
@echo " make restart [service1] [service2] ... Restart specific services in production mode"
@echo " make restart DEV=1 [service1] [service2] ... Restart specific services in development mode"
@echo " make restart Restart all services in production mode"
Expand Down
Loading

0 comments on commit c839bd2

Please sign in to comment.