From f074bd9f5af95f7cfe7f831919853dea2e918c86 Mon Sep 17 00:00:00 2001 From: Bxio Date: Sat, 5 Jul 2025 12:33:52 +0100 Subject: [PATCH] --- Dockerfile | 32 +++++++++++++------------------- index.html | 12 ------------ nginx.conf | 14 ++++++++++++++ package.json | 15 +++++++-------- postcss.config.js | 6 ++++++ src/index.css | 3 +++ src/index.jsx | 9 +++++++++ tailwind.config.js | 8 ++++++++ vite.config.js | 13 +++++++++++++ 9 files changed, 73 insertions(+), 39 deletions(-) delete mode 100644 index.html create mode 100644 nginx.conf create mode 100644 postcss.config.js create mode 100644 src/index.css create mode 100644 src/index.jsx create mode 100644 tailwind.config.js create mode 100644 vite.config.js diff --git a/Dockerfile b/Dockerfile index e767cb8..04f5e78 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,34 +1,28 @@ -############################ -# 1️⃣ BUILD STAGE -############################ -FROM node:20-alpine AS builder +# Stage 1: Build +FROM node:18-alpine AS builder -# Define diretório de trabalho WORKDIR /app -# Copia os manifests de dependências -COPY package*.json ./ +COPY package.json package-lock.json* ./ -# Instala dependências -RUN npm install +RUN npm ci -# Copia o restante do código COPY . . -# Builda para produção RUN npm run build - -############################ -# 2️⃣ NGINX STAGE -############################ +# Stage 2: Serve com Nginx FROM nginx:alpine -# Copia o build pronto para a pasta que o NGINX serve +# Copia build estático do stage anterior COPY --from=builder /app/dist /usr/share/nginx/html -# Exponha a porta padrão do NGINX +# Remove configuração default do nginx +RUN rm /etc/nginx/conf.d/default.conf + +# Copia config customizada (você pode criar o arquivo nginx.conf ao lado do Dockerfile) +COPY nginx.conf /etc/nginx/conf.d/ + EXPOSE 80 -# Comando default do NGINX -CMD ["nginx", "-g", "daemon off;"] +CMD ["nginx", "-g", "daemon off;"] \ No newline at end of file diff --git a/index.html b/index.html deleted file mode 100644 index 0dafaa3..0000000 --- a/index.html +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - Vite + React + TS - - -
- - \ No newline at end of file diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 0000000..aa8a899 --- /dev/null +++ b/nginx.conf @@ -0,0 +1,14 @@ +server { + listen 80; + server_name _; + + root /usr/share/nginx/html; + index index.html; + + location / { + try_files $uri $uri/ /index.html; + } + + gzip on; + gzip_types text/plain application/javascript application/json text/css application/xml; +} \ No newline at end of file diff --git a/package.json b/package.json index 4781383..452ff35 100644 --- a/package.json +++ b/package.json @@ -1,9 +1,8 @@ { - "name": "meu-app", + "name": "vite-react-tailwind", "version": "1.0.0", - "private": true, "scripts": { - "dev": "vite --port 3000", + "dev": "vite", "build": "vite build", "preview": "vite preview" }, @@ -12,10 +11,10 @@ "react-dom": "^18.2.0" }, "devDependencies": { - "vite": "^5.2.0", - "@vitejs/plugin-react": "^4.0.0", - "tailwindcss": "^4.0.0-beta.3", - "postcss": "^8.4.35", - "autoprefixer": "^10.4.16" + "vite": "^4.0.0", + "tailwindcss": "^3.3.2", + "postcss": "^8.4.21", + "autoprefixer": "^10.4.14", + "@vitejs/plugin-react": "^3.1.0" } } \ No newline at end of file diff --git a/postcss.config.js b/postcss.config.js new file mode 100644 index 0000000..96bb01e --- /dev/null +++ b/postcss.config.js @@ -0,0 +1,6 @@ +module.exports = { + plugins: { + tailwindcss: {}, + autoprefixer: {}, + }, +} \ No newline at end of file diff --git a/src/index.css b/src/index.css new file mode 100644 index 0000000..bd6213e --- /dev/null +++ b/src/index.css @@ -0,0 +1,3 @@ +@tailwind base; +@tailwind components; +@tailwind utilities; \ No newline at end of file diff --git a/src/index.jsx b/src/index.jsx new file mode 100644 index 0000000..eba282c --- /dev/null +++ b/src/index.jsx @@ -0,0 +1,9 @@ +import React from 'react' +import ReactDOM from 'react-dom/client' +import './index.css' + +function App() { + return

Olá, Docker + React + Vite + Tailwind!

+} + +ReactDOM.createRoot(document.getElementById('root')).render() \ No newline at end of file diff --git a/tailwind.config.js b/tailwind.config.js new file mode 100644 index 0000000..6e15e5f --- /dev/null +++ b/tailwind.config.js @@ -0,0 +1,8 @@ +/** @type {import('tailwindcss').Config} */ +module.exports = { + content: ["./index.html", "./src/**/*.{js,jsx,ts,tsx}"], + theme: { + extend: {}, + }, + plugins: [], +} \ No newline at end of file diff --git a/vite.config.js b/vite.config.js new file mode 100644 index 0000000..16f49d0 --- /dev/null +++ b/vite.config.js @@ -0,0 +1,13 @@ +import { defineConfig } from 'vite' +import react from '@vitejs/plugin-react' + +export default defineConfig({ + plugins: [react()], + server: { + port: 3000, // Porta para dev server (opcional) + open: true // Abre navegador automaticamente (opcional) + }, + build: { + outDir: 'dist' // Diretório de saída padrão (você pode mudar se quiser) + } +}) \ No newline at end of file