forked from kushal-chat/AC215_datadetox
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart-frontend-container.sh
More file actions
executable file
·61 lines (49 loc) · 1.24 KB
/
start-frontend-container.sh
File metadata and controls
executable file
·61 lines (49 loc) · 1.24 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
# Exit on error and undefined variables
set -eu
# Constants
IMAGE_NAME="datadetox-frontend"
CONTAINER_NAME="datadetox-frontend"
PORT="8080"
# Color codes for output
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
RED='\033[0;31m'
NC='\033[0m' # No Color
# Helper function for logging
log() {
echo -e "${GREEN}[INFO]${NC} $1"
}
warn() {
echo -e "${YELLOW}[WARN]${NC} $1"
}
error() {
echo -e "${RED}[ERROR]${NC} $1"
exit 1
}
# Check if Docker is running
if ! docker info >/dev/null 2>&1; then
error "Docker is not running. Please start Docker first."
fi
# Clean up any existing container (ignore errors with || true)
docker stop $CONTAINER_NAME 2>/dev/null || true
docker rm $CONTAINER_NAME 2>/dev/null || true
log "Cleaned up any existing containers"
# Build the image
log "Building Docker image..."
if ! docker build -t $IMAGE_NAME -f Dockerfile .; then
error "Failed to build Docker image"
fi
# Run the container
log "Starting container..."
docker run \
--rm \
--name $CONTAINER_NAME \
-p $PORT:$PORT \
-d \
$IMAGE_NAME
log "Container started successfully!"
log "Frontend available at http://localhost:$PORT"
# Watch container logs
log "Showing container logs (Ctrl+C to exit)..."
docker logs -f $CONTAINER_NAME