diff --git a/Makefile b/Makefile index 527d350c..3506b49f 100644 --- a/Makefile +++ b/Makefile @@ -11,6 +11,10 @@ export COMPOSE_DOCKER_CLI_BUILD=1 # take it form env, or from env file COMPOSE_PROJECT_NAME ?= $(shell grep COMPOSE_PROJECT_NAME ${ENV_FILE} | cut -d '=' -f 2) +# allows to commands with sudo if needed +# SUDO=sudo make up +SUDO ?= + # load env variables # also takes into account envrc (direnv file) ifneq (,$(wildcard ./${ENV_FILE})) @@ -19,8 +23,9 @@ ifneq (,$(wildcard ./${ENV_FILE})) export endif -DOCKER_COMPOSE=docker compose --env-file=${ENV_FILE} -DOCKER_COMPOSE_TEST=COMPOSE_PROJECT_NAME=search_test docker compose --env-file=${ENV_FILE} +DOCKER = $(SUDO) docker +DOCKER_COMPOSE = $(DOCKER) compose --env-file=${ENV_FILE} +DOCKER_COMPOSE_TEST = $(SUDO) COMPOSE_PROJECT_NAME=search_test $(DOCKER_COMPOSE) .PHONY: build create_external_volumes livecheck up down test test_front test_front_watch test_api import-dataset import-taxonomies sync-scripts build-translations generate-openapi check check_front check_translations lint lint_back lint_front #------------# @@ -35,7 +40,7 @@ create_external_volumes: echo creating docker volume $$vol_name \ # create volume \ # this bind mount a folder, it will happen when volume will be used \ - docker volume create --driver=local "$$vol_name" ; \ + ${DOCKER} volume create --driver=local "$$vol_name" ; \ done; livecheck: @@ -43,7 +48,7 @@ livecheck: exit_code=0; \ services=`${DOCKER_COMPOSE} config --service | tr '\n' ' '`; \ for service in $$services; do \ - if [ -z `docker compose ps -q $$service` ] || [ -z `docker ps -q --no-trunc | grep $$(${DOCKER_COMPOSE} ps -q $$service)` ]; then \ + if [ -z `${DOCKER} compose ps -q $$service` ] || [ -z `${DOCKER} ps -q --no-trunc | grep $$(${DOCKER_COMPOSE} ps -q $$service)` ]; then \ echo "$$service: DOWN"; \ exit_code=1; \ else \ @@ -75,7 +80,7 @@ down: ${DOCKER_COMPOSE} down _ensure_network: - docker network inspect ${COMMON_NET_NAME} >/dev/null || docker network create -d bridge ${COMMON_NET_NAME} + ${DOCKER} network inspect ${COMMON_NET_NAME} >/dev/null || ${DOCKER} network create -d bridge ${COMMON_NET_NAME} #--------# # Checks # diff --git a/docs/users/how-to-install.md b/docs/users/how-to-install.md index 5c0f328f..4d6c6a94 100644 --- a/docs/users/how-to-install.md +++ b/docs/users/how-to-install.md @@ -51,10 +51,17 @@ You should now be able to start docker: docker compose up -d ``` -> [!NOTES] -> * You may encounter a permission error if your user is not part of the `docker` group, in which case you should either [add it](https://docs.docker.com/engine/install/linux-postinstall/#manage-docker-as-a-non-root-user) or modify the Makefile to prefix `sudo` to all docker and docker compose commands. -> * Update container might crash because if you are note connected to any Redis, Search-a-licious will still run. You need to connect to Redis only if you want continuous updates. See [How to update the index](./how-to-update-index.md) - +> [!NOTE] +> You may encounter a permission error if your user is not part of the `docker` group. +> In that case you should set the `SUDO` env variable to `sudo`: +> +> ```console +> export SUDO=sudo +> make build +> ``` + +> [!NOTE] +> Update container might crash because if you are note connected to any Redis, Search-a-licious will still run. You need to connect to Redis only if you want continuous updates. See [How to update the index](./how-to-update-index.md) ## Using it