diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..4a5d1cc --- /dev/null +++ b/.dockerignore @@ -0,0 +1,5 @@ +node_modules +dist +.git +.env +scripts diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..6b9a5cf --- /dev/null +++ b/Dockerfile @@ -0,0 +1,31 @@ +# Build phase +FROM node:20-alpine AS builder + +WORKDIR /app + +# Copy dependency info +COPY package.json package-lock.json ./ + +# Install all dependencies +RUN npm ci + +# Copy the rest of the application code +COPY . . + +# Build the application +RUN npm run build + +# Serve phase +FROM nginx:alpine + +# Copy the build output to replace the default nginx contents +COPY --from=builder /app/dist /usr/share/nginx/html + +# Copy our custom nginx configuration +COPY nginx.conf /etc/nginx/conf.d/default.conf + +# Expose port 80 +EXPOSE 80 + +# Start nginx +CMD ["nginx", "-g", "daemon off;"] diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 0000000..7e14fb5 --- /dev/null +++ b/nginx.conf @@ -0,0 +1,11 @@ +server { + listen 80; + server_name _; + + root /usr/share/nginx/html; + index index.html; + + location / { + try_files $uri $uri/ /index.html; + } +} diff --git a/scripts/fix-repo-and-push.ts b/scripts/fix-repo-and-push.ts new file mode 100644 index 0000000..6411d99 --- /dev/null +++ b/scripts/fix-repo-and-push.ts @@ -0,0 +1,46 @@ +import { execSync } from 'child_process'; + +const TOKEN = '53c0cc31a6cb27901dd29f1215d4ee5fe5064a19'; +const DOMAIN = 'forgejo.seureview.com.br'; +const USER = 'marciobever'; +const REPO = 'festa-magica-ia'; + +async function updateAndPush() { + try { + console.log(`Tornando o repositório público (${DOMAIN})...`); + const patchRes = await fetch(`https://${DOMAIN}/api/v1/repos/${USER}/${REPO}`, { + method: 'PATCH', + headers: { + 'Authorization': `token ${TOKEN}`, + 'Content-Type': 'application/json' + }, + body: JSON.stringify({ + private: false + }) + }); + + if (!patchRes.ok) { + console.log(`Aviso ao atualizar repo:`, await patchRes.text()); + } else { + console.log('✅ Repositório atualizado para PÚBLICO (resolve o erro de Username/Password no Coolify).'); + } + + console.log('\nAdicionando Dockerfile e arquivos...'); + execSync('git add Dockerfile .dockerignore nginx.conf scripts/fix-repo-and-push.ts', { stdio: 'inherit' }); + + try { + execSync('git commit -m "Adiciona Dockerfile e configuração Nginx para deploy SPA"', { stdio: 'inherit' }); + } catch (e) { + console.log('Nada para commitar.'); + } + + console.log('\nFazendo push do código...'); + execSync('git push origin main', { stdio: 'inherit' }); + + console.log(`\n🎉 Resolvido e push concluído com sucesso!`); + } catch (error: any) { + console.error('\n❌ Ocorreu um erro:', error.message); + } +} + +updateAndPush();