-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b4520bd
commit 2d8f5f0
Showing
101 changed files
with
994 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1 @@ | ||
# Qpoint Demos | ||
|
||
A collection of apps and helpers to quickly spin up demos | ||
|
||
## Setup | ||
|
||
Ensure you have all the necessary dependencies: | ||
|
||
```bash | ||
make ensure-deps | ||
``` | ||
|
||
Then build the necessary resources and images: | ||
|
||
```bash | ||
make build | ||
``` | ||
|
||
## Usage | ||
|
||
Check to see which apps are available: | ||
|
||
```bash | ||
make help | ||
``` | ||
|
||
Bring up an app: | ||
|
||
```bash | ||
make <app>-app | ||
|
||
# for example | ||
make gpt4-app | ||
``` | ||
|
||
Teardown when complete | ||
|
||
```bash | ||
make down | ||
``` | ||
# QPoint Demo Repository |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
version: '3.8' | ||
|
||
services: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#!/bin/bash | ||
|
||
# Check if a domain name is provided | ||
if [ "$#" -ne 1 ]; then | ||
echo "Usage: $0 <domain>" | ||
exit 1 | ||
fi | ||
|
||
DOMAIN=$1 | ||
|
||
# Generate CA key and certificate | ||
openssl genrsa -out ca.key 2048 | ||
openssl req -x509 -new -nodes -key ca.key -sha256 -days 1825 -out ca.crt -subj "/C=US/ST=Default/L=Default/O=Default/OU=Default/CN=$DOMAIN CA" | ||
|
||
# Generate server key | ||
openssl genrsa -out server.key 2048 | ||
|
||
# Generate CSR for the server | ||
openssl req -new -key server.key -out server.csr -subj "/C=US/ST=Default/L=Default/O=Default/OU=Default/CN=$DOMAIN" | ||
|
||
# Sign the CSR with the CA to get the server certificate | ||
openssl x509 -req -in server.csr -CA ca.crt -CAkey ca.key -CAcreateserial -out server.crt -days 825 -sha256 | ||
|
||
# Print the YAML to stdout | ||
echo "ca_certificate: |" | ||
awk '{print " "$0}' ca.crt | ||
echo "" | ||
echo "ca_key: |" | ||
awk '{print " "$0}' ca.key | ||
echo "" | ||
echo "server_certificate: |" | ||
awk '{print " "$0}' server.crt | ||
echo "" | ||
echo "server_key: |" | ||
awk '{print " "$0}' server.key |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
#!/bin/bash | ||
|
||
# Read the templates from files | ||
DOCKER_COMPOSE_HEADER=$(cat .tools/compose-header.yml) | ||
QTAP_LOCAL_SERVICE=$(cat .tools/qtap-service.yml) | ||
SERVICE_TEMPLATE=$(cat .tools/service-template.yml) | ||
|
||
# Initialize the services array and port | ||
services=() | ||
startPort=4000 | ||
port=$startPort | ||
|
||
# Prepare table header | ||
echo "-----------------------------------------" | ||
printf "| %-20s | %-5s |\n" "Service Name" "Port" | ||
echo "-----------------------------------------" | ||
|
||
# Iterate through each directory looking for a Dockerfile | ||
for dir in */; do | ||
if [ -f "${dir}Dockerfile" ]; then | ||
# Remove the trailing slash from the directory name | ||
service_name=${dir%/} | ||
# Add the service name and port to the services array | ||
services+=("${service_name}:${port}") | ||
# Print the added service in table format | ||
printf "| %-20s | %-5s |\n" "$service_name" "$port" | ||
# Generate a docker-compose.yml for the service with . as build path | ||
service_definition=$(echo "$SERVICE_TEMPLATE" | sed "s/{{service_name}}/$service_name/g" | sed "s/{{port}}/$startPort/g" | sed "s/{{build_path}}/./g") | ||
echo "$DOCKER_COMPOSE_HEADER | ||
$service_definition | ||
$QTAP_LOCAL_SERVICE" > "${service_name}/docker-compose.yml" | ||
# Increment the port | ||
port=$((port + 1)) | ||
fi | ||
done | ||
|
||
# Print table footer | ||
echo "-----------------------------------------" | ||
|
||
# Start building the main docker-compose.yml content | ||
DOCKER_COMPOSE_CONTENT="$DOCKER_COMPOSE_HEADER" | ||
|
||
# Add the geoweather services with service_name/. as build path | ||
for service in "${services[@]}"; do | ||
service_name="${service%%:*}" | ||
port="${service##*:}" | ||
service_definition=$(echo "$SERVICE_TEMPLATE" | sed "s/{{service_name}}/$service_name/g" | sed "s/{{port}}/$port/g" | sed "s/{{build_path}}/${service_name}\//g") | ||
DOCKER_COMPOSE_CONTENT="$DOCKER_COMPOSE_CONTENT | ||
$service_definition" | ||
done | ||
|
||
# Add the qtap.local service | ||
DOCKER_COMPOSE_CONTENT="$DOCKER_COMPOSE_CONTENT | ||
$QTAP_LOCAL_SERVICE" | ||
|
||
# Write the content to the main docker-compose.yml | ||
echo "$DOCKER_COMPOSE_CONTENT" > docker-compose.yml | ||
|
||
echo "docker-compose.yml generated successfully." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
qtap.local: | ||
image: "us-docker.pkg.dev/qpoint-edge/public/qpoint:head" | ||
environment: | ||
- TOKEN=${TOKEN} | ||
command: > | ||
proxy | ||
--envoy-log-level=info | ||
--log-level=debug | ||
--registration-token=$TOKEN | ||
--log-encoding="console" | ||
--dns-lookup-family="V4_ONLY" | ||
ports: | ||
- "10080:10080" | ||
- "10443:10443" | ||
- "18080:18080" | ||
- "18443:18443" | ||
- "9901:9901" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{{service_name}}: | ||
build: {{build_path}} | ||
environment: | ||
- HTTP_PROXY=http://qtap.local:18080 | ||
- HTTPS_PROXY=http://qtap.local:18443 | ||
ports: | ||
- "{{port}}:80" | ||
depends_on: | ||
- qtap.local |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
-----BEGIN CERTIFICATE----- | ||
MIIDwTCCAqmgAwIBAgIUK+ZRUvKcW6HX/T5Dy+vof/XU2TMwDQYJKoZIhvcNAQEL | ||
BQAwcDELMAkGA1UEBhMCVVMxEDAOBgNVBAgMB0RlZmF1bHQxEDAOBgNVBAcMB0Rl | ||
ZmF1bHQxEDAOBgNVBAoMB0RlZmF1bHQxEDAOBgNVBAsMB0RlZmF1bHQxGTAXBgNV | ||
BAMMEGpvbmZyaWVzZW4uY2EgQ0EwHhcNMjQwNTI0MTkzNzM1WhcNMjkwNTIzMTkz | ||
NzM1WjBwMQswCQYDVQQGEwJVUzEQMA4GA1UECAwHRGVmYXVsdDEQMA4GA1UEBwwH | ||
RGVmYXVsdDEQMA4GA1UECgwHRGVmYXVsdDEQMA4GA1UECwwHRGVmYXVsdDEZMBcG | ||
A1UEAwwQam9uZnJpZXNlbi5jYSBDQTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCC | ||
AQoCggEBAKiuUUQdsMOqunKCg3a5QjEiHZpPgv+9vP7sA3VIAUz1TQkS2dKLQIQT | ||
6NbW1HR0iJoNmzy+6Z50BH9d753yVt6AoJ3a7Sias8harF1ei31P8wIsuIGNOrDb | ||
66Yj7HlajBf8HVvj5IB9b9Nix5IsWI7OAn5kx2fA8oIzkcfJJKHgKl15OZkXqynD | ||
B2aRZI7XF8n0Qfh65n5HTDOSh9aiTGLqjGXiwIF4R8ghNwvPVaHdxYOVufoDNnrQ | ||
9BPw6xfIzK4CrIIn9v8VVyDHuizTWFRdCrRITbjJq/mK179hAJ6RSLkx9kWNPr/c | ||
dGyFLfIzc3EAoPLehGFLDYPWZXP2rL8CAwEAAaNTMFEwHQYDVR0OBBYEFNqN+ku6 | ||
vZoh8D8IjbtzSU+RiWyGMB8GA1UdIwQYMBaAFNqN+ku6vZoh8D8IjbtzSU+RiWyG | ||
MA8GA1UdEwEB/wQFMAMBAf8wDQYJKoZIhvcNAQELBQADggEBAKKK/XyFocCzdhvJ | ||
IcNMfx2eoiUvHT3Jt8mfNjcvN1F8TjLs3oa3kcMt2oG7FqslGHHafwK/6aaj8l0N | ||
rQEHk2yq7EQCoDEGjS1VnphQwQYX73I9Lhad32FgdMLtrgeObLyiCqkf4GhtX13X | ||
tcQOqSkGslogh9KuLYa9IbJXVF777njYt1ZGZyAeBl1eAFvvOGXsAfKFzdDVCIb3 | ||
5lHtuW9/Pyv0kasxpW9wxlLcwt+dsw6ic0ce8Cz1CAKKHBquk6Cvu+9ZkofzpTnT | ||
QiKFvtukOdcgthFflY+ysMfFnsE5quMp0bfVGgnj7wVBO3F9etiE4rwHHd0asjYU | ||
+gDKUHw= | ||
-----END CERTIFICATE----- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
-----BEGIN PRIVATE KEY----- | ||
MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCorlFEHbDDqrpy | ||
goN2uUIxIh2aT4L/vbz+7AN1SAFM9U0JEtnSi0CEE+jW1tR0dIiaDZs8vumedAR/ | ||
Xe+d8lbegKCd2u0omrPIWqxdXot9T/MCLLiBjTqw2+umI+x5WowX/B1b4+SAfW/T | ||
YseSLFiOzgJ+ZMd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7qf0Vm | ||
P1E1QkZw/0I93dfH7Tedmv+M47nyTwxMef+gU3i/6PLeCJbRlLhUk9MVAoGBALlB | ||
0lcDucbMu/Q0OMVW5+6iKsElVhcKFIeMwzrl8/fdz9zQaPvW95wWTgBgKN74NXnC | ||
c1HEo5X07XwbJ0ZB38BWj2sD9njeYceEo3cMvUTc+6Gp47jFFTTqP2QB8LKtVPIT | ||
ZgXGfn/BLitWMBHoCs6L3Hdipq5Jb3iRmWvXfrUZAoGAKyYuVBijxFzLOZtZpZb7 | ||
UCq/R8W3SefbC0nKegglJHqqd9Oh3tOjChqlso6zDmVVvX+lODeswcLhl7I4vxMQ | ||
GhU9Ov054153PfXK257hGX4A+x3p7JOrumrXOk7/zp10SIoexBEoqwPwRilqBLFC | ||
aMuC1vrrI6Uu+zXRneiUc1E= | ||
-----END PRIVATE KEY----- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
24DC382471539083AEF30CF58F3040F91C36A266 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
httpbin.org | ||
ipapi.co | ||
api.openweathermap.org |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Use a lightweight image with necessary tools | ||
FROM alpine:latest | ||
|
||
# Install curl and jq | ||
RUN apk --no-cache add curl jq bash ca-certificates | ||
|
||
# Set the working directory inside the container | ||
WORKDIR /app | ||
|
||
# Copy the Bash script into the container | ||
COPY geoweather.sh . | ||
|
||
# Ensure the script has execute permissions | ||
RUN chmod +x geoweather.sh | ||
|
||
# Make port 80 available to the world outside this container | ||
EXPOSE 80 | ||
|
||
# Run the Bash script when the container launches | ||
CMD ["./geoweather.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
version: '3.8' | ||
|
||
services: | ||
curl-geoweather: | ||
build: . | ||
environment: | ||
- HTTP_PROXY=http://qtap.local:18080 | ||
- HTTPS_PROXY=http://qtap.local:18443 | ||
ports: | ||
- "4000:80" | ||
depends_on: | ||
- qtap.local | ||
qtap.local: | ||
image: "qpoint:dev" | ||
environment: | ||
- TOKEN=${TOKEN} | ||
command: > | ||
proxy | ||
--envoy-log-level=info | ||
--log-level=debug | ||
--registration-token=$TOKEN | ||
--log-encoding="console" | ||
--dns-lookup-family="V4_ONLY" | ||
ports: | ||
- "10080:10080" | ||
- "10443:10443" | ||
- "18080:18080" | ||
- "18443:18443" | ||
- "9901:9901" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
#!/bin/bash | ||
|
||
OWM_API_KEY="56e9e892982ed4de87fb7d8a6f470463" | ||
|
||
# Function to get public IP | ||
get_public_ip() { | ||
local ip | ||
ip=$(curl -s https://httpbin.org/ip | jq -r .origin) | ||
if [ -z "$ip" ]; then | ||
echo "Unable to get public IP" | ||
exit 1 | ||
fi | ||
echo "$ip" | ||
} | ||
|
||
# Function to get location from IP | ||
get_location() { | ||
local ip="$1" | ||
local location | ||
location=$(curl -s "https://ipapi.co/${ip}/json/") | ||
if [ -z "$location" ]; then | ||
echo "Unable to get location" | ||
exit 1 | ||
fi | ||
echo "$location" | ||
} | ||
|
||
# Function to get weather from latitude and longitude | ||
get_weather() { | ||
local lat="$1" | ||
local lon="$2" | ||
local weather | ||
weather=$(curl -s "https://api.openweathermap.org/data/2.5/weather?lat=${lat}&lon=${lon}&appid=${OWM_API_KEY}&units=metric") | ||
if [ -z "$weather" ]; then | ||
echo "Unable to get weather" | ||
exit 1 | ||
fi | ||
echo "$weather" | ||
} | ||
|
||
# Main function to fetch and display weather information | ||
main() { | ||
echo "Starting weather function" | ||
|
||
local public_ip | ||
public_ip=$(get_public_ip) | ||
echo "Public IP fetched: $public_ip" | ||
|
||
local location | ||
location=$(get_location "$public_ip") | ||
echo "Location fetched for IP $public_ip: $location" | ||
|
||
local city country latitude longitude | ||
city=$(echo "$location" | jq -r .city) | ||
country=$(echo "$location" | jq -r .country_name) | ||
latitude=$(echo "$location" | jq -r .latitude) | ||
longitude=$(echo "$location" | jq -r .longitude) | ||
|
||
if [ -z "$latitude" ] || [ -z "$longitude" ]; then | ||
echo "Error fetching location data for IP: $public_ip" | ||
exit 1 | ||
fi | ||
|
||
local weather | ||
weather=$(get_weather "$latitude" "$longitude") | ||
echo "Weather fetched for location $latitude, $longitude: $weather" | ||
|
||
local description temperature | ||
description=$(echo "$weather" | jq -r .weather[0].description) | ||
temperature=$(echo "$weather" | jq -r .main.temp) | ||
|
||
echo -e "\nWeather for $city, $country" | ||
echo "Current weather: $description" | ||
echo "Temperature: ${temperature}°C" | ||
} | ||
|
||
main |
Oops, something went wrong.