mirror of
https://github.com/trailbaseio/trailbase.git
synced 2026-02-21 10:19:02 -06:00
Coffee search example: rebuild db during docker build and add more documentation.
This commit is contained in:
@@ -22,6 +22,10 @@ A simple styled Blog example with UIs both for web and Flutter:
|
||||
</picture>
|
||||
</p>
|
||||
|
||||
#### Coffee Search
|
||||
|
||||
A very small web app demonstrating vector search and custom JS/TS endpoints.
|
||||
|
||||
#### First App Tutorial
|
||||
|
||||
The code for the [tutorial](https://trailbase.io/getting-started/first-app).
|
||||
|
||||
@@ -1,15 +1,24 @@
|
||||
FROM trailbase/trailbase:0.2.1 AS base
|
||||
|
||||
COPY traildepot /app/traildepot
|
||||
COPY dist /app/public
|
||||
FROM trailbase/trailbase:0.2.2 AS base
|
||||
|
||||
USER root
|
||||
|
||||
RUN apk add --no-cache sqlite
|
||||
|
||||
# TODO: Add a dedicated build step, both for (re)building the database and
|
||||
# building the web app.
|
||||
|
||||
COPY dist /app/public
|
||||
COPY traildepot /app/traildepot
|
||||
COPY arabica_data_cleaned.csv /app/
|
||||
COPY import.sql /app/
|
||||
|
||||
# Rebuild the database.
|
||||
WORKDIR /app
|
||||
RUN mkdir -p /app/traildepot/data
|
||||
RUN rm -rf /app/traildepot/data/*
|
||||
RUN cat import.sql | sqlite3 traildepot/data/main.db
|
||||
|
||||
RUN chown -R trailbase /app/traildepot/data
|
||||
RUN chmod +w /app/traildepot/data
|
||||
|
||||
|
||||
USER trailbase
|
||||
|
||||
EXPOSE 4000
|
||||
|
||||
@@ -6,8 +6,21 @@ search to build a coffee search.
|
||||
To import the coffee data from CSV, run:
|
||||
|
||||
```bash
|
||||
mkdir -p traildepot/data
|
||||
cat import.sql | sqlite3 traildepot/data/main.db -
|
||||
$ mkdir -p traildepot/data
|
||||
$ cat import.sql | sqlite3 traildepot/data/main.db -
|
||||
```
|
||||
|
||||
To build the web app
|
||||
|
||||
```bash
|
||||
$ pnpm i
|
||||
$ pnpm build
|
||||
```
|
||||
|
||||
Finally, to build the docker container:
|
||||
|
||||
```
|
||||
$ docker build . -t coffee && docker run -p 4001:4000 coffee
|
||||
```
|
||||
|
||||
## Reference
|
||||
|
||||
@@ -19,7 +19,7 @@ addRoute(
|
||||
FROM
|
||||
coffee
|
||||
WHERE
|
||||
Aroma IS NOT NULL
|
||||
embedding IS NOT NULL
|
||||
ORDER BY
|
||||
vector_distance_cos(embedding, '[${aroma}, ${flavor}, ${acidity}, ${sweetness}]')
|
||||
LIMIT 100
|
||||
|
||||
Reference in New Issue
Block a user