Merge branch 'hml' into dev

This commit is contained in:
Tiago Yamamoto 2025-12-13 16:51:06 -03:00
commit e0288e91e5
3 changed files with 120 additions and 0 deletions

76
.drone.yml Normal file
View file

@ -0,0 +1,76 @@
kind: pipeline
type: kubernetes
name: deploy-backend
# ✅ SERVICE ACCOUNT CORRETO (CLUSTER-WIDE)
service_account_name: drone-deployer
steps:
- name: build-and-push-backend
image: plugins/docker:latest
settings:
registry: in.gohorsejobs.com
repo: in.gohorsejobs.com/gohorsejobs/gohorsejobs-backend
tags:
- latest
context: backend
dockerfile: backend/Dockerfile
insecure: true
insecure_skip_verify: true
username:
from_secret: HARBOR_USERNAME
password:
from_secret: HARBOR_PASSWORD
- name: export-envs-to-k8s
image: bitnami/kubectl:latest
environment:
AWS_ACCESS_KEY_ID: { from_secret: AWS_ACCESS_KEY_ID }
AWS_ENDPOINT: { from_secret: AWS_ENDPOINT }
AWS_REGION: { from_secret: AWS_REGION }
AWS_SECRET_ACCESS_KEY: { from_secret: AWS_SECRET_ACCESS_KEY }
CORS_ORIGINS: { from_secret: CORS_ORIGINS }
DB_HOST: { from_secret: DB_HOST }
DB_NAME: { from_secret: DB_NAME }
DB_PASSWORD: { from_secret: DB_PASSWORD }
DB_PORT: { from_secret: DB_PORT }
DB_SSLMODE: { from_secret: DB_SSLMODE }
DB_USER: { from_secret: DB_USER }
ENV: { from_secret: ENV }
JWT_SECRET: { from_secret: JWT_SECRET }
MAX_UPLOAD_CAD_SIZE: { from_secret: MAX_UPLOAD_CAD_SIZE }
PORT: { from_secret: PORT }
S3_BUCKET: { from_secret: S3_BUCKET }
UPLOAD_DIR: { from_secret: UPLOAD_DIR }
commands:
- |
cat <<EOF > .env.k8s
AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID
AWS_ENDPOINT=$AWS_ENDPOINT
AWS_REGION=$AWS_REGION
AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY
CORS_ORIGINS=$CORS_ORIGINS
DB_HOST=$DB_HOST
DB_NAME=$DB_NAME
DB_PASSWORD=$DB_PASSWORD
DB_PORT=$DB_PORT
DB_SSLMODE=$DB_SSLMODE
DB_USER=$DB_USER
ENV=$ENV
JWT_SECRET=$JWT_SECRET
MAX_UPLOAD_CAD_SIZE=$MAX_UPLOAD_CAD_SIZE
PORT=$PORT
S3_BUCKET=$S3_BUCKET
UPLOAD_DIR=$UPLOAD_DIR
EOF
- kubectl -n gohorsejobs delete secret backend-secrets --ignore-not-found
- kubectl -n gohorsejobs create secret generic backend-secrets --from-env-file=.env.k8s
- name: deploy-backend
image: bitnami/kubectl:latest
commands:
- kubectl get pods -n gohorsejobs
- kubectl apply -n gohorsejobs -f k8s/backend-deployment.yaml
- kubectl apply -n gohorsejobs -f k8s/backend-service.yaml

View file

@ -0,0 +1,31 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: gohorse-backend
namespace: gohorsejobs
spec:
replicas: 1
selector:
matchLabels:
app: gohorse-backend
template:
metadata:
labels:
app: gohorse-backend
spec:
containers:
- name: backend
image: in.gohorsejobs.com/gohorsejobs/gohorsejobs-backend:latest
imagePullPolicy: Always
ports:
- containerPort: 8521
env:
- name: NODE_ENV
value: "production"
- name: PORT
value: "8521"
envFrom:
- secretRef:
name: backend-secrets
imagePullSecrets:
- name: harbor-registry

13
k8s/backend-service.yaml Normal file
View file

@ -0,0 +1,13 @@
apiVersion: v1
kind: Service
metadata:
name: gohorse-backend
namespace: gohorsejobs
spec:
selector:
app: gohorse-backend
ports:
- name: http
port: 8521
targetPort: 8521
type: ClusterIP