Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
eabbe45
feat: cria estrutura mínima do módulo de plano de trabalho
vicmagpac Oct 16, 2024
0429280
feat: refatora e atualiza escopo nome dos metadados
vicmagpac Oct 25, 2024
3c67692
feat: atualiza configurações do plano de trabalho no gerenciamento da…
vicmagpac Nov 1, 2024
8ef8364
feat: inicia criação do componente de cadastro do plano de trabalho n…
vicmagpac Nov 1, 2024
4e56931
feat: define estrutura mínima das metas na inscrição
vicmagpac Nov 4, 2024
f86a8f7
feat: adiciona novo campo de segmento cultural no plano de trabalho e…
vicmagpac Nov 4, 2024
078df46
feat: adiciona fluxo inicial de entregas nas metas
vicmagpac Nov 4, 2024
35045b6
feat: adiciona gerenciamento de entregas para as metas
vicmagpac Nov 4, 2024
9a7a146
feat: configura fields quando moeda nas metas e entregas
vicmagpac Nov 4, 2024
9148c49
feat: configura css das metas e entregas
vicmagpac Nov 4, 2024
ea6e8f4
feat: reimplementa formulário de configuração do plano de trabalho na…
vicmagpac Nov 4, 2024
47e8765
feat: limpa campos quando entregas vinculadas a meta são desativadas
vicmagpac Nov 4, 2024
a822f73
feat: adiciona collapse para plano de trabalho
vicmagpac Nov 5, 2024
cc3a630
feat: add estrutura minima com doctrine
vicmagpac Nov 5, 2024
8755423
feat: add crud básico para plano, metas e entregas
vicmagpac Nov 7, 2024
a7d2c34
Move configuraçoẽs de dependências nodejs para raiz
lpirola Oct 8, 2024
107dd99
Organiza os serviços no docker compose por processo: web, execute-job…
lpirola Oct 8, 2024
af2d243
Adiciona Nix Pack como padrão de iamgem docker para nginx, php e nodejs
lpirola Oct 8, 2024
a4196b6
feat: cria db updates do plano de trabalho
vicmagpac Nov 7, 2024
f329e61
feat: muda estrutura das entidades e metadados
vicmagpac Nov 7, 2024
4445589
feat: adiciona fluxo nos controladores
vicmagpac Nov 7, 2024
06ad0ec
feat: cria metadados das novas entidades
vicmagpac Nov 7, 2024
1d2363a
feat: deixa permanente diretório assets do module
vicmagpac Nov 7, 2024
c8764ee
feat: limpa classes não usadas e renomeia entidades
vicmagpac Nov 8, 2024
727536c
feat: configura limitação máxima do projeto para a meta
vicmagpac Nov 9, 2024
a42c815
feat: aplica regra etapa fazer cultural, valor da meta e limitar nume…
vicmagpac Nov 9, 2024
6fae6c0
feat: aplica regras de configuração do plano na configuração da oport…
vicmagpac Nov 9, 2024
4b6261d
feat: add validação plano de trabalho, metas e entregas
vicmagpac Nov 9, 2024
1976720
feat: add fluxo gerenciamento de plano de trabalho na inscrição
vicmagpac Nov 11, 2024
ccd2def
feat: ajusta nome do hook vazio entity registration na validação
vicmagpac Nov 11, 2024
7c70b9d
feat: add validação do plano de trabalho e metas quando enviado a reg…
vicmagpac Nov 11, 2024
ad0c9e6
feat: add form abaixo do de inscrição e remove validação de entrega q…
vicmagpac Nov 11, 2024
6648064
feat: carrega options dos campos selects vindo dos matadados
vicmagpac Nov 12, 2024
6427cdc
feat: melhora mensagens de validação
vicmagpac Nov 12, 2024
86b0c16
feat: adiciona cascade nas dependências da tabela registration
vicmagpac Nov 12, 2024
5a07b98
feat: add hook registration view detalhes
vicmagpac Nov 18, 2024
e89c8b8
feat: adiciona acompanhamento do plano de trabalho nos detalhes da in…
vicmagpac Nov 18, 2024
307b614
Adiciona comandos make como atalhos para devops
lpirola Oct 10, 2024
135417f
feat: valida entregas no backend quando habilitada na oportunidade
vicmagpac Nov 19, 2024
64c1bb6
feat: implementa toggle collapse para as metas na inscrição
vicmagpac Nov 19, 2024
8c3ab20
feat: atualiza options da etapa do fazer cultural
vicmagpac Nov 20, 2024
0aa544f
Adiciona teste básico com phpunit no App
lpirola Nov 12, 2024
b290549
Adiciona teste básico com phpunit no Theme
lpirola Nov 13, 2024
25d6698
Melhora a cobertura de testes com phpunit
lpirola Nov 14, 2024
7348d9f
Adiciona suporte ao github actions e packages
lpirola Nov 20, 2024
da83213
Corrige os testes funcionais no phpunit
lpirola Nov 22, 2024
58a06f9
Merge branch 'feature/plano-de-trabalho-doctrine' into feature/docker…
lpirola Nov 22, 2024
58c138d
Adiciona atalho para importar plano de trabalho
lpirola Nov 22, 2024
58a9ca4
Adiciona plugin para sincronização dos planos de ação do transferegov
lpirola Nov 22, 2024
c3962ef
Adiciona metadados na registration das refs transferegov
lpirola Nov 23, 2024
97f9e73
wip
lpirola Nov 25, 2024
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
Prev Previous commit
Next Next commit
Adiciona Nix Pack como padrão de iamgem docker para nginx, php e nodejs
  • Loading branch information
