Skip to content

Commit

Permalink
updated the docker commands to pull image from GCP
Browse files Browse the repository at this point in the history
  • Loading branch information
labrijisaad committed Apr 18, 2024
1 parent 182625f commit 045b947
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 9 deletions.
29 changes: 29 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
IMAGE_NAME := llm_rag_app
CONTAINER_NAME := llm_rag_app_container
SECRETS_VOLUME_PATH := $(CURDIR)/secrets
PROJECT_ID := llm-rag-application
REPO_NAME := llm-rag
REGION := europe-west1
TAG := latest
IMAGE_URI := $(REGION)-docker.pkg.dev/$(PROJECT_ID)/$(REPO_NAME)/$(IMAGE_NAME):$(TAG)

# Default target
.DEFAULT_GOAL := help
Expand All @@ -26,6 +31,26 @@ docker-build:
@echo Building Docker image named $(IMAGE_NAME)...
@docker build -t $(IMAGE_NAME) -f docker/Dockerfile .

# Tag the Docker image for Google Artifact Registry
docker-tag:
@echo Tagging Docker image $(IMAGE_NAME)...
@docker tag $(IMAGE_NAME) $(IMAGE_URI)

# Push the Docker image to Google Artifact Registry
docker-push:
@echo Pushing Docker image to $(IMAGE_URI)...
@docker push $(IMAGE_URI)

# Pull the Docker image from Google Artifact Registry
docker-pull:
@echo Pulling Docker image from $(IMAGE_URI)...
@docker pull $(IMAGE_URI)

# Run the pulled Docker container with the Streamlit app
docker-run-pulled:
@echo Running Docker container named $(CONTAINER_NAME)...
@docker run -d --name $(CONTAINER_NAME) -p 8501:8501 -v "$(SECRETS_VOLUME_PATH):/app/secrets" $(IMAGE_URI)

# Run the Docker container with the Streamlit app
docker-run:
@echo Running Docker container named $(CONTAINER_NAME)...
Expand All @@ -44,6 +69,10 @@ help:
@echo make test - Run the tests for the application with pytest
@echo make stream - Start the Streamlit app from the local system
@echo make docker-build - Build the Docker image for the application
@echo make docker-tag - Tag the Docker image for Google Artifact Registry
@echo make docker-push - Push the Docker image to Google Artifact Registry
@echo make docker-pull - Pull the Docker image from Google Artifact Registry
@echo make docker-run-pulled - Run the Streamlit app in a Docker container (pulled image)
@echo make docker-run - Run the Streamlit app in a Docker container
@echo make docker-kill - Stop and remove the Docker container
@echo Author: $(AUTHOR)
29 changes: 20 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,24 +130,35 @@ To begin using the LLM RAG app, follow these simple steps:
streamlit run streamlit_app/main.py
```
## 🐳 Docker Version
The application is available as a Docker container. To set up the Docker environment:

1. **Build the Docker Image:**
Run `make docker-build` or use the Docker command directly:
The application is available as a Docker container and can be easily set up and run with a few commands. If you want to run the application using the Docker image from the public registry, ensure that you have a `secrets` directory with the necessary API keys as specified in the `secrets/credentials.yml`.

To pull and run the Docker container:

1. **Pull the Docker Image:**
You can pull the image directly from **Google Artifact Registry** using the following command:
```shell
docker build -t llm_rag_app -f docker/Dockerfile .
docker pull europe-west1-docker.pkg.dev/llm-rag-application/llm-rag/llm_rag_app:latest
```

2. **Run the Docker Container:**
Start the container with `make docker-run` or use the Docker command:
After pulling the image, you can run it with:
```shell
docker run -p 8501:8501 -v $(pwd)/secrets:/app/secrets llm_rag_app
docker run -p 8501:8501 -v $(pwd)/secrets:/app/secrets europe-west1-docker.pkg.dev/llm-rag-application/llm-rag/llm_rag_app:latest
```
This command will start the container and mount your **`secrets`** directory for the application to use.

If you prefer to use the **Makefile**, the equivalent commands are provided for convenience:

3. **Stop the Docker Container:**
Use `make docker-kill` to stop and remove the container.
```shell
# To pull the Docker image
make docker-pull
# To run the pulled Docker image
make docker-run-pulled
```

The Streamlit app will be available at **`http://localhost:8501`**.
The Streamlit app will be available at **`http://localhost:8501`** once the container is running.


## 🌐 Connect with me
Expand Down

0 comments on commit 045b947

Please sign in to comment.