Compare commits
10 Commits
401e61e0eb
...
b33dd4f94f
| Author | SHA1 | Date | |
|---|---|---|---|
| b33dd4f94f | |||
| ba9bef2364 | |||
| 856d7ac5c1 | |||
| d8dc41222c | |||
| a434640456 | |||
| fcc2b90f15 | |||
| 0d7614ef4c | |||
| ae54ef3fe5 | |||
| c361842a91 | |||
| de079d8bd4 |
51
.drone.yml
51
.drone.yml
@@ -2,11 +2,6 @@ kind: pipeline
|
|||||||
type: docker
|
type: docker
|
||||||
name: Build y Deploy
|
name: Build y Deploy
|
||||||
|
|
||||||
volumes:
|
|
||||||
- name: dockersock
|
|
||||||
host:
|
|
||||||
path: /var/run/docker.sock
|
|
||||||
|
|
||||||
trigger:
|
trigger:
|
||||||
branch:
|
branch:
|
||||||
- main
|
- main
|
||||||
@@ -15,41 +10,33 @@ trigger:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: build-and-publish-backend
|
- name: build-and-publish-backend
|
||||||
image: plugins/docker
|
image: plugins/kaniko
|
||||||
volumes:
|
|
||||||
- name: dockersock
|
|
||||||
path: /var/run/docker.sock
|
|
||||||
settings:
|
settings:
|
||||||
registry:
|
repo: host.docker.internal:5000/${DRONE_REPO_OWNER}/${DRONE_REPO_NAME,,}-backend
|
||||||
from_secret: REGISTRY_URL
|
tags:
|
||||||
repo: ${REGISTRY_URL}/${DRONE_REPO_OWNER}/${DRONE_REPO_NAME,,}-backend
|
- latest
|
||||||
|
- ${DRONE_COMMIT_SHA:0:8}
|
||||||
|
dockerfile: Backend/GestionIntegral.Api/Dockerfile
|
||||||
|
context: .
|
||||||
username:
|
username:
|
||||||
from_secret: GITEA_USER
|
from_secret: GITEA_USER
|
||||||
password:
|
password:
|
||||||
from_secret: ACTIONS_PAT
|
from_secret: ACTIONS_PAT
|
||||||
dockerfile: Backend/GestionIntegral.Api/Dockerfile
|
|
||||||
tags:
|
|
||||||
- latest
|
|
||||||
- ${DRONE_COMMIT_SHA:0:8}
|
|
||||||
insecure: true
|
insecure: true
|
||||||
|
|
||||||
- name: build-and-publish-frontend
|
- name: build-and-publish-frontend
|
||||||
image: plugins/docker
|
image: plugins/kaniko
|
||||||
volumes:
|
|
||||||
- name: dockersock
|
|
||||||
path: /var/run/docker.sock
|
|
||||||
settings:
|
settings:
|
||||||
registry:
|
repo: host.docker.internal:5000/${DRONE_REPO_OWNER}/${DRONE_REPO_NAME,,}-frontend
|
||||||
from_secret: REGISTRY_URL
|
tags:
|
||||||
repo: ${REGISTRY_URL}/${DRONE_REPO_OWNER}/${DRONE_REPO_NAME,,}-frontend
|
- latest
|
||||||
|
- ${DRONE_COMMIT_SHA:0:8}
|
||||||
|
dockerfile: Frontend/Dockerfile
|
||||||
|
context: .
|
||||||
username:
|
username:
|
||||||
from_secret: GITEA_USER
|
from_secret: GITEA_USER
|
||||||
password:
|
password:
|
||||||
from_secret: ACTIONS_PAT
|
from_secret: ACTIONS_PAT
|
||||||
dockerfile: Frontend/Dockerfile
|
|
||||||
tags:
|
|
||||||
- latest
|
|
||||||
- ${DRONE_COMMIT_SHA:0:8}
|
|
||||||
insecure: true
|
insecure: true
|
||||||
depends_on:
|
depends_on:
|
||||||
- build-and-publish-backend
|
- build-and-publish-backend
|
||||||
@@ -74,30 +61,22 @@ steps:
|
|||||||
GITEA_PAT:
|
GITEA_PAT:
|
||||||
from_secret: ACTIONS_PAT
|
from_secret: ACTIONS_PAT
|
||||||
commands:
|
commands:
|
||||||
# Preparar el entorno SSH
|
|
||||||
- apk add --no-cache openssh-client
|
- apk add --no-cache openssh-client
|
||||||
- mkdir -p ~/.ssh
|
- mkdir -p ~/.ssh
|
||||||
- echo "$SSH_KEY" > ~/.ssh/id_rsa
|
- echo "$SSH_KEY" > ~/.ssh/id_rsa
|
||||||
- chmod 600 ~/.ssh/id_rsa
|
- chmod 600 ~/.ssh/id_rsa
|
||||||
- ssh-keyscan -H $PROD_HOST >> ~/.ssh/known_hosts
|
- ssh-keyscan -H $PROD_HOST >> ~/.ssh/known_hosts
|
||||||
|
|
||||||
# Ejecutar comandos remotos
|
|
||||||
- |
|
- |
|
||||||
ssh $PROD_USER@$PROD_HOST << 'EOF'
|
ssh $PROD_USER@$PROD_HOST << 'EOF'
|
||||||
echo "--- CONECTADO AL SERVIDOR DE PRODUCCIÓN ---"
|
echo "--- CONECTADO AL SERVIDOR DE PRODUCCIÓN ---"
|
||||||
cd /opt/gestion-integral
|
cd /opt/gestion-integral
|
||||||
|
|
||||||
# Exportamos las variables que necesita el docker-compose de la app
|
|
||||||
export DB_SA_PASSWORD="${DB_PASSWORD}"
|
export DB_SA_PASSWORD="${DB_PASSWORD}"
|
||||||
export JWT_KEY="${JWT_KEY}"
|
export JWT_KEY="${JWT_KEY}"
|
||||||
|
|
||||||
# Login, pull y deploy
|
|
||||||
docker login ${REGISTRY} -u ${GITEA_USER} -p ${GITEA_PAT}
|
docker login ${REGISTRY} -u ${GITEA_USER} -p ${GITEA_PAT}
|
||||||
docker compose pull
|
docker compose pull
|
||||||
docker compose up -d
|
docker compose up -d
|
||||||
docker image prune -af
|
docker image prune -af
|
||||||
|
|
||||||
echo "--- DESPLIEGUE COMPLETADO ---"
|
echo "--- DESPLIEGUE COMPLETADO ---"
|
||||||
EOF
|
EOF
|
||||||
depends_on:
|
depends_on:
|
||||||
- build-and-publish-frontend
|
- build-and-publish-frontend
|
||||||
Reference in New Issue
Block a user