-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy_dokploy.sh
More file actions
61 lines (49 loc) · 1.93 KB
/
deploy_dokploy.sh
File metadata and controls
61 lines (49 loc) · 1.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/bin/bash
# Script para facilitar el despliegue con Dokploy
# Colores para output
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
RED='\033[0;31m'
NC='\033[0m' # No Color
echo -e "${GREEN}=== Iniciando despliegue a Dokploy ===${NC}"
# Verificar instalación de Dokploy CLI
if ! command -v dokploy &> /dev/null; then
echo -e "${RED}Error: dokploy-cli no está instalado.${NC}"
echo -e "Instálalo con: ${YELLOW}npm install -g dokploy-cli${NC}"
exit 1
fi
# Configurar variables
echo -e "${GREEN}Configurando variables de entorno...${NC}"
# Estas variables pueden ser establecidas automáticamente por Dokploy o definidas aquí
export REGISTRY_URL=${REGISTRY_URL:-"your-registry-url"}
export IMAGE_NAME=${IMAGE_NAME:-"curriculum-backend"}
export IMAGE_TAG=${IMAGE_TAG:-"latest"}
export APP_DOMAIN=${APP_DOMAIN:-"your-app-domain.com"}
# Verificar inicio de sesión en el registro Docker
echo -e "${GREEN}Verificando inicio de sesión en el registro Docker...${NC}"
if [[ -n "$REGISTRY_URL" && "$REGISTRY_URL" != "your-registry-url" ]]; then
echo -e "${YELLOW}Asegúrate de haber iniciado sesión en el registro Docker con: docker login $REGISTRY_URL${NC}"
fi
# Construir la imagen
echo -e "${GREEN}Construyendo imagen Docker...${NC}"
docker build -t $REGISTRY_URL/$IMAGE_NAME:$IMAGE_TAG .
if [ $? -ne 0 ]; then
echo -e "${RED}Error al construir la imagen Docker.${NC}"
exit 1
fi
# Publicar la imagen
echo -e "${GREEN}Publicando imagen a $REGISTRY_URL...${NC}"
docker push $REGISTRY_URL/$IMAGE_NAME:$IMAGE_TAG
if [ $? -ne 0 ]; then
echo -e "${RED}Error al publicar la imagen Docker.${NC}"
exit 1
fi
# Desplegar con Dokploy
echo -e "${GREEN}Desplegando aplicación con Dokploy...${NC}"
dokploy deploy
if [ $? -ne 0 ]; then
echo -e "${RED}Error al desplegar la aplicación.${NC}"
exit 1
fi
echo -e "${GREEN}=== Despliegue completado con éxito ===${NC}"
echo -e "La aplicación estará disponible en: ${YELLOW}https://$APP_DOMAIN${NC}"