Skip to content

Commit 988666b

Browse files
committed
Adiciona comandos make como atalhos para devops
1 parent ac01a9e commit 988666b

File tree

5 files changed

+4142
-3197
lines changed

5 files changed

+4142
-3197
lines changed

.env.sample

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@ APP_MODE=development
2727
NIXPACKS_PHP_ROOT_DIR=/app/public
2828
NIXPACKS_PHP_FALLBACK_PATH=/index.php
2929

30-
SITE_NAME=Mapa das Periferias
31-
SITE_DESCRIPTION=As comunidades no Brasil são territórios de potência. Esta plataforma nasceu para reunir e sistematizar dados e informações sobre as periferias do Brasil, com a missão de fortalecer as políticas públicas voltadas para territórios periféricos.
30+
SITE_NAME=Mapas v7
31+
SITE_DESCRIPTION=Mapas Culturais é uma plataforma colaborativa que reúne informações sobre agentes, espaços, eventos e projetos culturais, fornecendo ao poder público uma radiografia da área de cultura e ao cidadão um mapa de espaços e eventos culturais da região. A plataforma está alinhada ao Sistema Nacional de Informação e Indicadores Culturais do Ministério da Cultura (SNIIC) e contribui para a realização de alguns dos objetivos do Plano Nacional de Cultura.
3232
LOGO_TITLE=
3333
LOGO_SUBTITLE=
3434
LOGO_IMAGE=
35-
AUTH_EMAIL_IMAGE=https://iniciativas-mapadasperiferias.cidades.gov.br/files/opportunity/4/file/30/logo-ppv2024-f33ccbf81a4f55ec30ccb6c03264c7a7-23.jpg
35+
AUTH_EMAIL_IMAGE=
3636
AUTH_LOGIN_ON_REGISTER=true
3737
STATUS_CREATE_AGENT=1
3838
AUTH_LOGIN_BY_CPF=false

Makefile

Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
# Makefile for managing a project with multiple Docker Compose services
2+
3+
# Variables
4+
DOCKER_COMPOSE_FILE := docker-compose.yaml
5+
COMPOSE := docker compose -f $(DOCKER_COMPOSE_FILE)
6+
COMPOSE_DEV := docker compose -f $(DOCKER_COMPOSE_FILE) -f docker-compose.dev.yaml
7+
BACKEND_SERVICE := backend
8+
FRONTEND_SERVICE := frontend
9+
10+
# Default target: show help
11+
.PHONY: help
12+
help:
13+
@echo "Available targets:"
14+
@echo " up - Start all services in the background (detached mode)"
15+
@echo " down - Stop services and remove containers"
16+
@echo " ps - List running containers"
17+
@echo " dev - Start backend and frontend in the background (dev mode)"
18+
@echo " build-backend - Build the backend image"
19+
@echo " build-frontend- Build the frontend image"
20+
@echo " build - Build both backend and frontend services"
21+
@echo " logs - Tail logs for all services"
22+
@echo " logs-backend - Tail logs for backend"
23+
@echo " restart - Restart services"
24+
@echo " test-backend - Run backend test suite"
25+
@echo " test-frontend - Run frontend test suite"
26+
@echo " lint-backend - Lint the backend codebase"
27+
@echo " lint-frontend - Lint the frontend codebase"
28+
@echo " clean - Clean dangling Docker images and volumes"
29+
30+
# Dev setup
31+
.PHONY: dev
32+
dev:
33+
$(COMPOSE_DEV) up -d
34+
@echo "Services running in dev mode"
35+
36+
# List running containers
37+
.PHONY: ps
38+
ps:
39+
$(COMPOSE) ps
40+
@echo "Services running"
41+
42+
# Start all services in background (detached mode)
43+
.PHONY: up
44+
up:
45+
$(COMPOSE) up -d
46+
@echo "Services have been started in detached mode."
47+
48+
# Stop and remove all services and containers
49+
.PHONY: down
50+
down:
51+
$(COMPOSE) down
52+
@echo "Services have been stopped and removed."
53+
54+
# Create folders and fix permissions: doctrine, assets, private-files,
55+
.PHONY: init
56+
init:
57+
cp .env.sample .env
58+
$(COMPOSE) exec backend mkdir var/logs/
59+
$(COMPOSE) exec backend mkdir var/private-files/
60+
@echo "Folders created."
61+
$(COMPOSE) exec backend chmod 777 var/logs/
62+
$(COMPOSE) exec backend chmod 777 var/private-files/
63+
$(COMPOSE) exec backend chmod 777 var/sessions/
64+
$(COMPOSE) exec backend chmod 777 var/DoctrineProxies/
65+
@echo "Permissions granted."
66+
67+
# Run Migrations
68+
.PHONY: db-migrations
69+
db-migrations:
70+
$(COMPOSE) exec backend php src/tools/apply-updates.php
71+
@echo "db updates applied."
72+
73+
# Restore dump database
74+
.PHONY: db-restore
75+
db-restore:
76+
$(COMPOSE) exec database bash -c "psql -h localhost -U mapas -d mapas < /data/dump.sql"
77+
@echo "dump.sql default database dump was restored."
78+
79+
# Build the backend service
80+
.PHONY: build-backend
81+
build-backend:
82+
$(COMPOSE) build $(BACKEND_SERVICE)
83+
@echo "Backend service has been built."
84+
85+
# Build the frontend service
86+
.PHONY: build-frontend
87+
build-frontend:
88+
$(COMPOSE) build $(FRONTEND_SERVICE)
89+
@echo "Frontend service has been built."
90+
91+
# Build all images (both backend and frontend)
92+
.PHONY: build
93+
build: build-backend build-frontend
94+
@echo "All services have been built."
95+
96+
# Tail logs for all services
97+
.PHONY: logs
98+
logs:
99+
$(COMPOSE) logs -f
100+
@echo "Displaying logs for all services."
101+
102+
# Tail logs for backend
103+
.PHONY: logs-backend
104+
logs-backend:
105+
$(COMPOSE) exec $(BACKEND_SERVICE) tail -f var/logs/app.log
106+
@echo "Displaying logs for backend."
107+
108+
# Restart all services (useful after code changes)
109+
.PHONY: restart
110+
restart:
111+
$(COMPOSE) restart
112+
@echo "All services have been restarted."
113+
114+
# Run the backend tests
115+
.PHONY: test-backend
116+
test-backend:
117+
$(COMPOSE) exec $(BACKEND_SERVICE) make test # assuming you have a Makefile for testing inside backend
118+
@echo "Backend tests have been run."
119+
120+
# Run the frontend tests
121+
.PHONY: test-frontend
122+
test-frontend:
123+
$(COMPOSE) exec $(FRONTEND_SERVICE) npm test # or whatever command you use
124+
@echo "Frontend tests have been run."
125+
126+
# Lint the backend code
127+
.PHONY: lint-backend
128+
lint-backend:
129+
$(COMPOSE) exec $(BACKEND_SERVICE) make lint # assuming you have a Makefile target for this
130+
@echo "Backend code has been linted."
131+
132+
# Lint the frontend code
133+
.PHONY: lint-frontend
134+
lint-frontend:
135+
$(COMPOSE) exec $(FRONTEND_SERVICE) npm run lint # or command appropriate for your frontend framework
136+
@echo "Frontend code has been linted."
137+
138+
# Clean Docker: remove any stopped container, dangling images, volumes, etc.
139+
.PHONY: clean
140+
clean:
141+
$(COMPOSE) down -v --remove-orphans
142+
@echo "Cleaned up Docker containers, images, volumes."

docker-compose.dev.yaml

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
services:
2-
web:
2+
backend:
33
image: ghcr.io/redemapas/mapas-php
44
build:
55
context: .
@@ -21,9 +21,6 @@ services:
2121
- doctrine-files:/app/var/DoctrineProxies/
2222
command: php -S 0.0.0.0:80 -q -t /app/public /app/router.php
2323

24-
tmui-postgres:
25-
image: achristmascarl/rainfrog:latest
26-
2724
recreate-pending-pcache:
2825
image: ghcr.io/redemapas/mapas-php
2926
restart: no
@@ -42,22 +39,28 @@ services:
4239
volumes:
4340
- ./:/app
4441

45-
db-update:
46-
image: ghcr.io/redemapas/mapas-php
42+
frontend:
43+
image: node:20 # Usando a imagem oficial do Node.js 20
44+
working_dir: /usr/src/app # Define o diretório de trabalho dentro do container
4745
restart: no
48-
build:
49-
context: .
50-
dockerfile: Dockerfile
5146
volumes:
52-
- ./:/app
53-
54-
pgadmin:
55-
image: dpage/pgadmin4
47+
- .:/usr/src/app # Mapeia sua pasta local para a pasta dentro do container
48+
- /usr/src/app/node_modules # Evita sobrepor os módulos node_modules do container
49+
command: /bin/sh -c "npm install -g pnpm && pnpm install && pnpm run watch"
50+
# Comando para instalar dependências e rodar build
5651
environment:
57-
PGADMIN_DEFAULT_EMAIL: ${PGADMIN_DEFAULT_EMAIL:-pgadmin4@pgadmin.org}
58-
PGADMIN_DEFAULT_PASSWORD: ${PGADMIN_DEFAULT_PASSWORD:-admin}
59-
PGADMIN_CONFIG_SERVER_MODE: 'False'
60-
volumes:
61-
- pgadmin:/var/lib/pgadmin
62-
ports:
63-
- 80
52+
- NODE_ENV=development # Variável de ambiente para o Node.js
53+
54+
# tmui-postgres:
55+
# image: achristmascarl/rainfrog:latest
56+
57+
# pgadmin:
58+
# image: dpage/pgadmin4
59+
# environment:
60+
# PGADMIN_DEFAULT_EMAIL: ${PGADMIN_DEFAULT_EMAIL:-pgadmin4@pgadmin.org}
61+
# PGADMIN_DEFAULT_PASSWORD: ${PGADMIN_DEFAULT_PASSWORD:-admin}
62+
# PGADMIN_CONFIG_SERVER_MODE: 'False'
63+
# volumes:
64+
# - pgadmin:/var/lib/pgadmin
65+
# ports:
66+
# - 80

0 commit comments

Comments
 (0)