Created
March 6, 2019 00:30
-
-
Save usergenic/22939cd68be8705f9ef78fd018863149 to your computer and use it in GitHub Desktop.
With just these three files, you can run a sinatra app with redis using Docker.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'sinatra' | |
require 'redis' | |
set :bind, '0.0.0.0' | |
Cache = Redis.new(host: 'redis', port: 6379) | |
def get_hit_count | |
Cache.incr('hits') | |
end | |
get '/' do | |
"Hello World! I have been hit #{get_hit_count} times.\n" | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: '3' | |
services: | |
web: | |
build: . | |
ports: | |
- "4567:4567" | |
volumes: | |
- .:/code | |
redis: | |
image: "redis:alpine" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM ruby:2.5.1-alpine | |
WORKDIR /code | |
RUN gem install sinatra | |
RUN gem install redis | |
CMD ["ruby", "app.rb"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment