ajuste no drone.yml

This commit is contained in:
Marcus Bohessef 2025-12-12 10:46:12 -03:00
parent 1758a74ad2
commit 6b9b8ba617

View file

@ -14,7 +14,6 @@ steps:
dockerfile: backend/Dockerfile
insecure: true
insecure_skip_verify: true
debug: true
username:
from_secret: HARBOR_USERNAME
password:
@ -28,33 +27,49 @@ steps:
KUBECONFIG_DATA:
from_secret: K3S_KUBECONFIG
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 }
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:
- echo "--- CONFIGURANDO KUBECONFIG ---"
- mkdir -p /tmp/drone-home/.kube
- echo "$KUBECONFIG_DATA" | base64 -d > /tmp/drone-home/.kube/config
- echo "--- TESTANDO ACESSO AO NAMESPACE gohorsejobs ---"
- kubectl get pods -n gohorsejobs || echo "Nenhum pod ainda — OK"
- echo "--- TESTANDO ACESSO AO NAMESPACE ---"
- kubectl -n gohorsejobs get pods || echo "Nenhum pod ainda — OK"
- echo "--- GERANDO ARQUIVO .env.k8s ---"
- echo "--- GERANDO ARQUIVO ENV ---"
- |
cat <<EOF > .env.k8s
AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID
@ -76,9 +91,8 @@ S3_BUCKET=$S3_BUCKET
UPLOAD_DIR=$UPLOAD_DIR
EOF
- echo "--- ATUALIZANDO SECRET backend-secrets ---"
- kubectl delete secret backend-secrets -n gohorsejobs --ignore-not-found
- kubectl create secret generic backend-secrets -n gohorsejobs --from-env-file=.env.k8s
- 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
@ -87,13 +101,11 @@ EOF
KUBECONFIG: /tmp/drone-home/.kube/config
KUBECONFIG_DATA:
from_secret: K3S_KUBECONFIG
commands:
- echo "--- PREPARANDO DEPLOY ---"
- mkdir -p /tmp/drone-home/.kube
- echo "$KUBECONFIG_DATA" | base64 -d > /tmp/drone-home/.kube/config
- echo "--- APPLY DEPLOYMENT ---"
- echo "--- APLICANDO DEPLOY ---"
- kubectl apply -n gohorsejobs -f k8s/backend-deployment.yaml
- echo "--- APPLY SERVICE ---"
- kubectl apply -n gohorsejobs -f k8s/backend-service.yaml