lpirola committed Nov 7, 2024
commit af2d24345951d9e4086a133166c69829c4b53fa6
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
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)"]

73 changes: 73 additions & 0 deletions .nixpacks/assets/nginx.template.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
worker_processes 5;
daemon off;

worker_rlimit_nofile 8192;

events {
worker_connections 4096; # Default: 1024
}

http {
include $!{nginx}/conf/mime.types;
index index.html index.htm index.php;

default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] $status '
'"$request" $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /dev/stdout;
error_log /dev/stdout;
sendfile on;
tcp_nopush on;
server_names_hash_bucket_size 128; # this seems to be required for some vhosts
client_max_body_size 128M;

server {
listen ${PORT};
listen [::]:${PORT};
server_name localhost;

$if(NIXPACKS_PHP_ROOT_DIR) (
root ${NIXPACKS_PHP_ROOT_DIR};
) else (
root /app;
)

add_header X-Frame-Options "SAMEORIGIN";
add_header X-Content-Type-Options "nosniff";

index index.php;

charset utf-8;

$if(IS_LARAVEL) (
location / {
try_files $uri $uri/ /index.php?$query_string;
}
) else ()

$if(NIXPACKS_PHP_FALLBACK_PATH) (
location / {
try_files $uri $uri/ ${NIXPACKS_PHP_FALLBACK_PATH}?$query_string;
}
) else ()

location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }

$if(IS_LARAVEL) (
error_page 404 /index.php;
) else ()

location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
include $!{nginx}/conf/fastcgi_params;
include $!{nginx}/conf/fastcgi.conf;
}

location ~ /\.(?!well-known).* {
deny all;
}
}
}
10 changes: 10 additions & 0 deletions .nixpacks/assets/php-fpm.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[www]
listen = 127.0.0.1:9000
user = nobody
pm = dynamic
pm.max_children = 50
pm.min_spare_servers = 4
pm.max_spare_servers = 32
pm.start_servers = 18
clear_env = no
catch_workers_output = yes
24 changes: 24 additions & 0 deletions .nixpacks/assets/scripts/config/template.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { readFile, writeFile } from "fs/promises";
import { getNixPath } from "../util/nix.mjs";

const replaceStr = input =>
input
// If statements
.replaceAll(/\$if\s*\((\w+)\)\s*\(([^]*?)\)\s*else\s*\(([^]*?)\)/gm,
(_all, condition, value, otherwise) =>
process.env[condition] ? replaceStr(value) : replaceStr(otherwise)
)
// Variables
.replaceAll(/\${(\w+)}/g,
(_all, name) => process.env[name]
)
// Nix paths
.replaceAll(/\$!{(\w+)}/g,
(_all, exe) => getNixPath(exe)
)

