Raí Santos commited on
Commit ·
65f788b
1
Parent(s): d94ca3a
oi
Browse files- Dockerfile +51 -17
- Makefile +92 -0
- README.md +115 -0
- docker-compose.yml +32 -5
- docker-entrypoint.sh +43 -0
Dockerfile
CHANGED
|
@@ -1,34 +1,68 @@
|
|
| 1 |
-
#
|
| 2 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
|
| 4 |
-
# Set working directory in container
|
| 5 |
WORKDIR /app
|
| 6 |
|
| 7 |
# Copy package files
|
| 8 |
COPY package*.json ./
|
| 9 |
|
| 10 |
-
# Install dependencies
|
| 11 |
-
RUN npm ci
|
| 12 |
-
|
| 13 |
-
RUN npm run download
|
| 14 |
|
| 15 |
-
# Copy application files
|
| 16 |
COPY . .
|
| 17 |
|
| 18 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
RUN addgroup -g 1001 -S nodejs && \
|
| 20 |
-
adduser -S
|
| 21 |
|
| 22 |
-
#
|
| 23 |
-
|
| 24 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
|
| 26 |
# Expose port
|
| 27 |
EXPOSE 7860
|
| 28 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
# Health check
|
| 30 |
-
HEALTHCHECK --interval=30s --timeout=3s --start-period=
|
| 31 |
-
CMD node -e "require('http').get('http://localhost:7860/
|
| 32 |
|
| 33 |
-
# Start the application
|
| 34 |
-
|
|
|
|
| 1 |
+
# Multi-stage build for optimized production image
|
| 2 |
+
# Stage 1: Build dependencies and download media
|
| 3 |
+
FROM node:18-alpine AS builder
|
| 4 |
+
|
| 5 |
+
# Install curl for downloading (if needed)
|
| 6 |
+
RUN apk add --no-cache curl
|
| 7 |
|
|
|
|
| 8 |
WORKDIR /app
|
| 9 |
|
| 10 |
# Copy package files
|
| 11 |
COPY package*.json ./
|
| 12 |
|
| 13 |
+
# Install ALL dependencies (including devDependencies for scripts)
|
| 14 |
+
RUN npm ci && npm cache clean --force
|
|
|
|
|
|
|
| 15 |
|
| 16 |
+
# Copy application files and scripts
|
| 17 |
COPY . .
|
| 18 |
|
| 19 |
+
# Download videos and audio files (with error handling)
|
| 20 |
+
RUN npm run download || echo "Warning: Video download failed, will use CDN fallback"
|
| 21 |
+
|
| 22 |
+
# Build production assets
|
| 23 |
+
RUN npm run build || echo "Build step skipped"
|
| 24 |
+
|
| 25 |
+
# Stage 2: Production image
|
| 26 |
+
FROM node:18-alpine AS production
|
| 27 |
+
|
| 28 |
+
WORKDIR /app
|
| 29 |
+
|
| 30 |
+
# Copy package files
|
| 31 |
+
COPY package*.json ./
|
| 32 |
+
|
| 33 |
+
# Install ONLY production dependencies
|
| 34 |
+
RUN npm ci --only=production && npm cache clean --force
|
| 35 |
+
|
| 36 |
+
# Create non-root user for security FIRST
|
| 37 |
RUN addgroup -g 1001 -S nodejs && \
|
| 38 |
+
adduser -S nodejs -u 1001 -G nodejs
|
| 39 |
|
| 40 |
+
# Copy entrypoint script as root and make executable
|
| 41 |
+
COPY docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh
|
| 42 |
+
RUN chmod +x /usr/local/bin/docker-entrypoint.sh
|
| 43 |
+
|
| 44 |
+
# Copy built application from builder
|
| 45 |
+
COPY --from=builder /app/public ./public
|
| 46 |
+
COPY --from=builder /app/dist ./dist
|
| 47 |
+
COPY --from=builder /app/server.js ./server.js
|
| 48 |
+
COPY --from=builder /app/scripts ./scripts
|
| 49 |
+
|
| 50 |
+
# Change ownership of app directory to nodejs user
|
| 51 |
+
RUN chown -R nodejs:nodejs /app
|
| 52 |
+
|
| 53 |
+
# Switch to non-root user
|
| 54 |
+
USER nodejs
|
| 55 |
|
| 56 |
# Expose port
|
| 57 |
EXPOSE 7860
|
| 58 |
|
| 59 |
+
# Set environment variables
|
| 60 |
+
ENV NODE_ENV=production
|
| 61 |
+
ENV PORT=7860
|
| 62 |
+
|
| 63 |
# Health check
|
| 64 |
+
HEALTHCHECK --interval=30s --timeout=3s --start-period=10s --retries=3 \
|
| 65 |
+
CMD node -e "require('http').get('http://localhost:7860/', (res) => { process.exit(res.statusCode === 200 ? 0 : 1) })"
|
| 66 |
|
| 67 |
+
# Start the application using entrypoint script
|
| 68 |
+
ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
|
Makefile
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
.PHONY: help build up down logs restart clean rebuild test health
|
| 2 |
+
|
| 3 |
+
# Variáveis
|
| 4 |
+
IMAGE_NAME = fitness-app
|
| 5 |
+
CONTAINER_NAME = fitness-app
|
| 6 |
+
PORT = 7860
|
| 7 |
+
|
| 8 |
+
help: ## Mostra esta mensagem de ajuda
|
| 9 |
+
@echo "🏋️ Fitness App - Comandos Disponíveis:"
|
| 10 |
+
@echo ""
|
| 11 |
+
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-15s\033[0m %s\n", $$1, $$2}'
|
| 12 |
+
|
| 13 |
+
build: ## Build da imagem Docker
|
| 14 |
+
@echo "🔨 Construindo imagem Docker..."
|
| 15 |
+
docker-compose build
|
| 16 |
+
|
| 17 |
+
up: ## Inicia o container
|
| 18 |
+
@echo "🚀 Iniciando container..."
|
| 19 |
+
docker-compose up -d
|
| 20 |
+
@echo "✅ App disponível em http://localhost:$(PORT)"
|
| 21 |
+
|
| 22 |
+
down: ## Para e remove o container
|
| 23 |
+
@echo "🛑 Parando container..."
|
| 24 |
+
docker-compose down
|
| 25 |
+
|
| 26 |
+
logs: ## Mostra os logs do container
|
| 27 |
+
@echo "📋 Logs do container:"
|
| 28 |
+
docker-compose logs -f fitness-app
|
| 29 |
+
|
| 30 |
+
restart: ## Reinicia o container
|
| 31 |
+
@echo "🔄 Reiniciando container..."
|
| 32 |
+
docker-compose restart
|
| 33 |
+
@echo "✅ Container reiniciado!"
|
| 34 |
+
|
| 35 |
+
clean: ## Remove container, imagem e volumes
|
| 36 |
+
@echo "🧹 Limpando tudo..."
|
| 37 |
+
docker-compose down -v
|
| 38 |
+
docker rmi $(IMAGE_NAME) 2>/dev/null || true
|
| 39 |
+
@echo "✅ Limpeza completa!"
|
| 40 |
+
|
| 41 |
+
rebuild: ## Reconstrói e reinicia o container
|
| 42 |
+
@echo "🔨 Reconstruindo do zero..."
|
| 43 |
+
docker-compose down
|
| 44 |
+
docker-compose build --no-cache
|
| 45 |
+
docker-compose up -d
|
| 46 |
+
@echo "✅ Rebuild completo! App em http://localhost:$(PORT)"
|
| 47 |
+
|
| 48 |
+
test: ## Testa se o app está respondendo
|
| 49 |
+
@echo "🧪 Testando app..."
|
| 50 |
+
@curl -f http://localhost:$(PORT) > /dev/null 2>&1 && echo "✅ App está funcionando!" || echo "❌ App não está respondendo"
|
| 51 |
+
|
| 52 |
+
health: ## Verifica o status de saúde do container
|
| 53 |
+
@echo "💊 Status de Saúde:"
|
| 54 |
+
@docker inspect --format='{{.State.Health.Status}}' $(CONTAINER_NAME) 2>/dev/null || echo "Container não está rodando"
|
| 55 |
+
|
| 56 |
+
shell: ## Abre um shell no container
|
| 57 |
+
@echo "🐚 Abrindo shell..."
|
| 58 |
+
docker-compose exec fitness-app sh
|
| 59 |
+
|
| 60 |
+
install: ## Instala dependências localmente
|
| 61 |
+
@echo "📦 Instalando dependências..."
|
| 62 |
+
npm install
|
| 63 |
+
@echo "✅ Dependências instaladas!"
|
| 64 |
+
|
| 65 |
+
download: ## Baixa vídeos e áudios
|
| 66 |
+
@echo "📥 Baixando mídia..."
|
| 67 |
+
npm run download
|
| 68 |
+
@echo "✅ Download completo!"
|
| 69 |
+
|
| 70 |
+
dev: ## Inicia em modo desenvolvimento
|
| 71 |
+
@echo "🔧 Modo desenvolvimento..."
|
| 72 |
+
npm run dev
|
| 73 |
+
|
| 74 |
+
prod-build: ## Build de produção local
|
| 75 |
+
@echo "🏗️ Build de produção..."
|
| 76 |
+
npm run build
|
| 77 |
+
@echo "✅ Build completo em ./dist"
|
| 78 |
+
|
| 79 |
+
start: ## Inicia servidor local (sem Docker)
|
| 80 |
+
@echo "▶️ Iniciando servidor..."
|
| 81 |
+
npm start
|
| 82 |
+
|
| 83 |
+
# Comandos compostos
|
| 84 |
+
setup: install download prod-build ## Setup completo (install + download + build)
|
| 85 |
+
@echo "✅ Setup completo!"
|
| 86 |
+
|
| 87 |
+
docker-setup: build up ## Setup Docker completo
|
| 88 |
+
@echo "✅ Docker setup completo!"
|
| 89 |
+
|
| 90 |
+
all: setup docker-setup ## Setup completo local + Docker
|
| 91 |
+
@echo "🎉 Tudo pronto!"
|
| 92 |
+
|
README.md
CHANGED
|
@@ -89,10 +89,125 @@ Seguindo o plano à risca, você pode esperar:
|
|
| 89 |
|
| 90 |
Lembre-se: você é mais forte do que imagina! Cada dia é uma vitória, cada escolha é um passo em direção à sua melhor versão.
|
| 91 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 92 |
## 🔒 Privacidade
|
| 93 |
|
| 94 |
Todos os seus dados ficam salvos localmente no seu dispositivo. Nenhuma informação pessoal é enviada para servidores externos.
|
| 95 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 96 |
---
|
| 97 |
|
| 98 |
**Feito com 💜 para sua transformação!**
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 89 |
|
| 90 |
Lembre-se: você é mais forte do que imagina! Cada dia é uma vitória, cada escolha é um passo em direção à sua melhor versão.
|
| 91 |
|
| 92 |
+
## 🐳 Executando com Docker
|
| 93 |
+
|
| 94 |
+
### Opção 1: Docker Compose (Recomendado)
|
| 95 |
+
|
| 96 |
+
```bash
|
| 97 |
+
# Clone o repositório
|
| 98 |
+
git clone <seu-repositorio>
|
| 99 |
+
cd k
|
| 100 |
+
|
| 101 |
+
# Construa e inicie o container
|
| 102 |
+
docker-compose up -d
|
| 103 |
+
|
| 104 |
+
# Acesse em: http://localhost:7860
|
| 105 |
+
```
|
| 106 |
+
|
| 107 |
+
### Opção 2: Docker Build Manual
|
| 108 |
+
|
| 109 |
+
```bash
|
| 110 |
+
# Build da imagem
|
| 111 |
+
docker build -t fitness-app .
|
| 112 |
+
|
| 113 |
+
# Execute o container
|
| 114 |
+
docker run -d \
|
| 115 |
+
--name fitness-app \
|
| 116 |
+
-p 7860:7860 \
|
| 117 |
+
--restart unless-stopped \
|
| 118 |
+
fitness-app
|
| 119 |
+
|
| 120 |
+
# Acesse em: http://localhost:7860
|
| 121 |
+
```
|
| 122 |
+
|
| 123 |
+
### Comandos Úteis
|
| 124 |
+
|
| 125 |
+
```bash
|
| 126 |
+
# Ver logs
|
| 127 |
+
docker-compose logs -f fitness-app
|
| 128 |
+
|
| 129 |
+
# Parar o container
|
| 130 |
+
docker-compose down
|
| 131 |
+
|
| 132 |
+
# Reconstruir após alterações
|
| 133 |
+
docker-compose up -d --build
|
| 134 |
+
|
| 135 |
+
# Ver status de saúde
|
| 136 |
+
docker ps
|
| 137 |
+
```
|
| 138 |
+
|
| 139 |
+
### Recursos do Container
|
| 140 |
+
|
| 141 |
+
- **CPU**: 1 core (limite), 0.5 core (reservado)
|
| 142 |
+
- **Memória**: 512MB (limite), 256MB (reservado)
|
| 143 |
+
- **Porta**: 7860
|
| 144 |
+
- **Health Check**: A cada 30s
|
| 145 |
+
|
| 146 |
+
## 💻 Desenvolvimento Local
|
| 147 |
+
|
| 148 |
+
### Pré-requisitos
|
| 149 |
+
|
| 150 |
+
- Node.js 18+
|
| 151 |
+
- npm ou yarn
|
| 152 |
+
|
| 153 |
+
### Instalação
|
| 154 |
+
|
| 155 |
+
```bash
|
| 156 |
+
# Instalar dependências
|
| 157 |
+
npm install
|
| 158 |
+
|
| 159 |
+
# Baixar vídeos e áudios (31 MB)
|
| 160 |
+
npm run download
|
| 161 |
+
|
| 162 |
+
# Build de produção
|
| 163 |
+
npm run build
|
| 164 |
+
|
| 165 |
+
# Iniciar servidor
|
| 166 |
+
npm start
|
| 167 |
+
```
|
| 168 |
+
|
| 169 |
+
### Scripts Disponíveis
|
| 170 |
+
|
| 171 |
+
- `npm start` - Inicia o servidor de produção
|
| 172 |
+
- `npm run dev` - Modo desenvolvimento com nodemon
|
| 173 |
+
- `npm run build` - Build de produção otimizado
|
| 174 |
+
- `npm run download` - Baixa vídeos e áudios do Hugging Face
|
| 175 |
+
- `npm run analyze` - Analisa o bundle
|
| 176 |
+
|
| 177 |
+
## 📊 Performance
|
| 178 |
+
|
| 179 |
+
- **Bundle Gzipped**: 33.45 KB (86.3% de compressão)
|
| 180 |
+
- **Load Time 3G**: 0.36s
|
| 181 |
+
- **Load Time 4G**: 0.05s
|
| 182 |
+
- **Offline**: 100% funcional (PWA + Service Worker)
|
| 183 |
+
- **Vídeos**: 14 vídeos locais (31 MB total)
|
| 184 |
+
- **Cache Strategy**: LRU com limite de 20 vídeos
|
| 185 |
+
|
| 186 |
## 🔒 Privacidade
|
| 187 |
|
| 188 |
Todos os seus dados ficam salvos localmente no seu dispositivo. Nenhuma informação pessoal é enviada para servidores externos.
|
| 189 |
|
| 190 |
+
## 📝 Licença
|
| 191 |
+
|
| 192 |
+
MIT License - Veja o arquivo LICENSE para mais detalhes.
|
| 193 |
+
|
| 194 |
---
|
| 195 |
|
| 196 |
**Feito com 💜 para sua transformação!**
|
| 197 |
+
|
| 198 |
+
## 🐛 Correções Recentes
|
| 199 |
+
|
| 200 |
+
### v3.5.0 (Atual)
|
| 201 |
+
✅ **Vídeos e Áudios Locais**: Migrados do Hugging Face CDN para local (31 MB)
|
| 202 |
+
✅ **Modal de Notificações**: Corrigido bug que impedia fechar
|
| 203 |
+
✅ **Performance**: Bundle 86% menor (gzipped)
|
| 204 |
+
✅ **Docker**: Multi-stage build otimizado
|
| 205 |
+
✅ **Security**: Removido onclick inline
|
| 206 |
+
✅ **Service Worker**: Cache separado para vídeos e áudios
|
| 207 |
+
|
| 208 |
+
### Bugs Corrigidos
|
| 209 |
+
- ✅ Botão × do modal de notificações não funcionava
|
| 210 |
+
- ✅ Botões "Marcar como Lidas" e "Limpar Todas" não respondiam
|
| 211 |
+
- ✅ onclick inline substituído por event listeners seguros
|
| 212 |
+
- ✅ Vídeos não carregavam do Hugging Face
|
| 213 |
+
- ✅ Build Docker falhava ao baixar mídia
|
docker-compose.yml
CHANGED
|
@@ -1,17 +1,44 @@
|
|
| 1 |
version: '3.8'
|
| 2 |
|
| 3 |
services:
|
| 4 |
-
|
| 5 |
-
build:
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
ports:
|
| 7 |
- "7860:7860"
|
| 8 |
environment:
|
| 9 |
- NODE_ENV=production
|
| 10 |
- PORT=7860
|
| 11 |
restart: unless-stopped
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
healthcheck:
|
| 13 |
-
test: ["CMD", "node", "-e", "require('http').get('http://localhost:7860/
|
| 14 |
interval: 30s
|
| 15 |
-
timeout:
|
| 16 |
retries: 3
|
| 17 |
-
start_period:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
version: '3.8'
|
| 2 |
|
| 3 |
services:
|
| 4 |
+
fitness-app:
|
| 5 |
+
build:
|
| 6 |
+
context: .
|
| 7 |
+
dockerfile: Dockerfile
|
| 8 |
+
target: production
|
| 9 |
+
container_name: fitness-app
|
| 10 |
ports:
|
| 11 |
- "7860:7860"
|
| 12 |
environment:
|
| 13 |
- NODE_ENV=production
|
| 14 |
- PORT=7860
|
| 15 |
restart: unless-stopped
|
| 16 |
+
|
| 17 |
+
# Volume for persistent data (optional - if you want to persist user data)
|
| 18 |
+
# volumes:
|
| 19 |
+
# - ./data:/app/data
|
| 20 |
+
|
| 21 |
+
# Resource limits (adjust based on your needs)
|
| 22 |
+
deploy:
|
| 23 |
+
resources:
|
| 24 |
+
limits:
|
| 25 |
+
cpus: '1'
|
| 26 |
+
memory: 512M
|
| 27 |
+
reservations:
|
| 28 |
+
cpus: '0.5'
|
| 29 |
+
memory: 256M
|
| 30 |
+
|
| 31 |
+
# Health check
|
| 32 |
healthcheck:
|
| 33 |
+
test: ["CMD", "node", "-e", "require('http').get('http://localhost:7860/', (res) => { process.exit(res.statusCode === 200 ? 0 : 1) })"]
|
| 34 |
interval: 30s
|
| 35 |
+
timeout: 5s
|
| 36 |
retries: 3
|
| 37 |
+
start_period: 15s
|
| 38 |
+
|
| 39 |
+
# Logging configuration
|
| 40 |
+
logging:
|
| 41 |
+
driver: "json-file"
|
| 42 |
+
options:
|
| 43 |
+
max-size: "10m"
|
| 44 |
+
max-file: "3"
|
docker-entrypoint.sh
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/sh
|
| 2 |
+
set -e
|
| 3 |
+
|
| 4 |
+
echo "🚀 Starting Fitness App..."
|
| 5 |
+
|
| 6 |
+
# Check if videos directory exists and has files
|
| 7 |
+
if [ ! -d "/app/public/videos" ] || [ -z "$(ls -A /app/public/videos 2>/dev/null)" ]; then
|
| 8 |
+
echo "📥 Videos directory is empty, attempting to download..."
|
| 9 |
+
if npm run download 2>/dev/null; then
|
| 10 |
+
echo "✅ Videos downloaded successfully!"
|
| 11 |
+
else
|
| 12 |
+
echo "⚠️ Video download failed, app will use CDN fallback"
|
| 13 |
+
fi
|
| 14 |
+
else
|
| 15 |
+
VIDEO_COUNT=$(ls -1 /app/public/videos/*.mp4 2>/dev/null | wc -l)
|
| 16 |
+
echo "✅ Found $VIDEO_COUNT video files"
|
| 17 |
+
fi
|
| 18 |
+
|
| 19 |
+
# Check if audio directory exists and has files
|
| 20 |
+
if [ ! -d "/app/public/songs" ] || [ -z "$(ls -A /app/public/songs 2>/dev/null)" ]; then
|
| 21 |
+
echo "📥 Audio directory is empty"
|
| 22 |
+
echo "⚠️ Audio files missing, some features may not work"
|
| 23 |
+
else
|
| 24 |
+
AUDIO_COUNT=$(ls -1 /app/public/songs/*.{mp3,ogg} 2>/dev/null | wc -l)
|
| 25 |
+
echo "✅ Found $AUDIO_COUNT audio files"
|
| 26 |
+
fi
|
| 27 |
+
|
| 28 |
+
# Check if dist directory exists (production build)
|
| 29 |
+
if [ -d "/app/dist" ]; then
|
| 30 |
+
echo "✅ Production build found"
|
| 31 |
+
else
|
| 32 |
+
echo "⚠️ No production build found, using development files"
|
| 33 |
+
fi
|
| 34 |
+
|
| 35 |
+
# Print environment info
|
| 36 |
+
echo "📊 Environment: $NODE_ENV"
|
| 37 |
+
echo "🌐 Port: ${PORT:-7860}"
|
| 38 |
+
echo "👤 Running as: $(whoami)"
|
| 39 |
+
|
| 40 |
+
# Start the application
|
| 41 |
+
echo "🎯 Starting server..."
|
| 42 |
+
exec node server.js
|
| 43 |
+
|