Skip to content

Instantly share code, notes, and snippets.

@adilsoncarvalho
Last active February 1, 2020 02:24
Show Gist options
  • Save adilsoncarvalho/91e779e34f1825968cfeb0b973de8036 to your computer and use it in GitHub Desktop.
Save adilsoncarvalho/91e779e34f1825968cfeb0b973de8036 to your computer and use it in GitHub Desktop.
Docker support for rails-api app
version: "3"
services:
api:
build: .
command: sh -c "rm -rf /api/tmp/pids/server.pid; rails s -b 0.0.0.0"
environment:
# database configuration for development
DEVELOPMENT_DATABASE_URL: postgres://postgres:mellon@postgres:5432/api_dev
# database configuration for testing
TEST_DATABASE_URL: postgres://postgres:mellon@postgres:5432/api_test
# database configuration for production
DATABASE_URL:
# Turning off warnings when running Rails with Ruby 2.7
# https://stackoverflow.com/a/59594760
RUBYOPT: '-W:no-deprecated -W:no-experimental'
depends_on:
- postgres
volumes:
- .:/api
ports:
- 3000:3000
postgres:
image: postgres:11-alpine
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: mellon
ports:
- 5432:5432
# docker run --rm -v "$(pwd):/api" -ti -w /api ruby:2.7-alpine sh
FROM ruby:2.7-alpine
EXPOSE 3000
RUN apk --no-cache add alpine-sdk postgresql-dev tzdata
RUN mkdir /api
WORKDIR /api
COPY Gemfile /api/Gemfile
COPY Gemfile.lock /api/Gemfile.lock
RUN bundle install
COPY . /api
CMD [ "rails", "s", "-b", "0.0.0.0" ]
source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
ruby '2.7.0'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 6.0.2', '>= 6.0.2.1'
# Use postgresql as the database for Active Record
gem 'pg', '>= 0.18', '< 2.0'
# Use Puma as the app server
gem 'puma', '~> 4.1'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
# gem 'jbuilder', '~> 2.7'
# Use Redis adapter to run Action Cable in production
# gem 'redis', '~> 4.0'
# Use Active Model has_secure_password
# gem 'bcrypt', '~> 3.1.7'
# Use Active Storage variant
# gem 'image_processing', '~> 1.2'
# Reduces boot times through caching; required in config/boot.rb
gem 'bootsnap', '>= 1.4.2', require: false
# Use Rack CORS for handling Cross-Origin Resource Sharing (CORS), making cross-origin AJAX possible
gem 'rack-cors'
# Soft deletes for ActiveRecord done right
gem 'discard', '~> 1.1'
# Flexible authentication solution for Rails with Warden
gem 'devise', '~> 4.7', '>= 4.7.1'
# JWT authentication for devise with configurable token revocation strategies
gem 'devise-jwt', '~> 0.6.0'
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
gem 'rspec-rails', '~> 3.9'
end
group :test do
# Used to ensure a clean state for testing by cleaning the database
gem 'database_cleaner'
# Fixtures replacement with a straightforward definition syntax
gem 'factory_bot_rails', '~> 5.1', '>= 5.1.1'
# Fake data generator to use in tests
gem 'faker', '~> 2.10', '>= 2.10.1'
# Matchers for specs
gem 'shoulda-matchers', '~> 4.2'
# Test coverage report
gem 'simplecov', require: false, group: :test
end
group :development do
gem 'listen', '>= 3.0.5', '< 3.2'
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
gem 'spring-watcher-listen', '~> 2.0.0'
end
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
GEM
remote: https://rubygems.org/
specs:
actioncable (6.0.2.1)
actionpack (= 6.0.2.1)
nio4r (~> 2.0)
websocket-driver (>= 0.6.1)
actionmailbox (6.0.2.1)
actionpack (= 6.0.2.1)
activejob (= 6.0.2.1)
activerecord (= 6.0.2.1)
activestorage (= 6.0.2.1)
activesupport (= 6.0.2.1)
mail (>= 2.7.1)
actionmailer (6.0.2.1)
actionpack (= 6.0.2.1)
actionview (= 6.0.2.1)
activejob (= 6.0.2.1)
mail (~> 2.5, >= 2.5.4)
rails-dom-testing (~> 2.0)
actionpack (6.0.2.1)
actionview (= 6.0.2.1)
activesupport (= 6.0.2.1)
rack (~> 2.0, >= 2.0.8)
rack-test (>= 0.6.3)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.2.0)
actiontext (6.0.2.1)
actionpack (= 6.0.2.1)
activerecord (= 6.0.2.1)
activestorage (= 6.0.2.1)
activesupport (= 6.0.2.1)
nokogiri (>= 1.8.5)
actionview (6.0.2.1)
activesupport (= 6.0.2.1)
builder (~> 3.1)
erubi (~> 1.4)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.1, >= 1.2.0)
activejob (6.0.2.1)
activesupport (= 6.0.2.1)
globalid (>= 0.3.6)
activemodel (6.0.2.1)
activesupport (= 6.0.2.1)
activerecord (6.0.2.1)
activemodel (= 6.0.2.1)
activesupport (= 6.0.2.1)
activestorage (6.0.2.1)
actionpack (= 6.0.2.1)
activejob (= 6.0.2.1)
activerecord (= 6.0.2.1)
marcel (~> 0.3.1)
activesupport (6.0.2.1)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 0.7, < 2)
minitest (~> 5.1)
tzinfo (~> 1.1)
zeitwerk (~> 2.2)
bcrypt (3.1.13)
bootsnap (1.4.5)
msgpack (~> 1.0)
builder (3.2.4)
byebug (11.0.1)
concurrent-ruby (1.1.5)
crass (1.0.6)
database_cleaner (1.7.0)
devise (4.7.1)
bcrypt (~> 3.0)
orm_adapter (~> 0.1)
railties (>= 4.1.0)
responders
warden (~> 1.2.3)
devise-jwt (0.6.0)
devise (~> 4.0)
warden-jwt_auth (~> 0.4)
diff-lcs (1.3)
discard (1.1.0)
activerecord (>= 4.2, < 7)
docile (1.3.2)
dry-auto_inject (0.7.0)
dry-container (>= 0.3.4)
dry-configurable (0.9.0)
concurrent-ruby (~> 1.0)
dry-core (~> 0.4, >= 0.4.7)
dry-container (0.7.2)
concurrent-ruby (~> 1.0)
dry-configurable (~> 0.1, >= 0.1.3)
dry-core (0.4.9)
concurrent-ruby (~> 1.0)
erubi (1.9.0)
factory_bot (5.1.1)
activesupport (>= 4.2.0)
factory_bot_rails (5.1.1)
factory_bot (~> 5.1.0)
railties (>= 4.2.0)
faker (2.10.1)
i18n (>= 1.6, < 2)
ffi (1.12.1)
globalid (0.4.2)
activesupport (>= 4.2.0)
i18n (1.8.2)
concurrent-ruby (~> 1.0)
json (2.3.0)
jwt (2.2.1)
listen (3.1.5)
rb-fsevent (~> 0.9, >= 0.9.4)
rb-inotify (~> 0.9, >= 0.9.7)
ruby_dep (~> 1.2)
loofah (2.4.0)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
mail (2.7.1)
mini_mime (>= 0.1.1)
marcel (0.3.3)
mimemagic (~> 0.3.2)
method_source (0.9.2)
mimemagic (0.3.3)
mini_mime (1.0.2)
mini_portile2 (2.4.0)
minitest (5.14.0)
msgpack (1.3.1)
nio4r (2.5.2)
nokogiri (1.10.7)
mini_portile2 (~> 2.4.0)
orm_adapter (0.5.0)
pg (1.2.2)
puma (4.3.1)
nio4r (~> 2.0)
rack (2.1.1)
rack-cors (1.1.1)
rack (>= 2.0.0)
rack-test (1.1.0)
rack (>= 1.0, < 3)
rails (6.0.2.1)
actioncable (= 6.0.2.1)
actionmailbox (= 6.0.2.1)
actionmailer (= 6.0.2.1)
actionpack (= 6.0.2.1)
actiontext (= 6.0.2.1)
actionview (= 6.0.2.1)
activejob (= 6.0.2.1)
activemodel (= 6.0.2.1)
activerecord (= 6.0.2.1)
activestorage (= 6.0.2.1)
activesupport (= 6.0.2.1)
bundler (>= 1.3.0)
railties (= 6.0.2.1)
sprockets-rails (>= 2.0.0)
rails-dom-testing (2.0.3)
activesupport (>= 4.2.0)
nokogiri (>= 1.6)
rails-html-sanitizer (1.3.0)
loofah (~> 2.3)
railties (6.0.2.1)
actionpack (= 6.0.2.1)
activesupport (= 6.0.2.1)
method_source
rake (>= 0.8.7)
thor (>= 0.20.3, < 2.0)
rake (13.0.1)
rb-fsevent (0.10.3)
rb-inotify (0.10.1)
ffi (~> 1.0)
responders (3.0.0)
actionpack (>= 5.0)
railties (>= 5.0)
rspec-core (3.9.1)
rspec-support (~> 3.9.1)
rspec-expectations (3.9.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.9.0)
rspec-mocks (3.9.1)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.9.0)
rspec-rails (3.9.0)
actionpack (>= 3.0)
activesupport (>= 3.0)
railties (>= 3.0)
rspec-core (~> 3.9.0)
rspec-expectations (~> 3.9.0)
rspec-mocks (~> 3.9.0)
rspec-support (~> 3.9.0)
rspec-support (3.9.2)
ruby_dep (1.5.0)
shoulda-matchers (4.2.0)
activesupport (>= 4.2.0)
simplecov (0.17.1)
docile (~> 1.1)
json (>= 1.8, < 3)
simplecov-html (~> 0.10.0)
simplecov-html (0.10.2)
spring (2.1.0)
spring-watcher-listen (2.0.1)
listen (>= 2.7, < 4.0)
spring (>= 1.2, < 3.0)
sprockets (4.0.0)
concurrent-ruby (~> 1.0)
rack (> 1, < 3)
sprockets-rails (3.2.1)
actionpack (>= 4.0)
activesupport (>= 4.0)
sprockets (>= 3.0.0)
thor (1.0.1)
thread_safe (0.3.6)
tzinfo (1.2.6)
thread_safe (~> 0.1)
warden (1.2.8)
rack (>= 2.0.6)
warden-jwt_auth (0.4.0)
dry-auto_inject (~> 0.6)
dry-configurable (~> 0.8)
jwt (~> 2.1)
warden (~> 1.2)
websocket-driver (0.7.1)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.4)
zeitwerk (2.2.2)
PLATFORMS
ruby
DEPENDENCIES
bootsnap (>= 1.4.2)
byebug
database_cleaner
devise (~> 4.7, >= 4.7.1)
devise-jwt (~> 0.6.0)
discard (~> 1.1)
factory_bot_rails (~> 5.1, >= 5.1.1)
faker (~> 2.10, >= 2.10.1)
listen (>= 3.0.5, < 3.2)
pg (>= 0.18, < 2.0)
puma (~> 4.1)
rack-cors
rails (~> 6.0.2, >= 6.0.2.1)
rspec-rails (~> 3.9)
shoulda-matchers (~> 4.2)
simplecov
spring
spring-watcher-listen (~> 2.0.0)
tzinfo-data
RUBY VERSION
ruby 2.7.0p0
BUNDLED WITH
2.1.2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment