Files
wace_plm/start-prod-full.sh

68 lines
1.6 KiB
Bash
Raw Normal View History

#!/bin/bash
# OS 확인
OS_INFO=$(grep '^ID=' /etc/os-release)
if [[ "$OS_INFO" != *"ubuntu"* ]]; then
echo "This script runs on Ubuntu only."
exit 1
fi
# 키보드 레이아웃을 영문(US)으로 설정
echo "Setting keyboard layout to English (US)..."
# CLI 환경에서 키보드 레이아웃 설정
if command -v loadkeys >/dev/null 2>&1 && [ $(id -u) -eq 0 ]; then
echo "Setting console keyboard layout to US..."
loadkeys us
elif command -v loadkeys >/dev/null 2>&1; then
echo "To change keyboard layout, run with sudo: sudo loadkeys us"
# 권한이 없어도 시도는 해봄
sudo loadkeys us 2>/dev/null || true
fi
echo "Starting Production Environment..."
# 환경 변수 파일 로드
if [ -f .env.production ]; then
echo "Loading production environment variables..."
set -a
source .env.production
set +a
else
echo "Error: .env.production file not found!"
exit 1
fi
echo "Starting Production Environment..."
export NODE_ENV=production
# 이전 컨테이너 정리
docker-compose -f docker-compose.prod.yml down
echo "Pruning Docker system..."
# 컨테이너 정리
docker system prune -af
docker image prune -af
docker volume prune -af
# Git 관련 명령어 실행
git reset --hard
git checkout main
# 강제로 리모트 브랜치의 내용을 가져옴
if ! git fetch origin; then
echo "Git fetch failed. Exiting script."
exit 1
fi
if ! git reset --hard origin/main; then
echo "Git reset failed. Exiting script."
exit 1
fi
# 컨테이너 상태 확인
echo "Checking container status..."
docker-compose -f docker-compose.prod.yml up --build --force-recreate -d
echo "Production environment setup complete!"