Skip to content

Commit bb2ae0d

Browse files
committed
Adiciona comandos make como atalhos para devops
1 parent af2d243 commit bb2ae0d

11 files changed

+4367
-15294
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
File renamed without changes.

Dockerfile.frontend

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Usa a imagem oficial do Node 20
2+
FROM node:20
3+
4+
5+
# Cria um diretório de trabalho no contêiner
6+
WORKDIR /app
7+
VOLUME [ "/app" ]
8+
9+
# Copia os arquivos package.json e pnpm-lock.yaml para o diretório de trabalho
10+
COPY . /app/
11+
12+
# Instala o pnpm globalmente
13+
RUN npm install -g pnpm
14+
15+
# Instala as dependências do projeto usando o pnpm
16+
RUN pnpm install
17+
18+
# Copia todos os arquivos do projeto para o diretório de trabalho
19+
20+
# Define o comando padrão para executar o pnpm run watch
21+
# CMD ["pnpm", "run", "build"]

Makefile

Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
# Makefile for managing a project with multiple Docker Compose services
2+
3+
# Variables
4+
DOCKER_COMPOSE_FILE := docker-compose.yml
5+
COMPOSE := docker compose -f $(DOCKER_COMPOSE_FILE)
6+
COMPOSE_DEV := docker compose -f $(DOCKER_COMPOSE_FILE) -f docker-compose.dev.yml
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+
$(COMPOSE) exec backend chmod 777 public/assets/
66+
@echo "Permissions granted."
67+
68+
69+
.PHONY: init_dev
70+
init_dev:
71+
$(COMPOSE) exec backend composer install
72+
@echo "Permissions granted."
73+
74+
75+
76+
# Run Migrations
77+
.PHONY: db-migrations
78+
db-migrations:
79+
$(COMPOSE) exec backend php src/tools/apply-updates.php
80+
@echo "db updates applied."
81+
82+
# Restore dump database
83+
.PHONY: db-restore
84+
db-restore:
85+
$(COMPOSE) exec database bash -c "psql -h localhost -U mapas -d mapas < /data/dump.sql"
86+
@echo "dump.sql default database dump was restored."
87+
88+
# Build the backend service
89+
.PHONY: build-backend
90+
build-backend:
91+
$(COMPOSE) build $(BACKEND_SERVICE)
92+
@echo "Backend service has been built."
93+
94+
# # Build the frontend service
95+
# .PHONY: build-frontend
96+
# build-frontend:
97+
# $(COMPOSE_DEV) run --rm frontend "/bin/sh -c 'npm install -g pnpm && pnpm install -s && pnpm run watch'"
98+
# @echo "Frontend service has been built."
99+
100+
# Build all images (both backend and frontend)
101+
.PHONY: build
102+
build: build-backend build-frontend
103+
@echo "All services have been built."
104+
105+
# Tail logs for all services
106+
.PHONY: logs
107+
logs:
108+
$(COMPOSE) logs
109+
@echo "Displaying logs for all services."
110+
111+
# Tail logs for backend
112+
.PHONY: logs-backend
113+
logs-backend:
114+
$(COMPOSE) exec $(BACKEND_SERVICE) tail -f var/logs/app.log
115+
@echo "Displaying logs for backend."
116+
117+
# Restart all services (useful after code changes)
118+
.PHONY: restart
119+
restart:
120+
$(COMPOSE) restart
121+
@echo "All services have been restarted."
122+
123+
# Run the backend tests
124+
.PHONY: test-backend
125+
test-backend:
126+
$(COMPOSE) exec $(BACKEND_SERVICE) make test # assuming you have a Makefile for testing inside backend
127+
@echo "Backend tests have been run."
128+
129+
# Run the frontend tests
130+
.PHONY: test-frontend
131+
test-frontend:
132+
$(COMPOSE) exec $(FRONTEND_SERVICE) npm test # or whatever command you use
133+
@echo "Frontend tests have been run."
134+
135+
# Lint the backend code
136+
.PHONY: lint-backend
137+
lint-backend:
138+
$(COMPOSE) exec $(BACKEND_SERVICE) make lint # assuming you have a Makefile target for this
139+
@echo "Backend code has been linted."
140+
141+
# Lint the frontend code
142+
.PHONY: lint-frontend
143+
lint-frontend:
144+
$(COMPOSE) exec $(FRONTEND_SERVICE) npm run lint # or command appropriate for your frontend framework
145+
@echo "Frontend code has been linted."
146+
147+
# Clean Docker: remove any stopped container, dangling images, volumes, etc.
148+
.PHONY: clean
149+
clean:
150+
$(COMPOSE) down -v --remove-orphans
151+
@sudo find . -name 'node_modules' -type d -prune -exec rm -rf '{}' +
152+
@sudo rm -rf vendor
153+
@echo "Cleaned up Docker containers, images, volumes."

docker-compose.dev.yaml

Lines changed: 0 additions & 63 deletions
This file was deleted.

docker-compose.dev.yml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
services:
2+
backend:
3+
image: ghcr.io/redemapas/mapas
4+
build:
5+
context: .
6+
dockerfile: Dockerfile.backend
7+
restart: no
8+
depends_on:
9+
- database
10+
environment:
11+
CACHE_ASSETS_URL: 'false'
12+
XDEBUG_MODE: coverage
13+
ports:
14+
- 4242:80
15+
volumes:
16+
- ./:/app
17+
- var-files:/app/var/
18+
- assets-files:/app/public/assets
19+
- user-public-files:/app/public/files/
20+
- sessions-files:/app/var/sessions/
21+
- doctrine-files:/app/var/DoctrineProxies/
22+
command: php -S 0.0.0.0:80 -q -t /app/public /app/router.php
23+
24+
recreate-pending-pcache:
25+
image: ghcr.io/redemapas/mapas
26+
restart: no
27+
build:
28+
context: .
29+
dockerfile: Dockerfile.backend
30+
volumes:
31+
- ./:/app
32+
33+
execute-job:
34+
image: ghcr.io/redemapas/mapas
35+
restart: no
36+
build:
37+
context: .
38+
dockerfile: Dockerfile.backend
39+
volumes:
40+
- ./:/app
41+
42+
frontend:
43+
image: ghcr.io/redemapas/mapas-frontend
44+
restart: no
45+
build:
46+
context: .
47+
dockerfile: Dockerfile.frontend
48+
# volumes:
49+
# - .:/app # Mapeia sua pasta local para a pasta dentro do container
50+
# - /usr/src/app/node_modules # Evita sobrepor os módulos node_modules do container
51+
command: /bin/sh -c "pnpm run watch"
52+
environment:
53+
- NODE_ENV=development # Variável de ambiente para o Node.js
54+
55+
# tmui-postgres:
56+
# image: achristmascarl/rainfrog:latest
57+
58+
# pgadmin:
59+
# image: dpage/pgadmin4
60+
# environment:
61+
# PGADMIN_DEFAULT_EMAIL: ${PGADMIN_DEFAULT_EMAIL:[email protected]}
62+
# PGADMIN_DEFAULT_PASSWORD: ${PGADMIN_DEFAULT_PASSWORD:-admin}
63+
# PGADMIN_CONFIG_SERVER_MODE: 'False'
64+
# volumes:
65+
# - pgadmin:/var/lib/pgadmin
66+
# ports:
67+
# - 80

0 commit comments

Comments
 (0)