-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart.sh
More file actions
executable file
·35 lines (27 loc) · 1.07 KB
/
start.sh
File metadata and controls
executable file
·35 lines (27 loc) · 1.07 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
#!/bin/bash
set -e
CONTAINER_NAME="donut-bot"
IMAGE_NAME="donut-bot"
echo "Checking if container '$CONTAINER_NAME' is running..."
# Check if container exists and is running
if docker ps --format '{{.Names}}' | grep -q "^${CONTAINER_NAME}$"; then
echo "Container '$CONTAINER_NAME' is running. Stopping it..."
docker stop "$CONTAINER_NAME"
echo "Container stopped."
elif docker ps -a --format '{{.Names}}' | grep -q "^${CONTAINER_NAME}$"; then
echo "Container '$CONTAINER_NAME' exists but is not running. Removing it..."
docker rm "$CONTAINER_NAME"
echo "Container removed."
else
echo "Container '$CONTAINER_NAME' does not exist."
fi
echo ""
echo "Building Docker image '$IMAGE_NAME'..."
docker build -t "$IMAGE_NAME" .
echo ""
echo "Starting container '$CONTAINER_NAME'..."
docker run -d --restart unless-stopped --env-file .env -v "$(pwd)/data:/app/data" --name "$CONTAINER_NAME" "$IMAGE_NAME"
echo ""
echo "Container '$CONTAINER_NAME' is now running!"
echo "View logs with: docker logs -f $CONTAINER_NAME"
echo "Stop container with: docker stop $CONTAINER_NAME"