forked from hasadna/meirim
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathdocker-run.sh
More file actions
executable file
·26 lines (22 loc) · 849 Bytes
/
Copy pathdocker-run.sh
File metadata and controls
executable file
·26 lines (22 loc) · 849 Bytes
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
#!/usr/bin/env bash
set -e
IMAGE="node:18"
CONTAINER_NAME="meirim-dev"
WORKDIR="/app"
# Ports: client (3000), api (3001), serve (80)
PORTS="-p 3000:3000 -p 3001:3001 -p 80:80"
# Mount the project root so changes are reflected live
MOUNTS="-v $(pwd):$WORKDIR -w $WORKDIR"
# Check if container already exists
if docker ps -a --format '{{.Names}}' | grep -q "^$CONTAINER_NAME$"; then
if docker ps --format '{{.Names}}' | grep -q "^$CONTAINER_NAME$"; then
echo "Container '$CONTAINER_NAME' is already running. Attaching..."
docker exec -it "$CONTAINER_NAME" /bin/bash
else
echo "Container '$CONTAINER_NAME' exists but is stopped. Starting..."
docker start -ai "$CONTAINER_NAME"
fi
else
echo "Creating and starting container '$CONTAINER_NAME'..."
docker run -it --name "$CONTAINER_NAME" $PORTS $MOUNTS "$IMAGE" /bin/bash
fi