-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
65 changed files
with
14,358 additions
and
522 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
name: Check Code Quality | ||
|
||
on: [pull_request] | ||
|
||
jobs: | ||
check-lint-and-build: | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 10 | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Install Node | ||
uses: actions/setup-node@v1 | ||
with: | ||
node-version: 20.x | ||
|
||
- name: Install packages | ||
run: npm install | ||
|
||
- name: Check linting | ||
run: npm run lint:check | ||
|
||
- name: Check build | ||
run: npm run db:generate | ||
|
||
- name: Check build | ||
run: npm run build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,7 +21,6 @@ lerna-debug.log* | |
# Package | ||
/yarn.lock | ||
/pnpm-lock.yaml | ||
/package-lock.json | ||
|
||
# IDEs | ||
.vscode/* | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,17 @@ | ||
FROM node:20-alpine AS builder | ||
|
||
RUN apk update && \ | ||
apk add git ffmpeg wget curl bash | ||
apk add git ffmpeg wget curl bash openssl | ||
|
||
LABEL version="2.2.0" description="Api to control whatsapp features through http requests." | ||
LABEL version="2.2.1" description="Api to control whatsapp features through http requests." | ||
LABEL maintainer="Davidson Gomes" git="https://github.com/DavidsonGomes" | ||
LABEL contact="[email protected]" | ||
|
||
WORKDIR /evolution | ||
|
||
COPY ./package.json ./tsconfig.json ./ | ||
|
||
RUN npm install -f | ||
RUN npm install | ||
|
||
COPY ./src ./src | ||
COPY ./public ./public | ||
|
@@ -32,7 +32,7 @@ RUN npm run build | |
FROM node:20-alpine AS final | ||
|
||
RUN apk update && \ | ||
apk add tzdata ffmpeg bash | ||
apk add tzdata ffmpeg bash openssl | ||
|
||
ENV TZ=America/Sao_Paulo | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,150 @@ | ||
#!/bin/bash | ||
|
||
# Definir cores para melhor legibilidade | ||
RED='\033[0;31m' | ||
GREEN='\033[0;32m' | ||
YELLOW='\033[1;33m' | ||
NC='\033[0m' # No Color | ||
|
||
# Função para log | ||
log() { | ||
echo -e "${GREEN}[INFO]${NC} $1" | ||
} | ||
log_error() { | ||
echo -e "${RED}[ERROR]${NC} $1" | ||
} | ||
log_warning() { | ||
echo -e "${YELLOW}[WARNING]${NC} $1" | ||
} | ||
|
||
# Verificar se está rodando como root | ||
if [ "$(id -u)" = "0" ]; then | ||
log_error "Este script não deve ser executado como root" | ||
exit 1 | ||
fi | ||
|
||
# Verificar sistema operacional | ||
OS="$(uname -s)" | ||
case "${OS}" in | ||
Linux*) | ||
if [ ! -x "$(command -v curl)" ]; then | ||
log_warning "Curl não está instalado. Tentando instalar..." | ||
if [ -x "$(command -v apt-get)" ]; then | ||
sudo apt-get update && sudo apt-get install -y curl | ||
elif [ -x "$(command -v yum)" ]; then | ||
sudo yum install -y curl | ||
else | ||
log_error "Não foi possível instalar curl automaticamente. Por favor, instale manualmente." | ||
exit 1 | ||
fi | ||
fi | ||
;; | ||
Darwin*) | ||
if [ ! -x "$(command -v curl)" ]; then | ||
log_error "Curl não está instalado. Por favor, instale o Xcode Command Line Tools." | ||
exit 1 | ||
fi | ||
;; | ||
*) | ||
log_error "Sistema operacional não suportado: ${OS}" | ||
exit 1 | ||
;; | ||
esac | ||
|
||
# Verificar conexão com a internet antes de prosseguir | ||
if ! ping -c 1 8.8.8.8 &> /dev/null; then | ||
log_error "Sem conexão com a internet. Por favor, verifique sua conexão." | ||
exit 1 | ||
fi | ||
|
||
# Adicionar verificação de espaço em disco | ||
REQUIRED_SPACE=1000000 # 1GB em KB | ||
AVAILABLE_SPACE=$(df -k . | awk 'NR==2 {print $4}') | ||
if [ $AVAILABLE_SPACE -lt $REQUIRED_SPACE ]; then | ||
log_error "Espaço em disco insuficiente. Necessário pelo menos 1GB livre." | ||
exit 1 | ||
fi | ||
|
||
# Adicionar tratamento de erro para comandos npm | ||
npm_install_with_retry() { | ||
local max_attempts=3 | ||
local attempt=1 | ||
|
||
while [ $attempt -le $max_attempts ]; do | ||
log "Tentativa $attempt de $max_attempts para npm install" | ||
if npm install; then | ||
return 0 | ||
fi | ||
attempt=$((attempt + 1)) | ||
[ $attempt -le $max_attempts ] && log_warning "Falha na instalação. Tentando novamente em 5 segundos..." && sleep 5 | ||
done | ||
|
||
log_error "Falha ao executar npm install após $max_attempts tentativas" | ||
return 1 | ||
} | ||
|
||
# Adicionar timeout para comandos | ||
execute_with_timeout() { | ||
timeout 300 $@ || log_error "Comando excedeu o tempo limite de 5 minutos: $@" | ||
} | ||
|
||
# Verificar se o NVM já está instalado | ||
if [ -d "$HOME/.nvm" ]; then | ||
log "NVM já está instalado." | ||
else | ||
log "Instalando NVM..." | ||
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash | ||
fi | ||
|
||
# Carregar o NVM no ambiente atual | ||
export NVM_DIR="$HOME/.nvm" | ||
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" | ||
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" | ||
|
||
# Verificar se a versão do Node.js já está instalada | ||
if command -v node >/dev/null 2>&1 && [ "$(node -v)" = "v20.10.0" ]; then | ||
log "Node.js v20.10.0 já está instalado." | ||
else | ||
log "Instalando Node.js v20.10.0..." | ||
nvm install v20.10.0 | ||
fi | ||
|
||
nvm use v20.10.0 | ||
|
||
# Verificar as versões instaladas | ||
log "Verificando as versões instaladas:" | ||
log "Node.js: $(node -v)" | ||
log "npm: $(npm -v)" | ||
|
||
# Instala dependências do projeto | ||
log "Instalando dependências do projeto..." | ||
rm -rf node_modules | ||
npm install | ||
|
||
# Deploy do banco de dados | ||
log "Deploy do banco de dados..." | ||
npm run db:generate | ||
npm run db:deploy | ||
|
||
# Iniciar o projeto | ||
log "Iniciando o projeto..." | ||
if [ "$1" = "-dev" ]; then | ||
npm run dev:server | ||
else | ||
npm run build | ||
npm run start:prod | ||
fi | ||
|
||
log "Instalação concluída com sucesso!" | ||
|
||
# Criar arquivo de log | ||
LOGFILE="./installation_log_$(date +%Y%m%d_%H%M%S).log" | ||
exec 1> >(tee -a "$LOGFILE") | ||
exec 2>&1 | ||
|
||
# Adicionar trap para limpeza em caso de interrupção | ||
cleanup() { | ||
log "Limpando recursos temporários..." | ||
# Adicione comandos de limpeza aqui | ||
} | ||
trap cleanup EXIT |
Oops, something went wrong.