Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- docker-compose -f docker-compose.yml -f production.yml up --build
- docker-compose -f docker-compose.yml -f production.yml build
- # This is a template. Referenced variables (e.g. $INSTALL_PATH) need
- # to be rewritten with real values in order for this file to work.
- upstream rails_app {
- server unix:///webapp/tmp/sockets/puma.sock;
- }
- server {
- listen 80;
- # define your domain
- server_name 127.0.0.1 localhost www.example.com;
- # define the public application root
- root /providre_api/public;
- # define where Nginx should write its logs
- access_log /providre_api/log/nginx.access.log;
- error_log /providre_api/log/nginx.error.log;
- # deny requests for files that should never be accessed
- location ~ /. {
- deny all;
- }
- location ~* ^.+.(rb|log)$ {
- deny all;
- }
- # serve static (compiled) assets directly if they exist (for rails production)
- location ~ ^/(assets|images|javascripts|stylesheets|swfs|system)/ {
- try_files $uri @rails;
- access_log off;
- gzip_static on; # to serve pre-gzipped version
- expires max;
- add_header Cache-Control public;
- # Some browsers still send conditional-GET requests if there's a
- # Last-Modified header or an ETag header even if they haven't
- # reached the expiry date sent in the Expires header.
- add_header Last-Modified "";
- add_header ETag "";
- break;
- }
- # send non-static file requests to the app server
- location / {
- try_files $uri @rails;
- }
- location @rails {
- proxy_set_header X-Real-IP $remote_addr;
- proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
- proxy_set_header Host $http_host;
- proxy_redirect off;
- proxy_pass http://rails_app;
- }
- }
- # Base image:
- FROM nginx
- # Install dependencies
- RUN apt-get update -qq && apt-get -y install apache2-utils
- # establish where Nginx should look for files
- ENV INSTALL_PATH /providre_api
- # Set our working directory inside the image
- WORKDIR $INSTALL_PATH
- # create log directory
- RUN mkdir log
- # copy over static assets
- COPY public public/
- # Copy Nginx config template
- COPY docker/web/nginx.conf /tmp/docker.nginx
- # substitute variable references in the Nginx config template for real values from the environment
- # put the final config in its place
- RUN envsubst '$INSTALL_PATH' < /tmp/docker.nginx > /etc/nginx/conf.d/default.conf
- EXPOSE 80
- # Use the "exec" form of CMD so Nginx shuts down gracefully on SIGTERM (i.e. `docker stop`)
- CMD [ "nginx", "-g", "daemon off;" ]
- version: '3'
- services:
- db:
- image: postgres
- volumes:
- - ./tmp/db:/var/lib/postgresql/data
- restart: always
- ports:
- - "5433:5432"
- environment:
- POSTGRES_USER: 'postgres'
- POSTGRES_PASSWORD: ''
- app:
- command: bundle exec puma -C config/puma.rb
- ports:
- - "3000"
- depends_on:
- - db
- version: '3'
- services:
- app:
- build:
- context: .
- dockerfile: ./docker/app/Dockerfile
- volumes:
- - .:/providre_api
- ports:
- - "3000:3000"
- version: '3'
- services:
- app:
- build:
- context: .
- dockerfile: ./docker/app/prod.Dockerfile
- volumes:
- - .:/providre_api
- ports:
- - "3000"
- nginx:
- container_name: web
- build:
- context: .
- dockerfile: ./docker/web/web.Dockerfile
- depends_on:
- - app
- volumes:
- - ./docker/web/nginx.conf:/etc/nginx/conf.d/default.conf
- ports:
- - 80:80
Add Comment
Please, Sign In to add comment