Guest User

Untitled

a guest
Nov 6th, 2018
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.34 KB | None | 0 0
  1. docker-compose -f docker-compose.yml -f production.yml up --build
  2.  
  3. docker-compose -f docker-compose.yml -f production.yml build
  4.  
  5. # This is a template. Referenced variables (e.g. $INSTALL_PATH) need
  6. # to be rewritten with real values in order for this file to work.
  7.  
  8. upstream rails_app {
  9. server unix:///webapp/tmp/sockets/puma.sock;
  10. }
  11.  
  12. server {
  13. listen 80;
  14. # define your domain
  15. server_name 127.0.0.1 localhost www.example.com;
  16.  
  17. # define the public application root
  18. root /providre_api/public;
  19.  
  20.  
  21. # define where Nginx should write its logs
  22. access_log /providre_api/log/nginx.access.log;
  23. error_log /providre_api/log/nginx.error.log;
  24.  
  25. # deny requests for files that should never be accessed
  26. location ~ /. {
  27. deny all;
  28. }
  29.  
  30. location ~* ^.+.(rb|log)$ {
  31. deny all;
  32. }
  33.  
  34. # serve static (compiled) assets directly if they exist (for rails production)
  35. location ~ ^/(assets|images|javascripts|stylesheets|swfs|system)/ {
  36. try_files $uri @rails;
  37.  
  38. access_log off;
  39. gzip_static on; # to serve pre-gzipped version
  40.  
  41. expires max;
  42. add_header Cache-Control public;
  43.  
  44. # Some browsers still send conditional-GET requests if there's a
  45. # Last-Modified header or an ETag header even if they haven't
  46. # reached the expiry date sent in the Expires header.
  47. add_header Last-Modified "";
  48. add_header ETag "";
  49. break;
  50. }
  51.  
  52. # send non-static file requests to the app server
  53. location / {
  54. try_files $uri @rails;
  55. }
  56.  
  57. location @rails {
  58. proxy_set_header X-Real-IP $remote_addr;
  59. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  60. proxy_set_header Host $http_host;
  61. proxy_redirect off;
  62. proxy_pass http://rails_app;
  63. }
  64. }
  65.  
  66. # Base image:
  67. FROM nginx
  68. # Install dependencies
  69. RUN apt-get update -qq && apt-get -y install apache2-utils
  70.  
  71. # establish where Nginx should look for files
  72. ENV INSTALL_PATH /providre_api
  73.  
  74. # Set our working directory inside the image
  75. WORKDIR $INSTALL_PATH
  76.  
  77. # create log directory
  78. RUN mkdir log
  79.  
  80. # copy over static assets
  81. COPY public public/
  82.  
  83. # Copy Nginx config template
  84. COPY docker/web/nginx.conf /tmp/docker.nginx
  85.  
  86. # substitute variable references in the Nginx config template for real values from the environment
  87. # put the final config in its place
  88. RUN envsubst '$INSTALL_PATH' < /tmp/docker.nginx > /etc/nginx/conf.d/default.conf
  89.  
  90. EXPOSE 80
  91.  
  92. # Use the "exec" form of CMD so Nginx shuts down gracefully on SIGTERM (i.e. `docker stop`)
  93. CMD [ "nginx", "-g", "daemon off;" ]
  94.  
  95. version: '3'
  96. services:
  97. db:
  98. image: postgres
  99. volumes:
  100. - ./tmp/db:/var/lib/postgresql/data
  101. restart: always
  102. ports:
  103. - "5433:5432"
  104. environment:
  105. POSTGRES_USER: 'postgres'
  106. POSTGRES_PASSWORD: ''
  107. app:
  108. command: bundle exec puma -C config/puma.rb
  109. ports:
  110. - "3000"
  111. depends_on:
  112. - db
  113.  
  114. version: '3'
  115. services:
  116. app:
  117. build:
  118. context: .
  119. dockerfile: ./docker/app/Dockerfile
  120. volumes:
  121. - .:/providre_api
  122. ports:
  123. - "3000:3000"
  124.  
  125. version: '3'
  126. services:
  127. app:
  128. build:
  129. context: .
  130. dockerfile: ./docker/app/prod.Dockerfile
  131. volumes:
  132. - .:/providre_api
  133. ports:
  134. - "3000"
  135. nginx:
  136. container_name: web
  137. build:
  138. context: .
  139. dockerfile: ./docker/web/web.Dockerfile
  140. depends_on:
  141. - app
  142. volumes:
  143. - ./docker/web/nginx.conf:/etc/nginx/conf.d/default.conf
  144. ports:
  145. - 80:80
Add Comment
Please, Sign In to add comment