Skip to content

Commit

Permalink
Merge pull request #1161 from yogeshojha/1135-feat-remove-installatio…
Browse files Browse the repository at this point in the history
…n-of-deprecated-docker-compose

ops(docker): use Docker Compose V2 commands
  • Loading branch information
yogeshojha committed Mar 5, 2024
2 parents ea3c53f + f65d429 commit 061ced8
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 35 deletions.
34 changes: 17 additions & 17 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,61 +14,61 @@ SERVICES := db web proxy redis celery celery-beat
.PHONY: setup certs up build username pull down stop restart rm logs

certs: ## Generate certificates.
@${COMPOSE_PREFIX_CMD} docker-compose -f docker-compose.setup.yml run --rm certs
@${COMPOSE_PREFIX_CMD} docker compose -f docker-compose.setup.yml run --rm certs

setup: ## Generate certificates.
@make certs

up: ## Build and start all services.
${COMPOSE_PREFIX_CMD} docker-compose ${COMPOSE_ALL_FILES} up -d --build ${SERVICES}
${COMPOSE_PREFIX_CMD} docker compose ${COMPOSE_ALL_FILES} up -d --build ${SERVICES}

build: ## Build all services.
${COMPOSE_PREFIX_CMD} docker-compose ${COMPOSE_ALL_FILES} build ${SERVICES}
${COMPOSE_PREFIX_CMD} docker compose ${COMPOSE_ALL_FILES} build ${SERVICES}

username: ## Generate Username (Use only after make up).
ifeq ($(isNonInteractive), true)
${COMPOSE_PREFIX_CMD} docker-compose ${COMPOSE_ALL_FILES} exec web python3 manage.py createsuperuser --username ${DJANGO_SUPERUSER_USERNAME} --email ${DJANGO_SUPERUSER_EMAIL} --noinput
${COMPOSE_PREFIX_CMD} docker compose ${COMPOSE_ALL_FILES} exec web python3 manage.py createsuperuser --username ${DJANGO_SUPERUSER_USERNAME} --email ${DJANGO_SUPERUSER_EMAIL} --noinput
else
${COMPOSE_PREFIX_CMD} docker-compose ${COMPOSE_ALL_FILES} exec web python3 manage.py createsuperuser
${COMPOSE_PREFIX_CMD} docker compose ${COMPOSE_ALL_FILES} exec web python3 manage.py createsuperuser
endif

migrate: ## Apply migrations
${COMPOSE_PREFIX_CMD} docker-compose ${COMPOSE_ALL_FILES} exec web python3 manage.py migrate
${COMPOSE_PREFIX_CMD} docker compose ${COMPOSE_ALL_FILES} exec web python3 manage.py migrate

changepassword: ## Change password for user
${COMPOSE_PREFIX_CMD} docker-compose ${COMPOSE_ALL_FILES} exec web python3 manage.py changepassword
${COMPOSE_PREFIX_CMD} docker compose ${COMPOSE_ALL_FILES} exec web python3 manage.py changepassword

migrate: ## Apply migrations
${COMPOSE_PREFIX_CMD} docker-compose ${COMPOSE_ALL_FILES} exec web python3 manage.py migrate
${COMPOSE_PREFIX_CMD} docker compose ${COMPOSE_ALL_FILES} exec web python3 manage.py migrate

pull: ## Pull Docker images.
docker login docker.pkg.github.com
${COMPOSE_PREFIX_CMD} docker-compose ${COMPOSE_ALL_FILES} pull
${COMPOSE_PREFIX_CMD} docker compose ${COMPOSE_ALL_FILES} pull

down: ## Down all services.
${COMPOSE_PREFIX_CMD} docker-compose ${COMPOSE_ALL_FILES} down
${COMPOSE_PREFIX_CMD} docker compose ${COMPOSE_ALL_FILES} down

stop: ## Stop all services.
${COMPOSE_PREFIX_CMD} docker-compose ${COMPOSE_ALL_FILES} stop ${SERVICES}
${COMPOSE_PREFIX_CMD} docker compose ${COMPOSE_ALL_FILES} stop ${SERVICES}

restart: ## Restart all services.
${COMPOSE_PREFIX_CMD} docker-compose ${COMPOSE_ALL_FILES} restart ${SERVICES}
${COMPOSE_PREFIX_CMD} docker compose ${COMPOSE_ALL_FILES} restart ${SERVICES}

rm: ## Remove all services containers.
${COMPOSE_PREFIX_CMD} docker-compose $(COMPOSE_ALL_FILES) rm -f ${SERVICES}
${COMPOSE_PREFIX_CMD} docker compose $(COMPOSE_ALL_FILES) rm -f ${SERVICES}

test:
${COMPOSE_PREFIX_CMD} docker-compose $(COMPOSE_ALL_FILES) exec celery python3 -m unittest tests/test_scan.py
${COMPOSE_PREFIX_CMD} docker compose $(COMPOSE_ALL_FILES) exec celery python3 -m unittest tests/test_scan.py

logs: ## Tail all logs with -n 1000.
${COMPOSE_PREFIX_CMD} docker-compose $(COMPOSE_ALL_FILES) logs --follow --tail=1000 ${SERVICES}
${COMPOSE_PREFIX_CMD} docker compose $(COMPOSE_ALL_FILES) logs --follow --tail=1000 ${SERVICES}

