Skip to content

Commit

Permalink
chore: add Makefile to simplify dev operations
Browse files Browse the repository at this point in the history
  • Loading branch information
hbollon committed Jul 18, 2024
1 parent 6d158b9 commit f7d4a31
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 2 deletions.
34 changes: 34 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
VERSION ?= $(shell git describe --always --tags)
DOCKER_TAG ?= latest

export DOCKER_BUILDKIT=1

.PHONY: build
build: ## Build docker image
docker build --tag=camptocamp/geoshop-api:$(VERSION) \
--build-arg=VERSION=$(VERSION) .
docker tag camptocamp/geoshop-api:$(VERSION) camptocamp/geoshop-api:$(DOCKER_TAG)

.PHONY: test
test: ## Run tests
docker compose exec -T api python manage.py test -v 2 --force-color --noinput

.PHONY: prepare_env
prepare_env: destroy_env build ## Prepare Docker environment
docker compose up -d
until [ "$$(docker inspect -f '{{.State.Health.Status}}' geoshop-back-api-1)" = "healthy" ]; do \
echo "Waiting for api..."; \
sleep 1; \
done;

.PHONY: destroy_env
destroy_env: ## Destroy Docker environment
docker compose down --remove-orphans

.PHONY: help
help: ## Display this help
@echo "Usage: make <target>"
@echo
@echo "Available targets:"
@grep --extended-regexp --no-filename '^[a-zA-Z_-]+:.*## ' $(MAKEFILE_LIST) | sort | \
awk 'BEGIN {FS = ":.*?## "}; {printf " %-20s%s\n", $$1, $$2}'
13 changes: 11 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ services:
retries: 5

migrate:
image: geoshop-api
image: camptocamp/geoshop-api
build:
context: .
dockerfile: Dockerfile
Expand All @@ -49,7 +49,7 @@ services:
- geoshop

api:
image: geoshop-api
image: camptocamp/geoshop-api
depends_on:
db:
condition: service_healthy
Expand All @@ -60,6 +60,15 @@ services:
PGHOST: "db"
command: "gunicorn wsgi -b :8000 --timeout 90"
restart: unless-stopped
healthcheck:
test:
[
"CMD-SHELL",
"curl -f http://127.0.0.1:8000/health/readiness || exit 1",
]
interval: 10s
timeout: 5s
retries: 5
volumes:
- "static-files:/app/geoshop_back/static:ro"
ports:
Expand Down

0 comments on commit f7d4a31

Please sign in to comment.