gabrielaltay commited on
Commit
ff7384a
·
1 Parent(s): 44d2f53
Files changed (4) hide show
  1. Dockerfile +1 -1
  2. build-docker.sh +31 -0
  3. clean-docker.sh +59 -0
  4. run-docker.sh +5 -5
Dockerfile CHANGED
@@ -38,4 +38,4 @@ EXPOSE 8501
38
  HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health
39
 
40
  # Run the application
41
- CMD ["sh", "-c", "uv run streamlit run src/legisqa_local/app.py --server.port=${PORT:-8501} --server.address=0.0.0.0"]
 
38
  HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health
39
 
40
  # Run the application
41
+ CMD ["uv", "run", "streamlit", "run", "src/legisqa_local/app.py", "--server.port=8501", "--server.address=0.0.0.0"]
build-docker.sh ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+
3
+ # Script to build the LegisQA Docker image
4
+
5
+ IMAGE_NAME="legisqa-local"
6
+ IMAGE_TAG="latest"
7
+
8
+ echo "Building LegisQA Docker image..."
9
+ echo "Image: $IMAGE_NAME:$IMAGE_TAG"
10
+ echo "Context: $(pwd)"
11
+ echo ""
12
+
13
+ # Build the Docker image
14
+ docker build -t $IMAGE_NAME:$IMAGE_TAG .
15
+
16
+ # Check if build was successful
17
+ if [ $? -eq 0 ]; then
18
+ echo ""
19
+ echo "✅ Docker image built successfully!"
20
+ echo "Image: $IMAGE_NAME:$IMAGE_TAG"
21
+ echo ""
22
+ echo "To run the container, use:"
23
+ echo " ./run-docker.sh"
24
+ echo ""
25
+ echo "To see the image details:"
26
+ echo " docker images | grep $IMAGE_NAME"
27
+ else
28
+ echo ""
29
+ echo "❌ Docker build failed!"
30
+ exit 1
31
+ fi
clean-docker.sh ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+
3
+ # Script to clean up LegisQA Docker containers and images
4
+
5
+ IMAGE_NAME="legisqa-local"
6
+ CONTAINER_NAME="legisqa-container"
7
+
8
+ echo "🧹 Cleaning up LegisQA Docker resources..."
9
+ echo ""
10
+
11
+ # Stop and remove the running container if it exists
12
+ echo "Stopping container: $CONTAINER_NAME"
13
+ if docker stop $CONTAINER_NAME 2>/dev/null; then
14
+ echo "✅ Container $CONTAINER_NAME stopped"
15
+ else
16
+ echo "ℹ️ Container $CONTAINER_NAME not running"
17
+ fi
18
+
19
+ echo ""
20
+
21
+ # Remove the container if it exists (in case it's stopped but not removed)
22
+ echo "Removing container: $CONTAINER_NAME"
23
+ if docker rm $CONTAINER_NAME 2>/dev/null; then
24
+ echo "✅ Container $CONTAINER_NAME removed"
25
+ else
26
+ echo "ℹ️ Container $CONTAINER_NAME not found"
27
+ fi
28
+
29
+ echo ""
30
+
31
+ # Remove the image if it exists
32
+ echo "Removing image: $IMAGE_NAME"
33
+ if docker rmi $IMAGE_NAME 2>/dev/null; then
34
+ echo "✅ Image $IMAGE_NAME removed"
35
+ else
36
+ echo "ℹ️ Image $IMAGE_NAME not found"
37
+ fi
38
+
39
+ echo ""
40
+
41
+ # Optional: Clean up dangling images and build cache
42
+ read -p "🗑️ Clean up dangling images and build cache? (y/N): " -n 1 -r
43
+ echo ""
44
+ if [[ $REPLY =~ ^[Yy]$ ]]; then
45
+ echo "Cleaning up dangling images..."
46
+ docker image prune -f
47
+ echo "Cleaning up build cache..."
48
+ docker builder prune -f
49
+ echo "✅ Cleanup complete!"
50
+ else
51
+ echo "ℹ️ Skipped cleanup of dangling images and build cache"
52
+ fi
53
+
54
+ echo ""
55
+ echo "🎉 LegisQA Docker cleanup finished!"
56
+ echo ""
57
+ echo "To rebuild and run:"
58
+ echo " ./build-docker.sh"
59
+ echo " ./run-docker.sh"
run-docker.sh CHANGED
@@ -3,16 +3,17 @@
3
  # Script to run LegisQA with Docker, mounting the ChromaDB volume
4
 
5
  # Port configuration (default to 8505 to avoid conflicts)
6
- PORT=${PORT:-8505}
 
7
 
8
  # ChromaDB host path (local chromadb directory)
9
  CHROMA_HOST_PATH="$(pwd)/chromadb"
10
 
11
  # Container path where ChromaDB will be mounted
12
- CHROMA_CONTAINER_PATH="/app/chroma_data"
13
 
14
  echo "Starting LegisQA Docker container..."
15
- echo "Port: $PORT"
16
  echo "ChromaDB Host Path: $CHROMA_HOST_PATH"
17
  echo "ChromaDB Container Path: $CHROMA_CONTAINER_PATH"
18
  echo "Environment File: docker.env"
@@ -31,9 +32,8 @@ if [ ! -f "docker.env" ]; then
31
  fi
32
 
33
  # Run Docker container
34
- docker run -p $PORT:$PORT \
35
  --env-file docker.env \
36
- -e PORT=$PORT \
37
  -v "$CHROMA_HOST_PATH:$CHROMA_CONTAINER_PATH" \
38
  --name legisqa-container \
39
  --rm \
 
3
  # Script to run LegisQA with Docker, mounting the ChromaDB volume
4
 
5
  # Port configuration (default to 8505 to avoid conflicts)
6
+ HOST_PORT=${PORT:-8505}
7
+ CONTAINER_PORT=8501 # Fixed port in Dockerfile
8
 
9
  # ChromaDB host path (local chromadb directory)
10
  CHROMA_HOST_PATH="$(pwd)/chromadb"
11
 
12
  # Container path where ChromaDB will be mounted
13
+ CHROMA_CONTAINER_PATH="/home/user/app/chroma_data"
14
 
15
  echo "Starting LegisQA Docker container..."
16
+ echo "Host Port: $HOST_PORT -> Container Port: $CONTAINER_PORT"
17
  echo "ChromaDB Host Path: $CHROMA_HOST_PATH"
18
  echo "ChromaDB Container Path: $CHROMA_CONTAINER_PATH"
19
  echo "Environment File: docker.env"
 
32
  fi
33
 
34
  # Run Docker container
35
+ docker run -p $HOST_PORT:$CONTAINER_PORT \
36
  --env-file docker.env \
 
37
  -v "$CHROMA_HOST_PATH:$CHROMA_CONTAINER_PATH" \
38
  --name legisqa-container \
39
  --rm \