Skip to content

KitaitiMakoto/bibid

Repository files navigation

BiB/i'd

BiB/i daemon. Actually, not a daemon.

It hosts EPUB files and generates HTML tags to embed the books into your blog.

Demo

BiB/i'd is running at bibid.kitaitimakoto.net.

Docker Image

kitaitimakoto/bibid

Running BiB/i'd

systemd

Example unit file is here: (/etc/systemd/system/bibid.service)

[Unit]
Description=BiB/i'd EPUB Hosting Service
After=postgresql.service

[Service]
User=www-data
WorkingDirectory=/var/www/bibid/current
EnvironmentFile=/var/www/bibid/current/.env.production
ExecStart=/usr/local/bin/bundle exec puma -b unix:///var/www/bibid/puma.sock
ExecStop=/bin/kill -TERM $MAINPID
ExecReload=/bin/kill -HUP $MAINPID
Restart=on-failure

[Install]
WantedBy=multi-user.target

Docker

% docker pull kitaitimakoto/bibid
% docker run --name bibid -d -p 3000:3000 --env-file=.env -v $(pwd)/gcp-service-account.json:/bibid/gcp-service-account.json kitaitimakoto/bibid

Expose port 3000 to host.

gcp-service-account.json specified for -v option is a file of Google Cloud Platform IAM service account and generated by Google Cloud Platform to access to Google Cloud Storage. See official document for how to generate it.

You may set environment variables blow in a file specified for --env-file or --env option.

  • RACK_ENV: development, test or production
  • DATABASE_URL: Database URL. ex) postgres://bibiduser:bibidpassword@databasehost:5432/bibid_databasename
  • SESSION_SECRET: Random string to sign session cookie. See Session Secret Security section in Sinatra document
  • TWITTER_KEY: OAuth2 client key for Twitter generated at Twitter Application Management site
  • TWITTER_SECRET: OAuth2 client secret for Twitter
  • CONTACT_URI: URI users can contact you
  • CARRIERWAVE_FOG_PROVIDER: Object storage provider. Currently, only Google Cloud Storage is available. Set to google
  • CARRIERWAVE_FOG_PROJECT: Project which include Google Cloud Storage bucket for Bib/i'd instance
  • CARRIERWAVE_FOG_DIRECTORY: Google Cloud Storage bucket name
  • CARRIERWAVE_FOG_KEY_LOCATION: Full path in Docker container for Google Cloud Platform IAM service account file

Development

  1. Install assets
    $ bower install
  2. Install gems
    $ bundle install --path=deps
  3. Copy sample configure file
    $ cp config/apps.sample.rb config/apps.rb
  4. Set :session_secret
    $ $EDITOR config/apps.rb
  5. Set Twitter consumer key and secret
    $ $EDITOR config/apps.rb
  6. Start server
    $ bundle exec rackup config.ru

License

BiB/i'd is released under the AGPLv3. See th file "agpl.txt" for the term.