Skip to content

Latest commit

 

History

History
61 lines (42 loc) · 977 Bytes

sinatra.md

File metadata and controls

61 lines (42 loc) · 977 Bytes

Docker - Sinatra

Files:

  • Gemfile
  • app.rb
  • config.ru
  • docker-composer.yml

Gemfile:

source 'https://rubygems.org'

gem 'sinatra'

app.rb:

require 'sinatra'

get '/' do
  'Hello world!'
end

config.ru:

require './app'
run Sinatra::Application

docker-compose.yml:

version: "3.7"

services:


  # sinatra_app
  # ----------------------------------------------------------------------
  sinatra_app:
    image:       'ruby:2.7.0'
    ports:       [ '3000:3000' ]
    volumes:     [ '.:/app', 'bundle-cache:/usr/local/bundle' ]
    working_dir: '/app'

    # use this to "ssh" in to box with: docker-compose run --rm --service-ports sinatra_app
    # command: /bin/bash

    # use this to run the server
    command: bash -c 'bundle install && bundle exec rackup -p 3000 --host 0.0.0.0'
  # ----------------------------------------------------------------------


volumes:
  bundle-cache: