jesus
This commit is contained in:
parent
93d603da6c
commit
18c0601b11
6 changed files with 112 additions and 4 deletions
27
backend/.forgejo/workflows/deploy.yaml
Normal file
27
backend/.forgejo/workflows/deploy.yaml
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
name: K3s Auto-Deploy
|
||||
on: [push]
|
||||
|
||||
jobs:
|
||||
build-and-deploy:
|
||||
runs-on: self-hosted
|
||||
steps:
|
||||
- name: Checkout Code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Build and Push Image
|
||||
run: |
|
||||
# Logando com o token que você já gerou
|
||||
echo "${{ secrets.FORGEJO_TOKEN }}" | docker login git.saveinmed.com.br -u ${{ github.actor }} --password-stdin
|
||||
|
||||
# Build e Push automáticos
|
||||
docker build -t git.saveinmed.com.br/${{ github.repository }}:latest .
|
||||
docker push git.saveinmed.com.br/${{ github.repository }}:latest
|
||||
|
||||
- name: Deploy to K3s
|
||||
run: |
|
||||
# Aplica os arquivos da pasta k8s
|
||||
kubectl apply -f k8s/deployment.yaml
|
||||
kubectl apply -f k8s/service.yaml
|
||||
|
||||
# AJUSTE AQUI: Use o nome que está no seu metadata.name do deployment.yaml
|
||||
kubectl rollout restart deployment/photum-backend -n photum
|
||||
37
backend/k8s/deployment.yaml
Normal file
37
backend/k8s/deployment.yaml
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: photum-backend
|
||||
namespace: photum
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app: photum
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: photum
|
||||
spec:
|
||||
imagePullSecrets:
|
||||
- name: forgejo-registry-secret
|
||||
containers:
|
||||
- name: photum-app
|
||||
image: git.saveinmed.com.br/yamamoto/photum:latest
|
||||
ports:
|
||||
- containerPort: 8080
|
||||
env:
|
||||
- name: APP_ENV
|
||||
value: "dev"
|
||||
- name: APP_PORT
|
||||
value: "8080"
|
||||
- name: DB_DSN
|
||||
value: "postgres://lol:k4m4d483@postgresql-207025-0.cloudclusters.net:10110/photum?sslmode=disable"
|
||||
- name: JWT_ACCESS_SECRET
|
||||
value: "supersecretkey"
|
||||
- name: JWT_REFRESH_SECRET
|
||||
value: "superrefreshsecret"
|
||||
- name: JWT_ACCESS_TTL_MINUTES
|
||||
value: "15"
|
||||
- name: JWT_REFRESH_TTL_DAYS
|
||||
value: "30"
|
||||
29
backend/k8s/ingress.yaml
Normal file
29
backend/k8s/ingress.yaml
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
apiVersion: networking.k8s.io/v1
|
||||
kind: Ingress
|
||||
metadata:
|
||||
name: photum-ingress
|
||||
namespace: photum
|
||||
annotations:
|
||||
# Emite o certificado SSL automaticamente
|
||||
cert-manager.io/cluster-issuer: letsencrypt-prod
|
||||
# Define o Traefik como controlador
|
||||
kubernetes.io/ingress.class: traefik
|
||||
# Comando para o External-DNS criar o registro no Cloudflare
|
||||
external-dns.alpha.kubernetes.io/hostname: api-dev.photum.app.br
|
||||
spec:
|
||||
tls:
|
||||
- hosts:
|
||||
- api-dev.photum.app.br
|
||||
# O certificado será armazenado neste secret
|
||||
secretName: photum-tls-cert
|
||||
rules:
|
||||
- host: api-dev.photum.app.br
|
||||
http:
|
||||
paths:
|
||||
- path: /
|
||||
pathType: Prefix
|
||||
backend:
|
||||
service:
|
||||
name: photum-service
|
||||
port:
|
||||
number: 80
|
||||
12
backend/k8s/service.yaml
Normal file
12
backend/k8s/service.yaml
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: photum-service
|
||||
namespace: photum
|
||||
spec:
|
||||
selector:
|
||||
app: photum
|
||||
ports:
|
||||
- protocol: TCP
|
||||
port: 80
|
||||
targetPort: 8080 # A porta que você definiu na variável APP_PORT
|
||||
|
|
@ -12,7 +12,7 @@ VITE_MAPBOX_TOKEN=YOUR_MAPBOX_TOKEN_HERE
|
|||
# Configure a URL base do seu backend API
|
||||
# Default: http://localhost:3000/api
|
||||
|
||||
VITE_API_URL=http://localhost:3000/api
|
||||
VITE_API_URL=http://localhost:8080/api
|
||||
|
||||
# Nota: A chave do Mapbox já está configurada diretamente no código para demonstração
|
||||
# Em produção, use variáveis de ambiente como acima
|
||||
|
|
|
|||
|
|
@ -61,7 +61,8 @@ export const AuthProvider: React.FC<{ children: ReactNode }> = ({ children }) =>
|
|||
if (!token) return;
|
||||
|
||||
try {
|
||||
const response = await fetch(`${import.meta.env.VITE_API_URL}/api/me`, {
|
||||
const API_URL = import.meta.env.VITE_API_URL || "http://localhost:8080";
|
||||
const response = await fetch(`${API_URL}/api/me`, {
|
||||
headers: {
|
||||
'Authorization': `Bearer ${token}`
|
||||
}
|
||||
|
|
@ -123,10 +124,12 @@ export const AuthProvider: React.FC<{ children: ReactNode }> = ({ children }) =>
|
|||
return "Ocorreu um erro inesperado. Tente novamente.";
|
||||
};
|
||||
|
||||
const login = async (email: string, password?: string) => {
|
||||
const API_URL = import.meta.env.VITE_API_URL || "http://localhost:8080";
|
||||
|
||||
const login = async (email: string, password?: string) => {
|
||||
// 1. Try Real API first
|
||||
try {
|
||||
const response = await fetch(`${import.meta.env.VITE_API_URL}/auth/login`, {
|
||||
const response = await fetch(`${API_URL}/auth/login`, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ email, senha: password })
|
||||
|
|
|
|||
Loading…
Reference in a new issue