A template for plain Ruby projects with database, backups, cronjobs, email and telegram support.
After cloning this template, customize the required gems in Gemfile
then run
bin/setup -d
to install all development dependencies and duplicate the example
configuration and env files.
In production, invoke it with bin/setup -p
in order to locally configure bundler
for deployment and skip development dependencies.
Run rake template:rename PROJECT=newname
to rename the project and replace all
occurrences across the repo files.
Customize config/config.yml
with your credentials and variables.
Use the installed whenever
gem to schedule recurring jobs via cron.
Customize the logic and the time interval in config/schedule.rb
, then run
bundle exec whenever --update-crontab
.
The development console is available via bin/console
.
The database supports migrations out-of-the-box: add progressive migration files
in the db/migrations
folder and run rake db:migrate
to migrate.
To extend this template, simply add your custom code and logic in lib/
and in
.rake
files under the tasks/
directory.
An optional rake task is available to create an HTML page from an ERB template that can be populated with database or other dynamic values and then served by a web server, functioning as visual output of the project.
First, customize your ERB template in web/template.html.erb
, along with the
css and javascript in the public folder if you need to. Then setup the variables
binding in the web/variables.yml
file. These variables will then be expanded
in the template when running rake web:build
and a web/public/index.html
file
will be created.
Don't forget to call the rake task in the schedule too if you want the page to be
updated automatically.
Use rake web:serve
to launch WEBrick locally and see your result.
In production you'll want to serve the web/public
folder as a whole.
Environmental variables have precedence over values defined in the configuration file and can be used to override them.
CONFIG_FILE
: Path to YAML configuration file
DATABASE_URL
: Database URL (overrides all other database variables)POSTGRES_HOST
orMYSQL_HOST
: Database hostname or IPPOSTGRES_PORT
orMYSQL_PORT
: Database portPOSTGRES_USERNAME
orMYSQL_USERNAME
: Database usernamePOSTGRES_PASSWORD
orMYSQL_PASSWORD
: Database passwordPOSTGRES_DATABASE
orMYSQL_DATABASE
: Database name
SQLITE_FILE
: Database file path
REDIS_HOST
: Database hostname or IPREDIS_PORT
: Database portREDIS_DATABASE
: Database number
SUPPRESS_LOG
: Suppress stdout/stderr log outputLOG_TO_FILE
: Log to file instead of stdout/stderrSTDOUT_LOG
: Standard output log file pathSTDERR_LOG
: Standard error log file path
TELEGRAM_APP_NAME
: Application name displayed in messagesTELEGRAM_TOKEN
: Bot tokenTELEGRAM_USER
: Recipient user IDTELEGRAM_ENABLED
: Whether Telegram notifications are enabled
AWS_S3_ACCESS_KEY_ID
: Access keyAWS_S3_SECRET_ACCESS_KEY
: Secret access keyAWS_S3_REGION
: RegionAWS_S3_BUCKET
: Bucket nameAWS_S3_PREFIX
: Bucket prefix (with final slash)
AWS_SES_ACCESS_KEY_ID
: Access keyAWS_SES_SECRET_ACCESS_KEY
: Secret access keyAWS_SES_REGION
: RegionAWS_SES_FROM_NAME
: Name of the senderAWS_SES_FROM_EMAIL
: Email of the senderAWS_SES_TO_EMAIL
: Email of the recipient(s)AWS_SES_ENCODING
: Character encoding (default UTF-8)