This is the rails based web project of the Pulcsi és Foltmékör group
- Ruby 3.0.3
- Node.js
- Postgresql 15.0
- Redis (for hot reload during development)
OR
- Docker with compose
For the application to run you need to setup a database and optionally a Redis isntance.
-
Set up Postgresql DB with default user/password
postgres/postgres -
Copy the
.env.examplefile to.envand set up the DB port -
Run
rails db:setupto create the databases -
Run
npm ito install flowbite (Tailwind components library) -
WITH Rails 7 You have to run with
bin/devinstead ofrails s
- Create a
.envfile from the example - There is a
docker-compose.dev.ymlfile to set up DB and Redis for you - Run
docker compose -f docker-compose.dev.yml up -d - After running you can set up the db with
rails db:setup - Run
npm ito install flowbite (Tailwind components library) - Run the app with
bin/dev
- Create a
.envfile from the example - Run
npm ito install flowbite (Tailwind components library) - Build image with
docker compose -f docker-compose.dev.yml --profile=full_docker build- Run dev server with
docker compose -f docker-compose.dev.yml --profile=full_docker upThis sets up docker in a way that both hot reload and db is working out of the box The project folder is attached as a volume, so every change is instantly reflected in the docker image. This way it is not required to restart the server.
While its running you can access the server console with
docker compose -f docker-compose.dev.yml exec -it web bashto run rails commands
Rails 7 works with importmap-rails instead of npm or Yarn. To add a Node dependency
use the following command (i.e React)
bin/importmap pin react@17.0.1After that you can use it in any javascript file
import React from "react"
import ReactDOM from "react-dom"
//...to remove a dependency use
bin/importmap unpin reactThe app uses Hotwire::Livereload
for easier development with TailwindCSS.
This require a Redis instance to run.
If you don't run it locally you can set the url in the .env file
REDIS_URL="redis://live-reload:6379/1"If you want to disable it run
bin/rails livereload:disableIf you don't have Redis then you can change the development part in config/cable.yml
to
development:
adapter: asyncIf you use bin/dev and the full docker development simultaneously, there is a possibility that tmp/pids/server.pid
does not get deleted. Delete it manually!
Tailwind uses its own bundler that only bundles the used css classes.
- If you run the app with
rails sthen it does not get compiled automatically - I you run
assets:precompilethe new css files can be ignored. Delete all files frompublic/assets. Don't run assets:precompile again
If you develop in only docker, the compose file sets up all the necessary env variables, but compose will look for the .env file. Create an empty one if there is none.