images: ## Show all Docker images.
${COMPOSE_PREFIX_CMD} docker-compose $(COMPOSE_ALL_FILES) images ${SERVICES}
${COMPOSE_PREFIX_CMD} docker compose $(COMPOSE_ALL_FILES) images ${SERVICES}

prune: ## Remove containers and delete volume data.
@make stop && make rm && docker volume prune -f

help: ## Show this help.
@echo "Make application docker images and manage containers using docker-compose files."
@echo "Make application Docker images and manage containers using Docker Compose files."
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m (default: help)\n\nTargets:\n"} /^[a-zA-Z_-]+:.*?##/ { printf " \033[36m%-12s\033[0m %s\n", $$1, $$2 }' $(MAKEFILE_LIST)
6 changes: 3 additions & 3 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -88,15 +88,15 @@ fi
echo " "
tput setaf 4;
echo "#########################################################################"
echo "Installing docker compose"
echo "Installing Docker Compose"
echo "#########################################################################"
if [ -x "$(command -v docker compose)" ]; then
tput setaf 2; echo "docker compose already installed, skipping."
tput setaf 2; echo "Docker Compose already installed, skipping."
else
curl -L "https://github.com/docker/compose/releases/download/v2.24.6/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
tput setaf 2; echo "docker compose installed!!!"
tput setaf 2; echo "Docker Compose installed!!!"
fi


Expand Down
30 changes: 15 additions & 15 deletions make.bat
Original file line number Diff line number Diff line change
Expand Up @@ -6,34 +6,34 @@ set COMPOSE_ALL_FILES = -f docker-compose.yml
set SERVICES = db web proxy redis celery celery-beat

:: Generate certificates.
if "%1" == "certs" docker-compose -f docker-compose.setup.yml run --rm certs
if "%1" == "certs" docker compose -f docker-compose.setup.yml run --rm certs
:: Generate certificates.
if "%1" == "setup" docker-compose -f docker-compose.setup.yml run --rm certs
if "%1" == "setup" docker compose -f docker-compose.setup.yml run --rm certs
:: Build and start all services.
if "%1" == "up" docker-compose %COMPOSE_ALL_FILES% up -d --build %SERVICES%
if "%1" == "up" docker compose %COMPOSE_ALL_FILES% up -d --build %SERVICES%
:: Build all services.
if "%1" == "build" docker-compose %COMPOSE_ALL_FILES% build %SERVICES%
if "%1" == "build" docker compose %COMPOSE_ALL_FILES% build %SERVICES%
:: Generate Username (use only after make up).
if "%1" == "username" docker-compose %COMPOSE_ALL_FILES% exec web python3 manage.py createsuperuser
if "%1" == "username" docker compose %COMPOSE_ALL_FILES% exec web python3 manage.py createsuperuser
:: Change password for user
if "%1" == "changepassword" docker-compose %COMPOSE_ALL_FILES% exec web python3 manage.py changepassword
if "%1" == "changepassword" docker compose %COMPOSE_ALL_FILES% exec web python3 manage.py changepassword
:: Apply migrations
if "%1" == "migrate" docker-compose %COMPOSE_ALL_FILES% exec web python3 manage.py migrate
if "%1" == "migrate" docker compose %COMPOSE_ALL_FILES% exec web python3 manage.py migrate
:: Pull Docker images.
if "%1" == "pull" docker login docker.pkg.github.com & docker-compose %COMPOSE_ALL_FILES% pull
:: Down all services.
if "%1" == "down" docker-compose %COMPOSE_ALL_FILES% down
if "%1" == "down" docker compose %COMPOSE_ALL_FILES% down
:: Stop all services.
if "%1" == "stop" docker-compose %COMPOSE_ALL_FILES% stop %SERVICES%
if "%1" == "stop" docker compose %COMPOSE_ALL_FILES% stop %SERVICES%
:: Restart all services.
if "%1" == "restart" docker-compose %COMPOSE_ALL_FILES% restart %SERVICES%
if "%1" == "restart" docker compose %COMPOSE_ALL_FILES% restart %SERVICES%
:: Remove all services containers.
if "%1" == "rm" docker-compose %COMPOSE_ALL_FILES% rm -f %SERVICES%
if "%1" == "rm" docker compose %COMPOSE_ALL_FILES% rm -f %SERVICES%
:: Tail all logs with -n 1000.
if "%1" == "logs" docker-compose %COMPOSE_ALL_FILES% logs --follow --tail=1000 %SERVICES%
if "%1" == "logs" docker compose %COMPOSE_ALL_FILES% logs --follow --tail=1000 %SERVICES%
:: Show all Docker images.
if "%1" == "images" docker-compose %COMPOSE_ALL_FILES% images %SERVICES%
if "%1" == "images" docker compose %COMPOSE_ALL_FILES% images %SERVICES%
:: Remove containers and delete volume data.
if "%1" == "prune" docker-compose %COMPOSE_ALL_FILES% stop %SERVICES% & docker-compose %COMPOSE_ALL_FILES% rm -f %SERVICES% & docker volume prune -f
if "%1" == "prune" docker compose %COMPOSE_ALL_FILES% stop %SERVICES% & docker-compose %COMPOSE_ALL_FILES% rm -f %SERVICES% & docker volume prune -f
:: Show this help.
if "%1" == "help" @echo Make application docker images and manage containers using docker-compose files only for windows.
if "%1" == "help" @echo Make application Docker images and manage containers using Docker Compose files only for windows.

0 comments on commit 061ced8

Please sign in to comment.