Skip to content

Commit 5594889

Browse files
committed
k8s
1 parent c0bbacc commit 5594889

9 files changed

Lines changed: 151 additions & 22 deletions

File tree

.github/workflows/docker-image.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: Binder Image
2+
on:
3+
workflow_dispatch: null
4+
push: null
5+
jobs:
6+
build:
7+
runs-on: ubuntu-latest
8+
permissions: write-all
9+
steps:
10+
- uses: actions/checkout@v3
11+
- name: Publish to GitHub Container Registry
12+
uses: elgohr/Publish-Docker-Github-Action@v5
13+
with:
14+
name: boettiger-lab/inat-ranges
15+
username: ${{ github.actor }}
16+
password: ${{ secrets.GITHUB_TOKEN }}
17+
registry: ghcr.io
18+

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,4 @@ rsconnect/
5555
*.pmtiles
5656
Rplots.pdf
5757
.tmp/
58+
kubernetes/set-secrets.sh

Dockerfile

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,22 @@ FROM rocker/geospatial:latest
33
WORKDIR /code
44

55
RUN install2.r --error \
6-
bench \
7-
bsicons \
8-
bslib \
9-
duckdbfs \
10-
fontawesome \
11-
gt \
12-
markdown \
13-
shiny \
14-
shinybusy \
15-
shinychat \
16-
tidyverse
6+
bench \
7+
bsicons \
8+
bslib \
9+
duckdbfs \
10+
fontawesome \
11+
gt \
12+
markdown \
13+
shiny \
14+
shinybusy \
15+
shinychat \
16+
tidyverse \
17+
mapgl \
18+
ellmer \
19+
conflicted
20+
1721

18-
RUN installGithub.r cboettig/mapgl tidyverse/ellmer boettiger-lab/duckdb.agent cboettig/duckdbfs
1922

2023
COPY . .
2124

app/app.R

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ server <- function(input, output, session) {
198198
observeEvent(input$chat_user_input, {
199199
taxa_selected <- txt_to_taxa(input$chat_user_input)
200200
chat_append("chat", "done")
201+
chat_clear("chat")
201202

202203
# optionally - store the selection as global variable for future reactions
203204
taxa_filter(taxa_selected)

kubernetes/deployment.yaml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: gbif
5+
labels:
6+
k8s-app: gbif
7+
spec:
8+
containers:
9+
- name: gbif
10+
image: ghcr.io/boettiger-lab/gbif-explorer
11+
imagePullPolicy: Always
12+
env:
13+
14+
- name: AWS_ACCESS_KEY_ID
15+
valueFrom:
16+
secretKeyRef:
17+
name: aws
18+
key: AWS_ACCESS_KEY_ID
19+
- name: AWS_SECRET_ACCESS_KEY
20+
valueFrom:
21+
secretKeyRef:
22+
name: aws
23+
key: AWS_SECRET_ACCESS_KEY
24+
- name: AWS_S3_ENDPOINT
25+
value: "rook-ceph-rgw-nautiluss3.rook"
26+
- name: AWS_PUBLIC_ENDPOINT
27+
value: "s3-west.nrp-nautilus.io"
28+
- name: AWS_HTTPS
29+
value: "false"
30+
- name: AWS_VIRTUAL_HOSTING
31+
value: "FALSE"
32+
- name: NRP_API_KEY
33+
valueFrom:
34+
secretKeyRef:
35+
name: nrp-api-key
36+
key: NRP_API_KEY
37+
- name: MAPTILER_API_KEY
38+
valueFrom:
39+
secretKeyRef:
40+
name: maptiler-api-key
41+
key: MAPTILER_API_KEY
42+
resources:
43+
requests:
44+
cpu: 8
45+
memory: 8Gi
46+
limits:
47+
cpu: 8
48+
memory: 8Gi
49+
50+

kubernetes/ingress.yaml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
apiVersion: networking.k8s.io/v1
2+
kind: Ingress
3+
metadata:
4+
annotations:
5+
haproxy.org/timeout-server: "300s"
6+
haproxy.org/timeout-client: "300s"
7+
haproxy.org/timeout-connect: "30s"
8+
haproxy.org/timeout-http-request: "300s"
9+
name: inat-ingress
10+
spec:
11+
ingressClassName: haproxy
12+
rules:
13+
- host: gbif.nrp-nautilus.io
14+
http:
15+
paths:
16+
- path: /
17+
pathType: Prefix
18+
backend:
19+
service:
20+
name: gbif
21+
port:
22+
number: 8080
23+
tls:
24+
- hosts:
25+
- gbif.nrp-nautilus.io

kubernetes/service.yaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
name: gbif
5+
labels:
6+
k8s-app: gbif
7+
8+
# ports.targetPort is the port exposed by the Docker container
9+
# ports.port is the port matched to the ingress
10+
spec:
11+
ports:
12+
- port: 8080
13+
protocol: TCP
14+
targetPort: 8080
15+
selector:
16+
k8s-app: gbif
17+
type: ClusterIP

tests/test-llm-app.R

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# interactive()
2+
library(shiny)
3+
library(bslib)
4+
library(shinychat)
5+
6+
ui <- page_fillable(
7+
chat_ui("chat", fill = TRUE)
8+
)
9+
10+
server <- function(input, output, session) {
11+
observeEvent(input$chat_user_input, {
12+
# In a real app, this would call out to a chat model or API,
13+
# perhaps using the 'ellmer' package.
14+
response <- paste0(
15+
"You said:\n\n",
16+
"<blockquote>",
17+
htmltools::htmlEscape(input$chat_user_input),
18+
"</blockquote>"
19+
)
20+
chat_append("chat", NULL)
21+
})
22+
}
23+
24+
shinyApp(ui, server)

tests/test-llm.R

Lines changed: 0 additions & 10 deletions
This file was deleted.

0 commit comments

Comments
 (0)