Easily find a tasty cocktail to mix.
Visit https://rockstails.fly.dev/ to try!
- Language: Ruby 4.0.1+
- Web framework: Sinatra (
web.rbis the entry point) - Views: Haml
- CSS: Bootstrap + custom styles
- Testing:
test-unitgem — all test files intest/ - Deployment: Fly.io
The app auto-detects the backend at startup via the DATABASE_URL environment variable:
| Mode | When used | Notes |
|---|---|---|
| File (YAML) | DATABASE_URL not set |
FileDB — reads cocktails and bars from datas/ |
| Hybrid | DATABASE_URL is set |
HybridDB — cocktails from YAML, bars in PostgreSQL |
- Install Ruby 4.0.1+ and Bundler.
- Install dependencies:
bundle install
- Start the app:
ruby web.rb # or: rackup - Visit http://localhost:8080.
-
Install and start PostgreSQL. On macOS:
brew services start postgresql.
On Ubuntu:sudo systemctl start postgresql.service. -
Create the database and user:
sudo -u postgres createuser rockstails sudo -u postgres createdb rockstails sudo -u postgres psql postgres=# ALTER USER rockstails WITH ENCRYPTED PASSWORD 'pass'; postgres=# GRANT ALL PRIVILEGES ON DATABASE rockstails TO rockstails;
-
Run migrations and import data:
rake db:migrate db:import_ingredients db:import_cocktails db:import_bars
-
Run tests:
rake test -
Start the app:
ruby web.rb
-
Visit http://localhost:8080.
Default local DB URL: postgres://rockstails:pass@localhost/rockstails (used automatically by the Rakefile).
-
Build and start containers:
docker-compose up --build
-
Run migrations and import data:
docker-compose run --rm app rake db:migrate db:import_ingredients db:import_cocktails db:import_bars
-
Run the test suite:
docker-compose run --rm app rake test -
Access the app at http://localhost:8080.
-
Stop containers:
docker-compose down
| Task | Description |
|---|---|
rake test |
Run the full test suite |
rake db:migrate |
Run database migrations |
rake db:import_ingredients |
Import ingredients from datas/cocktails.yml into the database |
rake db:import_cocktails |
Import cocktails from datas/cocktails.yml into the database |
rake db:import_bars |
Import bars from datas/bar/ into the database |
rake db:export_cocktails |
Export cocktails from the database back to datas/cocktails.yml |
rake db:export_bars |
Export bars from the database back to datas/bar/ |
All
db:import_*anddb:export_*tasks respect theDATABASE_URLenvironment variable.
| Variable | Default | Description |
|---|---|---|
DATABASE_URL |
(none) | PostgreSQL connection URL. When set, the hybrid backend is used (bars in SQL, cocktails from YAML). When unset, the file backend is used. |
APP_ENV |
default_env |
Rack environment (development, production, etc.). |
PORT |
8080 |
Port the app listens on. |
-
Proxy to the production database:
flyctl proxy 15432:5432 -a rockstails-db
-
Migrate and import data into production:
DATABASE_URL=postgres://rockstails:<password>@localhost:15432/rockstails rake db:migrate db:import_ingredients db:import_cocktails db:import_bars
-
Deploy:
fly deploy
You can use act to run GitHub Actions locally. Requires Docker.
brew install act
act # run default workflow
act -e push # simulate a push event
act -j <job> # run a specific jobOr run act in a container without installing it:
docker run --rm \
-v $(pwd):/github/workspace \
-v /var/run/docker.sock:/var/run/docker.sock \
ghcr.io/nektos/act:latestSimon Difford and http://www.diffordsguide.com for his extensive cocktail database.