Repository navigation
Expand file tree
/
Copy pathdeploy.sh
More file actions
executable file
·59 lines (49 loc) · 1.65 KB
/
Copy pathdeploy.sh
File metadata and controls
executable file
·59 lines (49 loc) · 1.65 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
#!/bin/bash
# Configuration
IMAGE_NAME="docusaurus:latest"
CONTAINER_NAME="docusaurus-tuyaopen.io"
GIT_BRANCH="master"
PORT=9050
# Colors for output
GREEN='\033[0;32m'
RED='\033[0;31m'
YELLOW='\033[1;33m'
NC='\033[0m'
# Check if in project root
if [ ! -d ".git" ] || [ ! -f "dockerfile" ]; then
echo -e "${RED}Error: Please run this script from the project root (where .git and dockerfile exist).${NC}"
exit 1
fi
echo -e "${YELLOW}Pulling latest changes from ${GIT_BRANCH}...${NC}"
git checkout $GIT_BRANCH && git pull origin $GIT_BRANCH
if [ $? -ne 0 ]; then
echo -e "${RED}Git pull failed!${NC}"
exit 1
fi
echo -e "${YELLOW}Building Docker image...${NC}"
docker build -t $IMAGE_NAME --target production .
if [ $? -ne 0 ]; then
echo -e "${RED}Docker build failed!${NC}"
exit 1
fi
echo -e "${YELLOW}Stopping and removing old container (if exists)...${NC}"
docker stop $CONTAINER_NAME 2>/dev/null || true
docker rm $CONTAINER_NAME 2>/dev/null || true
echo -e "${YELLOW}Starting new container...${NC}"
docker run -d \
--name $CONTAINER_NAME \
--restart unless-stopped \
-p $PORT:$PORT \
$IMAGE_NAME
if docker ps | grep -q $CONTAINER_NAME; then
echo -e "${GREEN}✅ Deployment successful! Container $CONTAINER_NAME is running on port $PORT.${NC}"
docker ps | grep $CONTAINER_NAME
else
echo -e "${RED}❌ Container failed to start. Showing logs:${NC}"
docker logs $CONTAINER_NAME
exit 1
fi
echo -e "${YELLOW}Pruning unused Docker resources...${NC}"
docker system prune -f
echo -e "${GREEN}🌐 Your site should be available at: https://tuyaopen.ai${NC}"
echo -e "${YELLOW}📝 Note: Update nginx config if needed. See nginx-commands.md for help.${NC}"