Skip to content

Commit af2d41f

Browse files
committed
Implementa suporte a imagem de container compatível com OCI
1 parent 67617b5 commit af2d41f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+2018
-820
lines changed

.dockerignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
dev
22
var/*/*
3+
node_modules
4+
*/node_modules
5+
vendor

.env.sample

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
PORT=80
2+
BUILD_ASSETS=0
3+
# not working DATABASE_URL=postgresql://mapas:mapas@database:5432/mapas?serverVersion=14&charset=utf8
4+
DATADIR=/opt/postgres/data
5+
GOOGLE_RECAPTCHA_SECRET=6LeIxAcTAAAAAGG-vFI1TnRWxMZNFuojJ4WifJWe
6+
GOOGLE_RECAPTCHA_SITEKEY=6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI
7+
JOBS_INTERVAL=5
8+
MAILER_FROM=sysadmin@localhost
9+
MAILER_TRANSPORT=smtp://mailhog:1025
10+
MC_UPDATES_PROCESSES=1
11+
NUM_PROCESSES=1
12+
PENDING_PCACHE_RECREATION_INTERVAL=5
13+
POSTGRES_DB=mapas
14+
POSTGRES_PASSWORD=mapas
15+
POSTGRES_USER=mapas
16+
# disabled REDIS_CACHE=redis://redis:6379
17+
SESSIONS_SAVE_PATH=/app/var/sessions
18+
DB_HOST=database
19+
DB_PASS=mapas
20+
DB_USER=mapas
21+
DB_NAME=mapas
22+
# not working DB_PORT=5432
23+
APP_ENV=development
24+
XDEBUG_MODE=off
25+
APP_MODE=development
26+
NIXPACKS_PHP_ROOT_DIR=/app/public
27+
NIXPACKS_PHP_FALLBACK_PATH=/index.php
28+
ACTIVE_THEME
29+
SITE_NAME=Mapas v7
30+
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.
31+
LOGO_TITLE=
32+
LOGO_SUBTITLE=
33+
LOGO_IMAGE=
34+
AUTH_EMAIL_IMAGE=
35+
AUTH_LOGIN_ON_REGISTER=true
36+
STATUS_CREATE_AGENT=1
37+
AUTH_LOGIN_BY_CPF=false
38+
39+
BASE_URL=http://localhost:4242

.github/workflows/ci.yml

Lines changed: 155 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,26 @@
11
name: ci
2-
32
on:
43
push:
54
branches:
6-
- "master"
7-
- "develop"
8-
- "saas"
5+
- "feature*"
96
tags:
107
- "v*.*.*"
118
pull_request:
129
branches:
1310
- "develop"
11+
workflow_dispatch:
1412

13+
permissions:
14+
contents: read
15+
packages: write
16+
id-token: write
17+
security-events: write
18+
actions: read
19+
checks: read
20+
statuses: read
21+
1522
jobs:
16-
docker:
23+
CODE_PUBLISH:
1724
runs-on: ubuntu-latest
1825
steps:
1926
-
@@ -24,44 +31,169 @@ jobs:
2431
id: meta
2532
uses: docker/metadata-action@v4
2633
with:
27-
# list of Docker images to use as base name for tags
2834
images: |
29-
docker.io/hacklab/mapasculturais
30-
# ghcr.io/username/app
31-
# generate Docker tags based on the following events/attributes
35+
ghcr.io/redemapas/mapas
3236
tags: |
37+
type=raw,value=latest,enable=${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') }}
3338
type=ref,event=branch
39+
type=raw,value=pr-${{ github.event.pull_request.number }}
3440
type=semver,pattern={{version}}
3541
type=semver,pattern={{major}}.{{minor}}
3642
type=semver,pattern={{major}}
43+
type=sha
3744
-
3845
name: Set up QEMU
3946
uses: docker/setup-qemu-action@v2
4047
-
4148
name: Set up Docker Buildx
4249
uses: docker/setup-buildx-action@v2
43-
-
44-
name: Login to Docker Hub
45-
if: github.event_name != 'pull_request'
46-
uses: docker/login-action@v2
47-
with:
48-
username: ${{ secrets.DOCKERHUB_USERNAME }}
49-
password: ${{ secrets.DOCKERHUB_TOKEN }}
5050
# -
51-
# name: Login to GHCR
51+
# name: Login to Docker Hub
5252
# if: github.event_name != 'pull_request'
5353
# uses: docker/login-action@v2
5454
# with:
55-
# registry: ghcr.io
56-
# username: ${{ github.repository_owner }}
57-
# password: ${{ secrets.GITHUB_TOKEN }}
55+
# username: ${{ secrets.DOCKERHUB_USERNAME }}
56+
# password: ${{ secrets.DOCKERHUB_TOKEN }}
57+
-
58+
name: Login to GHCR
59+
# if: github.event_name != 'pull_request'
60+
uses: docker/login-action@v2
61+
with:
62+
registry: ghcr.io
63+
username: ${{ github.repository_owner }}
64+
password: ${{ secrets.GITHUB_TOKEN }}
5865
-
5966
name: Build and push
6067
uses: docker/build-push-action@v4
6168
with:
62-
file: ./docker/Dockerfile
63-
context: .
64-
push: ${{ github.event_name != 'pull_request' }}
69+
file: .nixpacks/Dockerfile
70+
platforms: linux/amd64
71+
push: true
6572
tags: ${{ steps.meta.outputs.tags }}
6673
labels: ${{ steps.meta.outputs.labels }}
74+
cache-from: type=gha
75+
cache-to: type=gha,mode=max
76+
77+
CODE_STYLE_FIXER:
78+
name: CODE STYLE CS FIXER
79+
runs-on: ubuntu-latest
80+
steps:
81+
- uses: actions/checkout@v4
82+
with:
83+
submodules: recursive
84+
- name: Run PHP-CS-Fixer
85+
uses: erkenes/php-cs-fixer-action@main
86+
with:
87+
args: '--dry-run --diff -vvv'
88+
89+
CODE_STYLE_PSALM:
90+
name: CODE SECURITY
91+
runs-on: ubuntu-latest
92+
steps:
93+
- uses: actions/checkout@v4
94+
with:
95+
submodules: recursive
96+
- name: Run Psalm
97+
uses: docker://ghcr.io/psalm/psalm-github-actions
98+
with:
99+
composer_require_dev: true
100+
composer_ignore_platform_reqs: true
101+
security_analysis: true
102+
report_file: results.sarif
103+
- name: Upload Security Analysis results to GitHub
104+
uses: github/codeql-action/upload-sarif@v2
105+
with:
106+
sarif_file: results.sarif
107+
108+
CODE_TESTS:
109+
name: CODE TESTS
110+
timeout-minutes: 15
111+
runs-on: ubuntu-latest
112+
steps:
113+
- name: Baixando codigo
114+
uses: actions/checkout@v4
115+
with:
116+
submodules: recursive
117+
# See https://github.com/pnpm/action-setup
118+
- name: Install pnpm
119+
uses: pnpm/action-setup@v4
120+
# See https://github.com/actions/setup-node
121+
- name: Install Node.js
122+
uses: actions/setup-node@v4
123+
with:
124+
node-version: 20
125+
cache: 'pnpm'
126+
# cache-dependency-path: ./pnpm-lock.yaml
127+
- run: pnpm i
128+
- run: pnpm run build
129+
- name: Configuração de valores padrões
130+
run: |
131+
cp .env.sample .env
132+
133+
- uses: hoverkraft-tech/[email protected]
134+
with:
135+
compose-file: |
136+
docker-compose.yml
137+
docker-compose.dev.yml
138+
services: "backend"
139+
up-flags: "-d --wait"
140+
down-flags: "-v"
141+
142+
- name: Atualização da estrutura do banco de dados
143+
run: |
144+
make db-restore
145+
make init
146+
make init_dev
147+
make db-migrations
148+
env:
149+
APP_MODE: development
150+
151+
- name: Testes Unitários com PhpUnit
152+
run: |
153+
make test-backend
154+
155+
- name: Upload to Codecov
156+
uses: codecov/codecov-action@v2
157+
with:
158+
token: ${{ secrets.CODECOV_TOKEN }}
159+
files: ./coverage.xml
160+
verbose: true
161+
162+
# - name: Testes de integração com Cypress
163+
# uses: cypress-io/github-action@v6
164+
# with:
165+
# config: '{"e2e":{"viewportWidth":375,"viewportHeight":667}}'
166+
# wait-on: "http://localhost:4242"
167+
# wait-on-timeout: 120
168+
# browser: chrome
169+
# # record: false
170+
# # parallel: true
171+
# # group: "UI - Chrome - Mobile"
172+
# config-file: cypress/cypress.config.js
173+
# env:
174+
# # CYPRESS_PROJECT_ID: ${{ secrets.CYPRESS_PROJECT_ID }}
175+
# # CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
176+
# # Recommended: pass the GitHub token lets this action correctly
177+
# # determine the unique run id necessary to re-run the checks
178+
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
179+
#
180+
# - name: Save build folder
181+
# uses: actions/upload-artifact@v4
182+
# with:
183+
# name: screenshots
184+
# if-no-files-found: error
185+
# path: src/cypress/screenshots
186+
# - name: Install composer and dependencies
187+
# uses: php-actions/composer@v6
188+
# with:
189+
# php_extensions: pdo_pgsql zip intl gd mbstring curl xml
67190

191+
# - name: PHPUnit Tests Mapas
192+
# uses: php-actions/phpunit@v3
193+
# env:
194+
# XDEBUG_MODE: coverage
195+
# with:
196+
# version: 10.5
197+
# php_version: 8.2
198+
# configuration: phpunit.xml
199+
# php_extensions: pdo_pgsql zip intl gd mbstring curl xml

.gitignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,12 @@ src/themes/BaseV1/assets/css/main.css
1212
src/themes/BaseV1/assets/css/main.css.map
1313
**/.env
1414
!/dev/.env
15+
.vscode
16+
.zed
17+
public/assets
18+
public/evaluators-default-profiles
19+
public/files/distributionslog
20+
.phpunit*
21+
*.phar
22+
*.php-cs-fixer.cache
23+
*coverage.xml

.nixpacks/Dockerfile

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
FROM ghcr.io/railwayapp/nixpacks:ubuntu-1727136237
2+
3+
ENTRYPOINT ["/bin/bash", "-l", "-c"]
4+
WORKDIR /app/
5+
6+
7+
COPY .nixpacks/nixpkgs-dbc4f15b899ac77a8d408d8e0f89fa9c0c5f2b78.nix .nixpacks/nixpkgs-dbc4f15b899ac77a8d408d8e0f89fa9c0c5f2b78.nix
8+
RUN nix-env -if .nixpacks/nixpkgs-dbc4f15b899ac77a8d408d8e0f89fa9c0c5f2b78.nix && nix-collect-garbage -d
9+
10+
COPY .nixpacks/assets /assets/
11+
ARG NIXPACKS_METADATA NIXPACKS_PHP_FALLBACK_PATH NIXPACKS_PHP_ROOT_DIR PORT POST_MAX_SIZE UPLOAD_MAX_FILESIZE
12+
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
13+
14+
# setup phase
15+
COPY . /app/.
16+
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"
17+
18+
# install phase
19+
COPY . /app/.
20+
RUN mkdir -p /var/log/nginx && mkdir -p /var/cache/nginx
21+
RUN composer install --ignore-platform-reqs
22+
RUN pnpm i --frozen-lockfile
23+
24+
# build phase
25+
COPY . /app/.
26+
RUN pnpm run build
27+
28+
29+
30+
31+
32+
# start
33+
COPY . /app
34+
CMD ["node /assets/scripts/prestart.mjs /assets/nginx.template.conf /nginx.conf && (php-fpm -y /assets/php-fpm.conf & nginx -c /nginx.conf)"]
35+

.nixpacks/assets/nginx.template.conf

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
worker_processes 5;
2+
daemon off;
3+
4+
worker_rlimit_nofile 8192;
5+
6+
events {
7+
worker_connections 4096; # Default: 1024
8+
}
9+
10+
http {
11+
include $!{nginx}/conf/mime.types;
12+
index index.html index.htm index.php;
13+
14+
default_type application/octet-stream;
15+
log_format main '$remote_addr - $remote_user [$time_local] $status '
16+
'"$request" $body_bytes_sent "$http_referer" '
17+
'"$http_user_agent" "$http_x_forwarded_for"';
18+
access_log /dev/stdout;
19+
error_log /dev/stdout;
20+
sendfile on;
21+
tcp_nopush on;
22+
server_names_hash_bucket_size 128; # this seems to be required for some vhosts
23+
client_max_body_size 128M;
24+
25+
server {
26+
listen ${PORT};
27+
listen [::]:${PORT};
28+
server_name localhost;
29+
30+
$if(NIXPACKS_PHP_ROOT_DIR) (
31+
root ${NIXPACKS_PHP_ROOT_DIR};
32+
) else (
33+
root /app;
34+
)
35+
36+
add_header X-Frame-Options "SAMEORIGIN";
37+
add_header X-Content-Type-Options "nosniff";
38+
39+
index index.php;
40+
41+
charset utf-8;
42+
43+
$if(IS_LARAVEL) (
44+
location / {
45+
try_files $uri $uri/ /index.php?$query_string;
46+
}
47+
) else ()
48+
49+
$if(NIXPACKS_PHP_FALLBACK_PATH) (
50+
location / {
51+
try_files $uri $uri/ ${NIXPACKS_PHP_FALLBACK_PATH}?$query_string;
52+
}
53+
) else ()
54+
55+
location = /favicon.ico { access_log off; log_not_found off; }
56+
location = /robots.txt { access_log off; log_not_found off; }
57+
58+
$if(IS_LARAVEL) (
59+
error_page 404 /index.php;
60+
) else ()
61+
62+
location ~ \.php$ {
63+
fastcgi_pass 127.0.0.1:9000;
64+
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
65+
include $!{nginx}/conf/fastcgi_params;
66+
include $!{nginx}/conf/fastcgi.conf;
67+
}
68+
69+
location ~ /\.(?!well-known).* {
70+
deny all;
71+
}
72+
}
73+
}

0 commit comments

Comments
 (0)