Advertisement
galbator1x

Untitled

Dec 28th, 2017
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.45 KB | None | 0 0
  1. ====== Dockerfile
  2. # Base image:
  3. FROM ruby:2.4.2
  4.  
  5. # Install dependencies
  6. RUN apt-get update -qq && apt-get install -y build-essential libpq-dev nodejs software-properties-common
  7. RUN apt-get update -qq && apt-get install -y imagemagick
  8.  
  9. # Set an environment variable where the Rails app is installed to inside of Docker image:
  10. ENV RAILS_ROOT /thegame
  11. #ENV RAILS_ENV production
  12. RUN mkdir -p $RAILS_ROOT
  13.  
  14. # Set working directory, where the commands will be ran:
  15. WORKDIR $RAILS_ROOT
  16.  
  17. # Gems:
  18. COPY Gemfile Gemfile.lock ./
  19. RUN gem install bundler && bundle install --jobs 20 --retry 5
  20. RUN gem list activerecord
  21.  
  22. ADD config/puma.rb config/puma.rb
  23.  
  24. # Copy the main application.
  25. COPY . .
  26.  
  27. EXPOSE 3000
  28.  
  29.  
  30.  
  31. ====== docker-compose.prod.yml
  32. version: '2'
  33. services:
  34. postgres:
  35. image: postgres:9.4.5
  36. environment:
  37. POSTGRES_USER: thegame
  38. POSTGRES_PASSWORD: thegame
  39. ports:
  40. - '5435:5432'
  41. volumes:
  42. - thegame-postgres:/var/lib/postgresql/data
  43. app:
  44. build:
  45. context: .
  46. dockerfile: Dockerfile.prod
  47. command: ./entrypoint
  48. volumes:
  49. - .:/thegame
  50. ports:
  51. - "3010:3000"
  52. env_file:
  53. - .env.production
  54. volumes:
  55. thegame-postgres:
  56.  
  57.  
  58.  
  59. ====== entrypoint
  60. #!/bin/bash
  61. set -e
  62. if [[ -a /tmp/puma.pid ]]; then
  63. rm /tmp/puma.pid
  64. fi
  65.  
  66. if [[ \$RAILS_ENV == "production" ]]; then
  67. rake assets:precompile
  68. fi
  69.  
  70. rails server -b 0.0.0.0 -P /tmp/puma.pid -p 3000
  71. exec "\$@"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement