Skip to content

Commit e38e413

Browse files
chore: fix setup to startup project locally
1 parent 606d199 commit e38e413

File tree

3 files changed

+27
-32
lines changed

3 files changed

+27
-32
lines changed

Makefile

Lines changed: 24 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,25 @@
33
help:
44
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
55

6-
BIN_DOCKER_COMPOSE=docker-compose
7-
8-
compose = ${BIN_DOCKER_COMPOSE} -p permacoop
9-
106
run_server = ./tools/colorize_prefix.sh [server] 31
117
run_watch = ./tools/colorize_prefix.sh [watch] 36
128

9+
DOCKER_COMPOSE=docker compose
10+
1311
install: ## Install
14-
make install-deps
15-
make install-dev
12+
$(MAKE) install-deps
13+
$(MAKE) install-dev
1614

1715
install-deps: ## Install dependencies
1816
npm ci
1917

2018
install-dev: ## Install local development dependencies and services
2119
npx playwright install firefox
22-
make build
23-
make database-test-init
20+
$(MAKE) build
21+
$(MAKE) database-test-init
2422

2523
start: ## Start
26-
make -j 2 start-server start-watch
24+
$(MAKE) -j 2 start-server start-watch
2725

2826
start-server: up
2927
${run_server} "npm run start:dev"
@@ -32,22 +30,22 @@ start-watch:
3230
${run_watch} "npm run assets:watch"
3331

3432
compose: ## Run Docker compose command (args: CMD)
35-
${compose} ${CMD}
33+
${DOCKER_COMPOSE} ${CMD}
3634

3735
up: ## Start containers
38-
make compose CMD="up -d"
36+
${DOCKER_COMPOSE} up -d
3937

4038
stop: ## Stop containers
41-
make compose CMD=stop
39+
${DOCKER_COMPOSE} stop
4240

4341
restart: ## Restart containers
44-
make compose CMD=restart
42+
${DOCKER_COMPOSE} restart
4543

4644
rm: stop ## Stop and remove containers
47-
make compose CMD=rm
45+
${DOCKER_COMPOSE} rm
4846

4947
ps: ## Show running containers
50-
make compose CMD=ps
48+
${DOCKER_COMPOSE} ps
5149

5250
build: dist assets ## Build dist and assets
5351

@@ -82,10 +80,10 @@ database-migrate: ## Database migrations
8280
npm run migration:migrate
8381

8482
database-test-init: up ## Initialize test database
85-
make compose CMD="exec -T database dropdb --if-exists permacoop_test"
86-
make compose CMD="exec -T database createdb permacoop_test"
87-
make database-migrate DATABASE_NAME=permacoop_test
88-
make database-seed DATABASE_NAME=permacoop_test
83+
$(MAKE) compose CMD="exec -T database dropdb --if-exists permacoop_test"
84+
$(MAKE) compose CMD="exec -T database createdb permacoop_test"
85+
$(MAKE) database-migrate DATABASE_NAME=permacoop_test
86+
$(MAKE) database-seed DATABASE_NAME=permacoop_test
8987

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

9694
database-connect: ## Connect to the database container
97-
${compose} exec database psql -h database -d permacoop
95+
${DOCKER_COMPOSE} exec database psql -h database -d permacoop
9896

9997
ci: up ## Run CI checks
100-
make install
101-
make linter
102-
make test-cov
103-
make test-e2e CI=1 DATABASE_NAME=permacoop
98+
$(MAKE) install
99+
$(MAKE) linter
100+
$(MAKE) test-cov
101+
$(MAKE) test-e2e CI=1 DATABASE_NAME=permacoop
104102

105103
scalingo-postbuild:
106-
make build
107-
make database-migrate
104+
$(MAKE) build
105+
$(MAKE) database-migrate

docker-compose.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
1-
version: '3'
2-
31
volumes:
4-
database: {}
2+
database:
53

64
services:
75
database:
8-
image: postgres:12
6+
image: postgres:14.20
97
environment:
108
POSTGRES_USER: docker
119
POSTGRES_PASSWORD: docker

tools/colorize_prefix.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
# Usage: ./colorize_prefix.sh prefix color command
55
# Eg:
66
# ./colorize_prefix.sh [client] 33 "npm run dev"
7-
87
PREFIX_TEXT="$1"
98
COLOR_CODE="$2"
109
COMMAND="$3"
@@ -15,4 +14,4 @@ PREFIX_COLORIZED=$(echo "\033[${COLOR_CODE}m${PREFIX_TEXT}\033[0m")
1514

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

0 commit comments

Comments
 (0)