This repository has no description
1#!/bin/bash
2
3# Check if Docker daemon is running
4if ! docker info > /dev/null 2>&1; then
5 echo "Error: Docker daemon is not running. Please start Docker and try again."
6 exit 1
7fi
8
9# Check if the Postgres container is running
10if [ "$(docker ps -q -f name=annos-postgres)" ]; then
11 echo "Postgres container is already running."
12 DB_RUNNING=true
13else
14 echo "Starting Postgres container..."
15 npm run db:start
16 DB_RUNNING=false
17fi
18
19
20# Trap SIGINT and SIGTERM to stop containers on exit, only if we started them
21function cleanup {
22 if [ "$DB_RUNNING" = false ]; then
23 if [ "$(docker ps -q -f name=annos-postgres)" ]; then
24 echo "Stopping Postgres container..."
25 npm run db:stop
26 npm run db:remove
27 fi
28 fi
29}
30trap cleanup SIGINT SIGTERM
31
32# Run the dev command
33npm run dev:inner
34
35# Cleanup after dev command exits
36cleanup