The administration system for Schönherz Student Hostel and SVIE
- Ruby 2.5.7
- Postgresql 9.6
- Node (asset compiling)
- Redis (optional)
or
- Docker
# Redis is optional
sudo apt install postgresql-9.6 libpq-dev nodejs redis-server
Use asdf with ruby plugin or rbenv. Install Ruby 2.5.7 and set executable version. You can check current ruby version with ruby -v
Easiest way to install brew, then install required packages.
# Redis is optional
brew install asdf [email protected] redis
brew services start [email protected]
brew services start redis
Add ruby and node plugin to asdf. Install Ruby 2.5.7 and set executable version. You can check current ruby version with ruby -v
. Install node too.
git clone https://github.com/kir-dev/pek-next.git
cd pek-next
gem install bundler
bundle install
Create a .env
file using .env.example
and replace the values with real ones.
sudo su postgres
psql -c 'create user "pek-next" with superuser password '\''pek-next'\'';'
As your own user
rake db:setup
rails s
bundle exec sidekiq
rake test
Easiest way for deployment is docker-compose.
Copy .env
from .env.example
, add APP_ID
and APP_SECRET
according to auth.sch and generate a SECRET_KEY_BASE
using bundle exec rake secret
.
Then run the following commands:
# These volumes are not necessary and could be removed from docker-compose, but a named volume easier to find later on
docker volume create pek_public
docker volume create pek_database
docker-compose up --build
To deploy the application in staging environment use the following command:
docker-compose -f docker-compose.yml -f docker-compose.staging.yml up -d --build
After creating, while the containers are running run the following commands:
# This is only necessary at new setups
docker-compose run web bash -c "bundle exec rake db:setup"
# This is only necessary after pending migrations
docker-compose run web bash -c "bundle exec rake db:migrate"
# This is required at new setups and after changing in assets
docker-compose run web bash -c "bundle exec rake assets:precompile"
Be sure to make regular backups in prod.
To create a database dump, use the following commands:
# open a session to the postgres container
docker-compose exec postgres bash
# create the database dump in the postgres container (use your current date),then exit
pg_dump -U postgres -Fc pek-next > /tmp/pek-next-production-db-2022-12-04.dump
exit
# copy the database dump from the container to the host machine
docker cp pek-next_postgres_1:/tmp/pek-next-production-db-2022-12-04.dump ~/db-dumps
To load a previously created database dump, use the following commands:
# copy the dump from the host to the postgres container
docker cp ~/db-dumps/pek-next-production-db-2022-12-04.dump pek-next_postgres_1:/tmp
# open the postgres container and load the database dump
docker-compose exec postgres bash
pg_restore -U postgres -d pek-next /tmp/pek-next-production-db-2022-12-04.dump
sudo apt install ruby-dev
rbenv install -v 2.5.7
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
source ~/.bashrc
Restart your terminal
by Kir-Dev Team