export async function compileTemplate(infile, outfile) {
await writeFile(outfile,
replaceStr(await readFile(infile, { encoding: 'utf8' })),
{ encoding: 'utf8' })
}
24 changes: 24 additions & 0 deletions .nixpacks/assets/scripts/prestart.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env node
import { compileTemplate } from "./config/template.mjs";
import { e } from "./util/cmd.mjs";
import { checkEnvErrors, isLaravel } from "./util/laravel.mjs";
import Logger from "./util/logger.mjs";
import { access, constants } from 'node:fs/promises'

const prestartLogger = new Logger('prestart');
const serverLogger = new Logger('server');

if (process.argv.length != 4) {
prestartLogger.error(`Usage: ${process.argv[1]} <config-file> <output-file>`)
process.exit(1);
}

await Promise.all([
isLaravel() ? checkEnvErrors('/app') : Promise.resolve(),
access('/app/storage', constants.R_OK)
.then(() => e('chmod -R ugo+rw /app/storage'))
.catch(() => {}),
compileTemplate(process.argv[2], process.argv[3])
]).catch(err => prestartLogger.error(err));

serverLogger.info(`Server starting on port ${process.env.PORT}`)
3 changes: 3 additions & 0 deletions .nixpacks/assets/scripts/util/cmd.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { execSync } from "child_process";

export const e = cmd => execSync(cmd).toString().replace('\n', '');
41 changes: 41 additions & 0 deletions .nixpacks/assets/scripts/util/laravel.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import Logger from "./logger.mjs"
import * as fs from 'node:fs/promises'
import * as path from 'node:path'

const variableHints = {
'APP_ENV': 'You should probably set this to `production`.'
};

const logger = new Logger('laravel');

export const isLaravel = () => process.env['IS_LARAVEL'] != null;

function checkVariable(name) {
if (!process.env[name]) {
let hint =
`Your app configuration references the ${name} environment variable, but it is not set.`
+ (variableHints[name] ?? '');

logger.warn(hint);
}
}

export async function checkEnvErrors(srcdir) {
const envRegex = /env\(["']([^,]*)["']\)/g;
const configDir = path.join(srcdir, 'config');

const config =
(await Promise.all(
(await fs.readdir(configDir))
.filter(fileName => fileName.endsWith('.php'))
.map(fileName => fs.readFile(path.join(configDir, fileName)))
)).join('');

for (const match of config.matchAll(envRegex)) {
if (match[1] != 'APP_KEY') checkVariable(match[1]);
}

if (!process.env.APP_KEY) {
logger.warn('Your app key is not set! Please set a random 32-character string in your APP_KEY environment variable. This can be easily generated with `openssl rand -hex 16`.');
}
}
27 changes: 27 additions & 0 deletions .nixpacks/assets/scripts/util/logger.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
export default class Logger {
/** @type string */
#tag;

/**
* @param {string} tag
*/
constructor(tag) {
this.#tag = tag
}

#log(color, messageType, message, fn = console.log) {
fn(`\x1b[${color}m[${this.#tag}:${messageType}]\x1b[0m ${message}`)
}

info(message) {
this.#log(34, 'info', message)
}

warn(message) {
this.#log(35, 'warn', message, console.warn)
}

error(message) {
this.#log(31, 'error', message, console.error)
}
}
3 changes: 3 additions & 0 deletions .nixpacks/assets/scripts/util/nix.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { e } from "./cmd.mjs";

export const getNixPath = (exe) => e(`nix-store -q ${e(`which ${exe}`)}`);
1 change: 1 addition & 0 deletions .nixpacks/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
docker build . -f ./.nixpacks/Dockerfile -t 3df5c547-87c5-4bf6-8791-409a25d3e390 --build-arg NIXPACKS_METADATA=php --build-arg NIXPACKS_PHP_FALLBACK_PATH=/app/public/index.php --build-arg NIXPACKS_PHP_ROOT_DIR=/app/public --build-arg PORT=80 --build-arg POST_MAX_SIZE=128M --build-arg UPLOAD_MAX_FILESIZE=128M
22 changes: 22 additions & 0 deletions .nixpacks/nixpkgs-dbc4f15b899ac77a8d408d8e0f89fa9c0c5f2b78.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{ }:

let pkgs = import (fetchTarball "https://github.com/NixOS/nixpkgs/archive/dbc4f15b899ac77a8d408d8e0f89fa9c0c5f2b78.tar.gz") { overlays = [ (import (builtins.fetchTarball "https://github.com/railwayapp/nix-npm-overlay/archive/main.tar.gz")) ]; };
in with pkgs;
let
APPEND_LIBRARY_PATH = "${lib.makeLibraryPath [ libmysqlclient ] }";
myLibraries = writeText "libraries" ''
export LD_LIBRARY_PATH="${APPEND_LIBRARY_PATH}:$LD_LIBRARY_PATH"

'';
in
buildEnv {
ignoreCollisions = true;
name = "dbc4f15b899ac77a8d408d8e0f89fa9c0c5f2b78-env";
paths = [
(runCommand "dbc4f15b899ac77a8d408d8e0f89fa9c0c5f2b78-env" { } ''
mkdir -p $out/etc/profile.d
cp ${myLibraries} $out/etc/profile.d/dbc4f15b899ac77a8d408d8e0f89fa9c0c5f2b78-env.sh
'')
(php83.withExtensions (pe: pe.enabled ++ [])) libmysqlclient nginx nodejs_18 php83Packages.composer pnpm-9_x
];
}
17 changes: 17 additions & 0 deletions .user.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
expose_php = 0
date.timezone = America/Sao_Paulo
apc.enable_cli = 1
session.use_strict_mode = 1
zend.detect_unicode = 0

; https://symfony.com/doc/current/performance.html
realpath_cache_size = 4096K
realpath_cache_ttl = 600
opcache.interned_strings_buffer = 16
opcache.max_accelerated_files = 20000
opcache.memory_consumption = 256
opcache.enable_file_override = 1
post_max_size = 128M
upload_max_filesize = 128M
memory_limit = 128M
max_file_uploads = 20
8 changes: 7 additions & 1 deletion docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@ services:
- doctrine-files:/app/var/DoctrineProxies/
ports:
- 80
# healthcheck:
# test: ["CMD-SHELL", "curl -f http://localhost || exit 1"]
# interval: 30s # Intervalo entre as verificações de saúde
# timeout: 10s # Tempo limite para cada verificação
# retries: 3 # Número de tentativas antes de marcar como falha
# start_period: 5s # Período de inicialização antes de começar as verificações

database:
image: kartoza/postgis:14
Expand All @@ -70,7 +76,7 @@ services:
DATADIR: ${DATADIR}
volumes:
- db_data:/opt/postgres/data
# - ./dev/db:/docker-entrypoint-initdb.d
- ./dev/db:/docker-entrypoint-initdb.d
ports:
- 5432
healthcheck:
Expand Down
15 changes: 15 additions & 0 deletions nixpacks.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[variables]
NIXPACKS_METADATA="php"
NIXPACKS_PHP_FALLBACK_PATH="/app/public/index.php"
NIXPACKS_PHP_ROOT_DIR="/app/public"
PORT="80"

[phases.setup]
cmds = ['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"']

# [phases.install]
# cmds = ['npm install -g corepack', 'corepack enable', 'corepack prepare pnpm@9.7.1 --activate', 'pnpm install']
# [phases.setup]
# nixPkgs = ["...", "xvfb-run"] # Install the ffmpeg package from Nix
# nixLibs = ["...", "xvfb-run"] # Install the gcc-unwrapped package from Nix and add it to the LD_LIBRARY_PATH
# aptPkgs = ["...", "wget"] # Install the wget package with apt-get
7 changes: 7 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"watch": "pnpm run --parallel --recursive watch",
"postinstall": "sass src/themes/BaseV1/assets/css/sass/main.scss:src/themes/BaseV1/assets/css/main.css"
},
"packageManager": "pnpm@^9",
"devDependencies": {
"fast-glob": "^3.3.2",
"laravel-mix": "^6.0.49",
Expand All @@ -15,5 +16,11 @@
"sass": "^1.77.2",
"sass-loader": "^12.6.0",
"webpack": "^5.91.0"
},
"dependencies": {
"@babel/plugin-proposal-object-rest-spread": "^7.20.7",
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
"@babel/plugin-transform-runtime": "^7.25.7",
"@babel/preset-env": "^7.25.7"
}
}
Loading