feat: Add Gitea Actions pipeline and Docker deployment config
Some checks failed
Build and Deploy / build-and-push (push) Failing after 12m54s

This commit is contained in:
Cauê Faleiros
2026-02-20 14:04:34 -03:00
parent c0bd6d7e3d
commit 090f6cff6a
6 changed files with 2197 additions and 0 deletions

View File

@@ -0,0 +1,50 @@
name: Build and Deploy
on:
push:
branches:
- main
- master
jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Convert repository name to lowercase
run: echo "repo_name=${GITHUB_REPOSITORY,,}" >> $GITHUB_ENV
- name: Login to Gitea Registry
uses: docker/login-action@v3
with:
registry: gitea.blyzer.com.br
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: |
gitea.blyzer.com.br/${{ env.repo_name }}:latest
gitea.blyzer.com.br/${{ env.repo_name }}:${{ gitea.sha }}
# Vite requires these variables at BUILD time to embed them in the static files
build-args: |
VITE_SUPABASE_URL=${{ secrets.VITE_SUPABASE_URL }}
VITE_SUPABASE_ANON_KEY=${{ secrets.VITE_SUPABASE_ANON_KEY }}
GEMINI_API_KEY=${{ secrets.GEMINI_API_KEY || '' }}
- name: Deploy to Portainer
run: |
if [ -n "${{ secrets.PORTAINER_WEBHOOK }}" ]; then
curl -k -X POST "${{ secrets.PORTAINER_WEBHOOK }}"
echo "Deployment triggered via Portainer Webhook."
else
echo "PORTAINER_WEBHOOK secret not set, skipping deployment trigger."
fi

30
Dockerfile Normal file
View File

@@ -0,0 +1,30 @@
# Stage 1: Build the React application
FROM node:20-alpine AS builder
WORKDIR /app
COPY package.json package-lock.json ./
RUN npm ci
COPY . .
# Build arguments for Vite environment variables
ARG VITE_SUPABASE_URL
ARG VITE_SUPABASE_ANON_KEY
ARG GEMINI_API_KEY
ENV VITE_SUPABASE_URL=$VITE_SUPABASE_URL
ENV VITE_SUPABASE_ANON_KEY=$VITE_SUPABASE_ANON_KEY
ENV GEMINI_API_KEY=$GEMINI_API_KEY
RUN npm run build
# Stage 2: Serve with Nginx
FROM nginx:alpine
COPY --from=builder /app/dist /usr/share/nginx/html
COPY nginx.conf /etc/nginx/conf.d/default.conf
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]

46
GEMINI.md Normal file
View File

@@ -0,0 +1,46 @@
# GEMINI.md - Project Context & Conventions
## Project Overview
**Name:** car-auto-center (CMS - Automotivo)
**Type:** SPA (Single Page Application)
**Stack:** React 19, TypeScript, Vite, Tailwind CSS
**State Management:** React Context (`DataContext`) + Supabase
**Routing:** React Router v7
## Architecture
- **Entry Point:** `index.tsx` mounts `App.tsx`.
- **Routing:** Defined in `App.tsx`. Includes Public (`/`) and Admin (`/admin`) routes.
- **Data Flow:**
- `contexts/DataContext.tsx` provides global state (settings, content).
- `lib/supabase.ts` handles Supabase connection.
- `data.ts` contains initial/mock data and constants.
- `types.ts` defines all shared TypeScript interfaces.
- **Components:**
- `components/`: Reusable UI components.
- `components/Pages.tsx`: Route page components (Home, About, etc.).
- `components/Admin/`: Admin-specific views (Login, Dashboard).
## Key Technologies
- **Build Tool:** Vite
- **Styling:** Tailwind CSS (utility-first), `clsx`, `tailwind-merge`.
- **Icons:** `lucide-react`.
- **Backend:** Supabase (Auth/DB) - *Note: Local storage fallback usage observed in code.*
## Conventions
- **Naming:** PascalCase for components, camelCase for functions/variables.
- **File Structure:**
- Components co-located in `components/`.
- Pages often aggregated in `Pages.tsx` (consider splitting if growing).
- **Env Vars:** Prefix with `VITE_` for client-side exposure.
- `VITE_SUPABASE_URL`
- `VITE_SUPABASE_ANON_KEY`
## Development
1. **Install:** `npm install`
2. **Dev Server:** `npm run dev` (Port 3000)
3. **Build:** `npm run build`
## Deployment (Pipeline)
- Target: Portainer (Docker).
- Registry: Gitea Container Registry.
- CI/CD: Gitea Actions.

26
docker-compose.yml Normal file
View File

@@ -0,0 +1,26 @@
version: '3.8'
services:
web:
# Adjust the image name to match your Gitea repository owner/name
image: gitea.blyzer.com.br/farelos/cms-automotivo:latest
ports:
# Maps port 80 inside the container to port 8080 on the host (adjust as needed)
- "8080:80"
deploy:
mode: replicated
replicas: 1
restart_policy:
condition: on-failure
update_config:
parallelism: 1
delay: 10s
# Environment variables for runtime configuration (if any are not baked in)
environment:
- NODE_ENV=production
networks:
- app_net
networks:
app_net:
driver: overlay

17
nginx.conf Normal file
View File

@@ -0,0 +1,17 @@
server {
listen 80;
server_name localhost;
root /usr/share/nginx/html;
index index.html;
location / {
try_files $uri $uri/ /index.html;
}
# Optional: Cache control for static assets
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg)$ {
expires 1y;
add_header Cache-Control "public, no-transform";
}
}

2028
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff