Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 24 additions & 26 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,25 @@
help:
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'

BIN_DOCKER_COMPOSE=docker-compose

compose = ${BIN_DOCKER_COMPOSE} -p permacoop

run_server = ./tools/colorize_prefix.sh [server] 31
run_watch = ./tools/colorize_prefix.sh [watch] 36

DOCKER_COMPOSE=docker compose

install: ## Install
make install-deps
make install-dev
$(MAKE) install-deps
$(MAKE) install-dev

install-deps: ## Install dependencies
npm ci

install-dev: ## Install local development dependencies and services
npx playwright install firefox
make build
make database-test-init
$(MAKE) build
$(MAKE) database-test-init

start: ## Start
make -j 2 start-server start-watch
$(MAKE) -j 2 start-server start-watch

start-server: up
${run_server} "npm run start:dev"
Expand All @@ -32,22 +30,22 @@ start-watch:
${run_watch} "npm run assets:watch"

compose: ## Run Docker compose command (args: CMD)
${compose} ${CMD}
${DOCKER_COMPOSE} ${CMD}

up: ## Start containers
make compose CMD="up -d"
${DOCKER_COMPOSE} up -d

stop: ## Stop containers
make compose CMD=stop
${DOCKER_COMPOSE} stop

restart: ## Restart containers
make compose CMD=restart
${DOCKER_COMPOSE} restart

rm: stop ## Stop and remove containers
make compose CMD=rm
${DOCKER_COMPOSE} rm

ps: ## Show running containers
make compose CMD=ps
${DOCKER_COMPOSE} ps

build: dist assets ## Build dist and assets

Expand Down Expand Up @@ -82,10 +80,10 @@ database-migrate: ## Database migrations
npm run migration:migrate

database-test-init: up ## Initialize test database
make compose CMD="exec -T database dropdb --if-exists permacoop_test"
make compose CMD="exec -T database createdb permacoop_test"
make database-migrate DATABASE_NAME=permacoop_test
make database-seed DATABASE_NAME=permacoop_test
$(MAKE) compose CMD="exec -T database dropdb --if-exists permacoop_test"
$(MAKE) compose CMD="exec -T database createdb permacoop_test"
$(MAKE) database-migrate DATABASE_NAME=permacoop_test
$(MAKE) database-seed DATABASE_NAME=permacoop_test

database-migration: ## Generate a database migration
npm run migration:generate -- migrations/$(NAME)
Expand All @@ -94,14 +92,14 @@ database-seed: ## Seed database
npm run seed:run

database-connect: ## Connect to the database container
${compose} exec database psql -h database -d permacoop
${DOCKER_COMPOSE} exec database psql -h database -d permacoop

ci: up ## Run CI checks
make install
make linter
make test-cov
make test-e2e CI=1 DATABASE_NAME=permacoop
$(MAKE) install
$(MAKE) linter
$(MAKE) test-cov
$(MAKE) test-e2e CI=1 DATABASE_NAME=permacoop

scalingo-postbuild:
make build
make database-migrate
$(MAKE) build
$(MAKE) database-migrate
6 changes: 2 additions & 4 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
version: '3'

volumes:
database: {}
database:

services:
database:
image: postgres:12
image: postgres:14.20
environment:
POSTGRES_USER: docker
POSTGRES_PASSWORD: docker
Expand Down
3 changes: 1 addition & 2 deletions tools/colorize_prefix.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
# Usage: ./colorize_prefix.sh prefix color command
# Eg:
# ./colorize_prefix.sh [client] 33 "npm run dev"

PREFIX_TEXT="$1"
COLOR_CODE="$2"
COMMAND="$3"
Expand All @@ -15,4 +14,4 @@ PREFIX_COLORIZED=$(echo "\033[${COLOR_CODE}m${PREFIX_TEXT}\033[0m")

# script ... preserves color output
# See: https://stackoverflow.com/a/3515296
script -q /dev/null bash -c "${COMMAND}" | sed -u "s/^/${PREFIX_COLORIZED} /"
script --quiet --return /dev/null --command "bash -c \"${COMMAND}\"" | sed -u "s/^/${PREFIX_COLORIZED} /"