Coffee search example: rebuild db during docker build and add more documentation.

This commit is contained in:
Sebastian Jeltsch
2024-11-20 14:23:53 +01:00
parent b004188a5a
commit f0133fdffa
4 changed files with 36 additions and 10 deletions

View File

@@ -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).

View File

@@ -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

View File

@@ -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

View File

@@ -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