Skip to content

tamatebako/tebako-samples

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Tebako sample applications

This repository provides sample applications to demonstrate usage of Tebako.

Right now there is only one sample.

Sinatra

Running in standalone mode:

$ cd sinatra
$ bundle install
$ bundle exec ruby app.rb

This launches a Sinatra server that responds at:

Packaging for MacOS

Install Tebako according to the Tebako README.

Run this:

tebako press -e app.rb -o sample.tebako -r sinatra
Warning

Please do not package "in-place" like:

tebako press -e app.rb -o sinatra.tebako -r ./

Tebako includes all files starting from the root folder into package and packaging "in-place" will force endless recursive inclusion of the package into itself.

Packaging for Ubuntu, Alpine Linux

Packaging for Ubuntu and Alpine Linux employs Tebako Docker containers available through ghrc.io.

There are no prerequisites for using these containers.

Packaging from inside the container:

tebako press -e app.rb -o sinatra.teb -r sinatra -R 3.2.5

Packaging from outside the container for Ubuntu:

docker run -v $PWD:/mnt/w -t ghcr.io/tamatebako/tebako-ubuntu-20.04:latest \
  tebako press --root=/mnt/w/sinatra --entry-point=app.rb \
  --output=/mnt/w/sinatra.tebako --Ruby=3.2.5 --patchelf

This command:

  • mounts current directory to /mnt/w

  • packages the application in /mnt/w/sinatra.tebako

  • applies the experimental --patchelf option to make it portable across different versions of GLIBC.

Please refer to tebako README for more information.

Support for glibc forward portable packages is subject to the following caveats:

  • The package is built against the installed OpenSSL version on the system (e.g. 1.1.1), which needs to be present at the target system. If the target system has a different version of OpenSSL, the package will not work.

Packaging from outside the container for Alpine:

docker run -v $PWD:/mnt/w -t ghcr.io/tamatebako/tebako-alpine-3.17:latest \
  tebako press --root=/mnt/w/sinatra --entry-point=app.rb \
  --output=/mnt/w/sinatra.tebako --Ruby=3.2.5

Packaging for glibc-based Linux distributions using the Ubuntu container

This sample shows how to create portable tebako package for GNU Linux distributions, such as Red Hat Enterprise Linux, CentOS, Fedora, Rocky Linux, etc.

Ruby on Rails

Command that was used to generate sample application:

rails new ror --skip-bundle  --skip-docker --skip-action-mailer --skip-action-mailbox --skip-action-text --skip-active-storage \
              --skip-action-cable --skip-bootsnap --skip-dev-gems --skip-coffee --skip-sprockets --skip-spring --skip-test

Database configuration at database.yml changed to be more flexible:

default: &default
  adapter: sqlite3
  pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
  timeout: 5000

development:
  <<: *default
  database: <%= ENV.fetch("RAILS_STORAGE") { "storage/development.sqlite3" } %>
test:
  <<: *default
  database: <%= ENV.fetch("RAILS_STORAGE") { "storage/test.sqlite3" } %>

production:
  <<: *default
  database: <%= ENV.fetch("RAILS_STORAGE") { "storage/production.sqlite3" } %>

Running in standalone mode:

cd ror
bundle install
rails server

This launches a rails server that responds at:

Packaging for MacOS

Install Tebako according to the Tebako README.

Run this:

tebako press -e bin/rails -o rails.tebako -r ror
Warning

Please do not package "in-place" like:

tebako press -e app.rb -o rails.tebako -r ./

Tebako includes all files starting from the root folder into package and packaging "in-place" will force endless recursive inclusion of the package into itself.

Packaging for Ubuntu, Alpine Linux

Packaging for Ubuntu and Alpine Linux employs Tebako Docker containers available through ghrc.io.

There are no prerequisites for using these containers.

For example, packaging from outside the container for Ubuntu:

docker run -v $PWD:/mnt/w -t ghcr.io/tamatebako/tebako-ubuntu-20.04:latest \
  tebako press --root=/mnt/w/ror --entry-point=bin/rails \
  --output=/mnt/w/rails.tebako --Ruby=3.2.5 --patchelf

Please refer to Sinatra sample comments above for more Tebako CI containers examples.

Running Tebako-packaged Rails application

There is no configuration option to change where Rails expects the tmp folder to be. The location is hardcoded in multiple places within the Rails codebase, residing under the application root, and as a result, it gets included in the read-only Tebako memfs. Although patches have been proposed (e.g., https://github.com/rails/rails#39583), there is currently no way to change the paths for temporary files, caches, and sockets.

To address this limitation in Rails, Tebako provides --tebako-mount option to mount a host folder to the memfs tree.

For our example we create ror-data folder where temporary files and logs will be placed.

mkdir -p $PWD/ror-data
./rails.tebako server --port=4567  --tebako-mount local/tmp:$PWD/ror-data/tmp \
--tebako-mount local/log:$PWD/ror-data/log

Please refer to tebako README for more information re Tebako runtime options.

License

Copyright Ribose.

Licensed under the 2-clause BSD license.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published