Prompt Matcher
Rails app where you can search prompts from huggingface.
Requirements
- Ruby 3.2.2
- postgres
- redis
- elasticsearch v8.10.2
- nodejs
- esbuild
- yarn
- docker - optional
Setup
Hybrid mode - app running in host + elastic + dbs via docker containers
- make local version for .env via
cp .env-local .env
- Since elasticsearch v8.10.2 requries https enabled there is additional step to do:
- start elasticsearch container via
docker compose up es01
- check in the logs if the cluster is up and running
- copy certificate from elasticsearch container
docker cp prompt_matcher-es01-1:/usr/share/elasticsearch/config/certs/ca/ca.crt ./ca.crt
- stop container
- install esbuld via
npm install -g esbuild
- install yarn via
npm install -g yarn
- bundle install
- yarn install
- prepare postgres db via
bin/rails db:create
Docker version
Note:
Latest version of elasticsearch requires ssl running locally. In the result docker compose setup is quite complex. I have found a good recipe in elastic search blog post. In the result initial setup may look like super complex, but it's a new reality :D
- make local version for .env via
cp .env-example .env
- Since elasticsearch v8.10.2 requries ssl enabled there is additional steps to do:
- start elasticsearch container via
docker compose up es01
- check in the logs if the cluster is up and running
- copy certificate from elasticsearch container
docker cp prompt_matcher-es01-1:/usr/share/elasticsearch/config/certs/ca/ca.crt ./ca.crt
- stop container
- build the base image
docker compose build --no-cache app
- prepare postgres db:
docker compose run -u rails --rm app /bin/bash
bin/rails db:create
Load prompts from huggingface
Hybrid mode
bin/rails db:migrate
bin/rails db:seed
Docker version
docker compose run -u rails --rm app /bin/bash
bin/rails db:migrate
bin/rails db:seed
Start application
Hybrid mode
Execute following command: bin/dev
Docker version
Execute following command: docker compose up app
Note: I have noticed that sometimes there there is missed folder permission for tmp/cache
, but it may be releated to my local env.
Test
Since full docker version is not working properly I would run specs only from host side:
RAILS_ENV=test bin/rails db:migrate
bin/rspec
Code quality & security
Code quality keeper standardrb
bundle exec standardrb
Security scan via bundle exec brakeman
Deployment ideas
These days I would try following options: