Przewodnik po konfiguracji lokalnego środowiska deweloperskiego dla LibreMedia.
| Narzędzie | Wersja | Instalacja |
|---|---|---|
| Ruby | 3.4.6 | rbenv/rvm |
| PostgreSQL | 15+ | Homebrew/apt |
| Node.js | 24+ | nvm |
| Yarn | 1.22+ | npm |
| Redis | 7+ | Homebrew/apt |
| Narzędzie | Opis |
|---|---|
| Elasticsearch 8.x | Wyszukiwanie pełnotekstowe |
| FFmpeg | Przetwarzanie wideo |
| ImageMagick | Przetwarzanie obrazów |
git clone git@github.com:WebgateSystems/lmcore.git libremedia
cd libremedia# rbenv
rbenv install 3.4.6
rbenv local 3.4.6
# LUB rvm
rvm install 3.4.6
rvm use 3.4.6nvm install 24
nvm use 24
# lub użyj pliku .nvmrc
nvm use# Ruby gems
bundle install
# Node packages
yarn install# Utwórz bazę i uruchom migracje
bin/rails db:prepare
# Załaduj dane przykładowe
bin/rails db:seedbin/devAplikacja będzie dostępna pod http://localhost:3000
libremedia/
├── app/
│ ├── controllers/ # Kontrolery
│ │ ├── api/v1/ # API endpoints
│ │ └── concerns/ # Współdzielone moduły
│ ├── models/ # Modele ActiveRecord
│ │ └── concerns/ # Moduły modeli
│ ├── views/ # Widoki Slim
│ ├── javascript/ # Stimulus controllers
│ │ └── controllers/
│ ├── assets/
│ │ ├── stylesheets/ # SCSS
│ │ └── fonts/ # Font Awesome
│ ├── policies/ # Pundit policies
│ ├── services/ # Service objects
│ └── jobs/ # Background jobs
├── config/
│ ├── locales/ # Tłumaczenia i18n
│ └── settings.yml # Konfiguracja aplikacji
├── db/
│ ├── migrate/ # Migracje
│ └── seeds/ # Dane seedowe
│ └── development/
├── docs/ # Dokumentacja
├── spec/ # Testy RSpec
│ ├── models/
│ ├── requests/
│ ├── system/
│ └── factories/
└── ...
# Serwer deweloperski
bin/dev # Rails + JS/CSS watchers
# Konsola Rails
bin/rails c
# Migracje
bin/rails db:migrate
bin/rails db:rollback
# Seedy
bin/rails db:seed
# Routes
bin/rails routes | grep <pattern>
# Generatory
bin/rails g model User name:string
bin/rails g controller Posts index show# Wszystkie testy
bundle exec rspec
# Konkretny plik
bundle exec rspec spec/models/user_spec.rb
# Konkretny test
bundle exec rspec spec/models/user_spec.rb:42
# Z tagiem
bundle exec rspec --tag focus
# Pokrycie kodu
COVERAGE=true bundle exec rspec# Sprawdzenie
bundle exec rubocop
# Auto-fix
bundle exec rubocop -a
# Konkretny plik
bundle exec rubocop app/models/user.rb# Build JS
npm run build
# Build CSS
yarn build:css
# Lub oba
npm run build && yarn build:cssDodaj do ~/.bashrc lub ~/.zshrc:
# LibreMedia shortcuts
alias rsc='rm -rf app/assets/builds/ && npm run build && yarn build:css && rails s'
alias rc='rails c'
alias rs='rails s'
alias rr='bundle exec rspec'
alias be='bundle exec'Główny plik konfiguracji z wartościami domyślnymi.
Lokalne nadpisania (nie commitowane):
# config/settings.local.yml
stripe:
publishable_key: pk_test_...
secret_key: sk_test_...
elasticsearch:
url: http://localhost:9200# .env (nie commitowany)
DATABASE_URL=postgresql://localhost/libremedia_development
REDIS_URL=redis://localhost:6379/0# Rails console
bin/rails db
# Lub bezpośrednio
psql libremedia_developmentbin/rails db:drop db:create db:migrate db:seedpg_dump -Fc libremedia_development > backup.dump
pg_restore -d libremedia_development backup.dump# macOS
brew services start redis
# Linux
sudo systemctl start redisredis-cli
> PING
PONGbundle exec sidekiqDostępny pod /sidekiq (wymaga zalogowania jako admin).
W development joby są wykonywane inline (synchronicznie). Aby testować z Sidekiq:
# config/environments/development.rb
config.active_job.queue_adapter = :sidekiq# macOS
brew services start elasticsearch
# Docker
docker run -d -p 9200:9200 -e "discovery.type=single-node" elasticsearch:8.11.0bin/rails c
> Post.reindex
> Video.reindex# W kodzie
byebugRails.logger.debug "Debug info: #{variable.inspect}"tail -f log/development.logmain— produkcjadevelop— stagingfeature/*— nowe funkcjefix/*— poprawki
<type>: <description>
[optional body]
[optional footer]
Typy: feat, fix, docs, style, refactor, test, chore
# .git/hooks/pre-commit
#!/bin/sh
bundle exec rubocop --force-exclusion
bundle exec rspec --fail-fast# Aktualizuj bundler
gem install bundler
bundle update --bundler# Wyczyść cache
yarn cache clean
rm -rf node_modules
yarn install# Sprawdź czy PostgreSQL działa
pg_isready
# Restart
brew services restart postgresql
# lub
sudo systemctl restart postgresql# Wyczyść assets
rm -rf app/assets/builds/*
rm -rf tmp/cache
# Rebuild
npm run build && yarn build:css- testing.md — Testy i CI/CD
- architecture.md — Architektura systemu