-
Notifications
You must be signed in to change notification settings - Fork 1
/
start
34 lines (28 loc) · 1.19 KB
/
start
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
# Function to check if a Docker container is running
container_exists() {
docker ps -a --format '{{.Names}}' | grep -q "$1"
}
# Check if MongoDB and Elasticsearch containers are already running
if ! container_exists "mongodb"; then
echo "MongoDB container is not running. Starting MongoDB container using Docker Compose..."
docker-compose -f docker-compose.yaml up -d mongodb
fi
if ! container_exists "elasticsearch"; then
echo "Elasticsearch container is not running. Starting Elasticsearch container using Docker Compose..."
docker-compose -f docker-compose.yaml up -d elasticsearch
fi
# Start the SBOM container using the Dockerfile
docker build -t sbom .
echo "Building SBOM container..."
# Connect to specific network
#network_name=sbom_patcher_sbom_network
#if docker network inspect $network_name &>/dev/null; then
# docker network connect $network_name sbom
# echo "Container sbom connected to network $network_name"
#else
# echo "Network $network_name does not exists"
#fi
docker run --name sbom -p 5000:5000 --network sbom_patcher_sbom_network --link mongodb --link elasticsearch -d sbom
docker exec -d sbom python SBOM.py
echo "all container already started..."