Skip to content

aurexli/kitchen_roll

Repository files navigation

Cooking App

This project is a self-hosted collection of recipes.

Requirements

  • Installed Docker: This project uses 3 container to run the following services:
    • rails application
    • mysql database
    • nginx as a reverse proxy

How to get started

  1. Clone the repository
git clone git@github.com:aurexli/cooking_app.git
  1. Create the environment and credential files Create env file that is used by docker.
cd cooking_app
cp .env.example .env
# Generate a user/password and populate the file
vim .env

Create local env that is used by the rails application.

touch config/local_env.yml

This file should contain this content:

DATABASE_NAME_DEV: db/developmentdb
DATABASE_NAME_TEST: db/testdb
DATABASE_NAME_PROD: db/productiondb
SOCKET: /var/run/mysqld/mysqld.sock
HOST: localhost
ADMIN_PASSWORD: some-admin-password

ADMIN_PASSWORD is the default admin user that exits after the database has been seeded. The admin user is called asdf. To change the name of the admin user, edit the last line in db/seeds.rb.

  1. The website runs on port 80 per default. You can adjust the nginx config in docker/nginx.conf.

  2. Build and start the cooking application

docker compose build
docker compose up -d
  1. Create and initialize the database
docker exec rails_app bundle exec rake db:create
docker exec rails_app bundle exec rake db:migrate
  1. Seed the database with the ingredients and the default admin user
docker exec rails_app bundle exec rake db:seed

Stop the application

docker compose down

Notes for debugging

  • View logs

    docker compose logs
  • Get interactive shell

    docker container ls
    docker exec -it <docker-container-id> bash

Used libraries, etc

  • ruby, version: 3.2.5
  • rails, version: 8.0.2
  • stimulus libraries:
      bin/importmap pin @stimulus-components/rails-nested-form
      bin/importmap pin slim-select
      bin/importmap pin stimulus-textarea-autogrow
      bin/importmap pin stimulus-use

How to run the test suite locally

  1. You need to install rails and ruby.

  2. Create credentials file

# Create config/credentials/production.yml.enc
EDITOR="code --wait" rails credentials:edit

# The content should be:
# database:
#   username:
#   password:
  1. Replace the values in config/database.yml
-username: <%= ENV['DB_USER'] %>
+username: <%= Rails.application.credentials.database.username %>

-password: <%= ENV['DB_PASSWORD'] %>
+password: <%= Rails.application.credentials.database.password %>

-host: <%= ENV['DB_HOST'] %> # created by docker compose
+host: <%= ENV["HOST"] %>
  1. Run tests
# Run one test
rails test test/models/recipe_test.rb
# Run all tests
rails test test

About

Collection of cook books.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published