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
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
dev
var/*/*
node_modules
vendor
56 changes: 56 additions & 0 deletions .env.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
PORT=80
BUILD_ASSETS=0
DATABASE_URL=postgresql://mapas:mapas@database:5432/mapas?serverVersion=14&charset=utf8
DATADIR=/opt/postgres/data
GOOGLE_RECAPTCHA_SECRET=6LeIxAcTAAAAAGG-vFI1TnRWxMZNFuojJ4WifJWe
GOOGLE_RECAPTCHA_SITEKEY=6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI
JOBS_INTERVAL=5
MAILER_FROM=sysadmin@localhost
MAILER_TRANSPORT=smtp://mailhog:1025
MC_UPDATES_PROCESSES=1
NUM_PROCESSES=1
PENDING_PCACHE_RECREATION_INTERVAL=5
POSTGRES_DB=mapas
POSTGRES_PASSWORD=mapas
POSTGRES_USER=mapas
PWA_UPSTREAM=pwa:3000
#REDIS_CACHE=redis://redis:6379
SERVER_NAME=http://
SESSIONS_SAVE_PATH=/app/var/sessions
TRUSTED_HOSTS=^${SERVER_NAME:-example\.com|localhost} | php$$
TRUSTED_PROXIES=127.0.0.0/8,10.0.0.0/8,172.17.0.0/12,192.168.0.0/16
DB_HOST=database
APP_ENV=development
XDEBUG_MODE=off
APP_MODE=development
# APP_RUNTIME=Runtime\\FrankenPhpSymfony\\Runtime
NIXPACKS_PHP_ROOT_DIR=/app/public
NIXPACKS_PHP_FALLBACK_PATH=/index.php

SITE_NAME=Mapas v7
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.
LOGO_TITLE=
LOGO_SUBTITLE=
LOGO_IMAGE=
AUTH_EMAIL_IMAGE=
AUTH_LOGIN_ON_REGISTER=true
STATUS_CREATE_AGENT=1
AUTH_LOGIN_BY_CPF=false

AUTH_GOV_BR_ID=true
AUTO_GOV_RESPONSE_TYPE=code
AUTH_GOV_BR_CLIENT_ID=client_id
AUTH_GOV_BR_CLIENT_SECRET=secret
AUTH_GOV_BR_SCOPE=openid email profile phone govbr_confiabilidades
AUTH_GOV_BR_REDIRECT_URI=https://gov.br/autenticacao/oauth2callback
AUTH_GOV_BR_ENDPOINT=https://gov.br/authorize
AUTH_GOV_BR_TOKEN_ENDPOINT=https://gov.br/token
AUTH_GOV_BR_NONCE=mapas
AUTH_GOV_BR_CODE_VERIFIER=vbQ71yzBAphMeargyG6EG_It9P6-kqSIrgRyT-hGwIQ
AUTH_GOV_BR_CODE_CHALLENGE=wwheOwufT6pFeAuIaHo8QmMT4k6r2gh0N1X_zHQK7LU
AUTH_GOV_BR_CODE_CHALLENGE_METHOD=S256
AUTH_GOV_BR_USERINFO_ENDPOINT=https://gov.br/jwk
AUTH_GOV_BR_STATE_SALT=mapas
AUTH_GOV_BR_APPLY_SEAL_ID=1
AUTH_GOV_BR_MENSSAGEM_AUTHENTICATED=Usuário já se autenticou pelo GovBr
AUTH_GOV_BR_DICT_AGENT_FIELDS_UPDATE="['nomeCompleto' => 'full_name', 'name' => 'name', 'documento' => 'cpf', 'cpf' => 'cpf', 'emailPrivado' => 'email', 'telefone1' => 'phone_number']"
177 changes: 155 additions & 22 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,26 @@
name: ci

on:
push:
branches:
- "master"
- "develop"
- "feature*"
tags:
- "v*.*.*"
pull_request:
branches:
- "develop"
workflow_dispatch:

permissions:
contents: read
packages: write
id-token: write
security-events: write
actions: read
checks: read
statuses: read

jobs:
docker:
CODE_PUBLISH:
runs-on: ubuntu-latest
steps:
-
Expand All @@ -23,44 +31,169 @@ jobs:
id: meta
uses: docker/metadata-action@v4
with:
# list of Docker images to use as base name for tags
images: |
docker.io/hacklab/mapasculturais
# ghcr.io/username/app
# generate Docker tags based on the following events/attributes
ghcr.io/redemapas/mapas
tags: |
type=raw,value=latest,enable=${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') }}
type=ref,event=branch
type=raw,value=pr-${{ github.event.pull_request.number }}
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=sha
-
name: Set up QEMU
uses: docker/setup-qemu-action@v2
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
-
name: Login to Docker Hub
if: github.event_name != 'pull_request'
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
# -
# name: Login to GHCR
# name: Login to Docker Hub
# if: github.event_name != 'pull_request'
# uses: docker/login-action@v2
# with:
# registry: ghcr.io
# username: ${{ github.repository_owner }}
# password: ${{ secrets.GITHUB_TOKEN }}
# username: ${{ secrets.DOCKERHUB_USERNAME }}
# password: ${{ secrets.DOCKERHUB_TOKEN }}
-
name: Login to GHCR
# if: github.event_name != 'pull_request'
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
-
name: Build and push
uses: docker/build-push-action@v4
with:
file: ./docker/Dockerfile
context: .
push: ${{ github.event_name != 'pull_request' }}
file: .nixpacks/Dockerfile
platforms: linux/amd64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max

CODE_STYLE_FIXER:
name: CODE STYLE CS FIXER
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Run PHP-CS-Fixer
uses: erkenes/php-cs-fixer-action@main
with:
args: '--dry-run --diff -vvv'

CODE_STYLE_PSALM:
name: CODE SECURITY
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Run Psalm
uses: docker://ghcr.io/psalm/psalm-github-actions
with:
composer_require_dev: true
composer_ignore_platform_reqs: true
security_analysis: true
report_file: results.sarif
- name: Upload Security Analysis results to GitHub
uses: github/codeql-action/upload-sarif@v2
with:
sarif_file: results.sarif

CODE_TESTS:
name: CODE TESTS
timeout-minutes: 15
runs-on: ubuntu-latest
steps:
- name: Baixando codigo
uses: actions/checkout@v4
with:
submodules: recursive
# See https://github.com/pnpm/action-setup
- name: Install pnpm
uses: pnpm/action-setup@v4
# See https://github.com/actions/setup-node
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: 'pnpm'
# cache-dependency-path: ./pnpm-lock.yaml
- run: pnpm i
- run: pnpm run build
- name: Configuração de valores padrões
run: |
cp .env.sample .env

- uses: hoverkraft-tech/compose-action@v1.5.1
with:
compose-file: |
docker-compose.yml
docker-compose.dev.yml
services: "backend"
up-flags: "-d --wait"
down-flags: "-v"

- name: Atualização da estrutura do banco de dados
run: |
make db-restore
make init
make init_dev
make db-migrations
env:
APP_MODE: development

- name: Testes Unitários com PhpUnit
run: |
make test-backend

- name: Upload to Codecov
uses: codecov/codecov-action@v2
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage.xml
verbose: true

# - name: Testes de integração com Cypress
# uses: cypress-io/github-action@v6
# with:
# config: '{"e2e":{"viewportWidth":375,"viewportHeight":667}}'
# wait-on: "http://localhost:4242"
# wait-on-timeout: 120
# browser: chrome
# # record: false
# # parallel: true
# # group: "UI - Chrome - Mobile"
# config-file: cypress/cypress.config.js
# env:
# # CYPRESS_PROJECT_ID: ${{ secrets.CYPRESS_PROJECT_ID }}
# # CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
# # Recommended: pass the GitHub token lets this action correctly
# # determine the unique run id necessary to re-run the checks
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
#
# - name: Save build folder
# uses: actions/upload-artifact@v4
# with:
# name: screenshots
# if-no-files-found: error
# path: src/cypress/screenshots
# - name: Install composer and dependencies
# uses: php-actions/composer@v6
# with:
# php_extensions: pdo_pgsql zip intl gd mbstring curl xml

# - name: PHPUnit Tests Mapas
# uses: php-actions/phpunit@v3
# env:
# XDEBUG_MODE: coverage
# with:
# version: 10.5
# php_version: 8.2
# configuration: phpunit.xml
# php_extensions: pdo_pgsql zip intl gd mbstring curl xml
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,7 @@ src/themes/BaseV1/assets/css/main.css
src/themes/BaseV1/assets/css/main.css.map
**/.env
!/dev/.env
.phpunit*
*.phar
*.php-cs-fixer.cache
*coverage.xml
4 changes: 2 additions & 2 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[submodule "src/plugins/MultipleLocalAuth"]
path = src/plugins/MultipleLocalAuth
url = https://github.com/culturagovbr/plugin-MultipleLocalAuth.git
branch = feature/login-basev2
url = https://github.com/redemapas/plugin-MultipleLocalAuth.git
branch = main
[submodule "src/plugins/AdminLoginAsUser"]
path = src/plugins/AdminLoginAsUser
url = https://github.com/mapasculturais/plugin-AdminLoginAsUser
Expand Down
35 changes: 35 additions & 0 deletions .nixpacks/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
FROM ghcr.io/railwayapp/nixpacks:ubuntu-1727136237

ENTRYPOINT ["/bin/bash", "-l", "-c"]
WORKDIR /app/


COPY .nixpacks/nixpkgs-dbc4f15b899ac77a8d408d8e0f89fa9c0c5f2b78.nix .nixpacks/nixpkgs-dbc4f15b899ac77a8d408d8e0f89fa9c0c5f2b78.nix
RUN nix-env -if .nixpacks/nixpkgs-dbc4f15b899ac77a8d408d8e0f89fa9c0c5f2b78.nix && nix-collect-garbage -d

COPY .nixpacks/assets /assets/
ARG NIXPACKS_METADATA NIXPACKS_PHP_FALLBACK_PATH NIXPACKS_PHP_ROOT_DIR PORT POST_MAX_SIZE UPLOAD_MAX_FILESIZE
ENV NIXPACKS_METADATA=$NIXPACKS_METADATA NIXPACKS_PHP_FALLBACK_PATH=$NIXPACKS_PHP_FALLBACK_PATH NIXPACKS_PHP_ROOT_DIR=$NIXPACKS_PHP_ROOT_DIR PORT=$PORT POST_MAX_SIZE=$POST_MAX_SIZE UPLOAD_MAX_FILESIZE=$UPLOAD_MAX_FILESIZE

# setup phase
COPY . /app/.
RUN PHP_INI_PATH=$(php --ini | grep "Additional .ini files parsed:" | cut -d: -f2 | tr -d " "); echo "PHP_INI_PATH is $PHP_INI_PATH"; echo "upload_max_filesize=128M" >> $PHP_INI_PATH; echo "post_max_size=128M" >> $PHP_INI_PATH; echo "Content of php.ini below:"; cat "$PHP_INI_PATH"

# install phase
COPY . /app/.
RUN mkdir -p /var/log/nginx && mkdir -p /var/cache/nginx
RUN composer install --ignore-platform-reqs
RUN pnpm i --frozen-lockfile

# build phase
COPY . /app/.
RUN pnpm run build





# start
COPY . /app
CMD ["node /assets/scripts/prestart.mjs /assets/nginx.template.conf /nginx.conf && (php-fpm -y /assets/php-fpm.conf & nginx -c /nginx.conf)"]

Loading
Loading