This document provides detailed instructions for deploying the Congress.gov API Chatbot application to various environments, with a focus on Tanzu Platform for Cloud Foundry.
- Prerequisites
- Deployment to Tanzu Platform for Cloud Foundry
- Deployment to Other Environments
- Continuous Integration and Deployment
- Troubleshooting Deployment Issues
Before deploying the application, ensure you have the following:
- Access to a Tanzu Platform for Cloud Foundry environment
- Cloud Foundry CLI installed and configured
- Access to the GenAI tile and LLM service instances
- Congress.gov API key (get your API key at https://api.congress.gov/sign-up/)
- Go 1.24+ installed (for building the application)
- Build the application:
go build -o congress-chatbot cmd/server/main.go- Ensure the
manifest.ymlfile is properly configured:
applications:
- name: congress-chatbot
memory: 256M
instances: 1
buildpacks:
- go_buildpack
env:
GOPACKAGENAME: github.com/cf-toolsuite/tanzu-genai-showcase/go-fiber-langchaingo
GO_INSTALL_PACKAGE_SPEC: github.com/cf-toolsuite/tanzu-genai-showcase/go-fiber-langchaingo/cmd/server
ENV: production
health-check-type: http
health-check-http-endpoint: /health- Verify that your
.env.examplefile contains all the necessary environment variables:
CONGRESS_API_KEY=your_congress_api_key
GENAI_API_KEY=your_GENAI_API_KEY
GENAI_API_BASE_URL=your_GENAI_API_BASE_URL
LLM=gpt-4o-mini
- Log in to your Cloud Foundry environment:
cf login -a <API_ENDPOINT> -u <USERNAME> -p <PASSWORD> -o <ORG> -s <SPACE>- Push the application without starting it:
cf push --no-start- Set the Congress.gov API key:
cf set-env congress-chatbot CONGRESS_API_KEY <YOUR_CONGRESS_API_KEY>- List available plans for the GenAI service offering:
cf marketplace -e genai- Create an LLM service instance (if not already created):
cf create-service genai <PLAN_NAME> congress-llmReplace <PLAN_NAME> with the name of an available plan of the GenAI tile service offering.
- Bind the service to your application:
cf bind-service congress-chatbot congress-llm- Start your application to apply the binding:
cf start congress-chatbotIf you need to configure additional environment variables:
cf set-env congress-chatbot ENV production
cf set-env congress-chatbot PORT 8080
cf restage congress-chatbotTo scale the application horizontally (add more instances):
cf scale congress-chatbot -i 3To scale the application vertically (adjust memory or disk):
cf scale congress-chatbot -m 512M -k 512M- Check the application status:
cf app congress-chatbot- View application logs:
cf logs congress-chatbot --recent- Stream application logs:
cf logs congress-chatbot- Create a
Dockerfilein the project root:
FROM golang:1.24-alpine AS builder
WORKDIR /app
COPY . .
RUN go mod download
RUN go build -o congress-chatbot cmd/server/main.go
FROM alpine:latest
WORKDIR /app
COPY --from=builder /app/congress-chatbot .
COPY --from=builder /app/public ./public
ENV PORT=8080
EXPOSE 8080
CMD ["./congress-chatbot"]- Build the Docker image:
docker build -t congress-chatbot .- Run the Docker container:
docker run -p 8080:8080 \
-e CONGRESS_API_KEY=<YOUR_CONGRESS_API_KEY> \
-e GENAI_API_KEY=<YOUR_GENAI_API_KEY> \
-e GENAI_API_BASE_URL=<YOUR_GENAI_API_BASE_URL> \
-e LLM=gpt-4o-mini \
congress-chatbot- Create a Kubernetes deployment manifest (
deployment.yaml):
apiVersion: apps/v1
kind: Deployment
metadata:
name: congress-chatbot
spec:
replicas: 3
selector:
matchLabels:
app: congress-chatbot
template:
metadata:
labels:
app: congress-chatbot
spec:
containers:
- name: congress-chatbot
image: congress-chatbot:latest
ports:
- containerPort: 8080
env:
- name: CONGRESS_API_KEY
valueFrom:
secretKeyRef:
name: congress-chatbot-secrets
key: congress-api-key
- name: GENAI_API_KEY
valueFrom:
secretKeyRef:
name: congress-chatbot-secrets
key: genai-api-key
- name: GENAI_API_BASE_URL
valueFrom:
secretKeyRef:
name: congress-chatbot-secrets
key: genai-api-base-url
- name: LLM
value: "gpt-4o-mini"- Create a Kubernetes service manifest (
service.yaml):
apiVersion: v1
kind: Service
metadata:
name: congress-chatbot
spec:
selector:
app: congress-chatbot
ports:
- port: 80
targetPort: 8080
type: LoadBalancer- Create a Kubernetes secret for the API keys:
kubectl create secret generic congress-chatbot-secrets \
--from-literal=congress-api-key=<YOUR_CONGRESS_API_KEY> \
--from-literal=genai-api-key=<YOUR_GENAI_API_KEY> \
--from-literal=genai-api-base-url=<YOUR_GENAI_API_BASE_URL>- Apply the Kubernetes manifests:
kubectl apply -f deployment.yaml
kubectl apply -f service.yamlThe project includes CI/CD configurations for various platforms:
The ci/jenkins/Jenkinsfile contains a pipeline configuration for Jenkins:
pipeline {
agent any
stages {
stage('Build') {
steps {
sh 'go build -o congress-chatbot cmd/server/main.go'
}
}
stage('Test') {
steps {
sh 'go test ./...'
}
}
stage('Deploy') {
steps {
sh 'cf login -a $CF_API -u $CF_USERNAME -p $CF_PASSWORD -o $CF_ORG -s $CF_SPACE'
sh 'cf push --no-start'
sh 'cf set-env congress-chatbot CONGRESS_API_KEY $CONGRESS_API_KEY'
sh 'cf bind-service congress-chatbot congress-llm'
sh 'cf start congress-chatbot'
}
}
}
}The ci/gitlab/.gitlab-ci.yml contains a pipeline configuration for GitLab CI:
stages:
- build
- test
- deploy
build:
stage: build
image: golang:1.24
script:
- go build -o congress-chatbot cmd/server/main.go
artifacts:
paths:
- congress-chatbot
test:
stage: test
image: golang:1.24
script:
- go test ./...
deploy:
stage: deploy
image: governmentpaas/cf-cli
script:
- cf login -a $CF_API -u $CF_USERNAME -p $CF_PASSWORD -o $CF_ORG -s $CF_SPACE
- cf push --no-start
- cf set-env congress-chatbot CONGRESS_API_KEY $CONGRESS_API_KEY
- cf bind-service congress-chatbot congress-llm
- cf start congress-chatbot
only:
- mainThe ci/bitbucket/bitbucket-pipelines.yml contains a pipeline configuration for Bitbucket Pipelines:
image: golang:1.24
pipelines:
default:
- step:
name: Build
script:
- go build -o congress-chatbot cmd/server/main.go
artifacts:
- congress-chatbot
- step:
name: Test
script:
- go test ./...
branches:
main:
- step:
name: Deploy
image: governmentpaas/cf-cli
script:
- cf login -a $CF_API -u $CF_USERNAME -p $CF_PASSWORD -o $CF_ORG -s $CF_SPACE
- cf push --no-start
- cf set-env congress-chatbot CONGRESS_API_KEY $CONGRESS_API_KEY
- cf bind-service congress-chatbot congress-llm
- cf start congress-chatbotSymptoms:
- The application fails to start after deployment
cf startcommand fails
Possible Causes and Solutions:
-
Missing environment variables
- Check if all required environment variables are set:
cf env congress-chatbot
- Set any missing environment variables:
cf set-env congress-chatbot CONGRESS_API_KEY <YOUR_CONGRESS_API_KEY>
-
Service binding issues
- Check if the service is properly bound:
cf services
- Rebind the service if necessary:
cf unbind-service congress-chatbot congress-llm cf bind-service congress-chatbot congress-llm
-
Build issues
- Check the application logs for build errors:
cf logs congress-chatbot --recent
- Ensure the Go version is compatible:
cf set-env congress-chatbot GOVERSION go1.24
Symptoms:
- The application starts but crashes shortly after
- Health check fails
Possible Causes and Solutions:
-
Memory issues
- Increase the memory allocation:
cf scale congress-chatbot -m 512M
-
Configuration issues
- Check the application logs for configuration errors:
cf logs congress-chatbot --recent
- Verify the service credentials are correctly parsed:
cf env congress-chatbot
-
API connectivity issues
- Ensure the application can connect to the Congress.gov API and the GenAI LLM service
- Check for network or firewall issues
Symptoms:
- The application is slow to respond
- Timeouts occur during API calls
Possible Causes and Solutions:
-
Insufficient resources
- Scale the application vertically:
cf scale congress-chatbot -m 512M
- Scale the application horizontally:
cf scale congress-chatbot -i 3
-
External API latency
- Check the application logs for slow API calls:
cf logs congress-chatbot --recent
- Adjust the timeout settings in the application code
-
Caching issues
- Verify that the caching mechanism is working correctly
- Adjust the cache TTL if necessary