File tree Expand file tree Collapse file tree 5 files changed +75
-2
lines changed Expand file tree Collapse file tree 5 files changed +75
-2
lines changed Original file line number Diff line number Diff line change
1
+ FROM ruby:2.3.1
2
+
3
+ RUN apt-get update -yqq \
4
+ && apt-get install -yqq --no-install-recommends \
5
+ postgresql-client \
6
+ nodejs \
7
+ && apt-get -q clean \
8
+ && rm -rf /var/lib/apt/lists
9
+
10
+ # Pre-install gems with native extensions
11
+ RUN gem install nokogiri -v "1.6.8.1"
12
+
13
+ WORKDIR /usr/src/app
14
+ COPY Gemfile* ./
15
+ RUN bundle install
16
+ COPY . .
17
+
18
+ # Pre-compile assets
19
+ ENV RAILS_ENV production
20
+ RUN rails assets:precompile
21
+
22
+ CMD script/start
Original file line number Diff line number Diff line change 1
1
version : " 2"
2
2
3
3
volumes :
4
+ assets :
5
+ external : false
6
+ configs :
7
+ external : false
4
8
db-data :
5
9
external : false
6
10
7
11
services :
12
+ webserver :
13
+ image : " nginx:1.11.8"
14
+ env_file : .env.prod
15
+ ports :
16
+ - " 80:80"
17
+ - " 443:443"
18
+ volumes :
19
+ - assets:/usr/share/nginx/html
20
+ - configs:/etc/nginx/conf.d
21
+
8
22
prod_db :
9
23
image : postgres
10
24
env_file : .env.prod
11
25
volumes :
12
26
- db-data:/var/lib/postgresql/db-data
13
27
14
28
prod_app :
15
- build : .
29
+ build :
30
+ context : .
31
+ dockerfile : Dockerfile.prod
16
32
env_file : .env.prod
17
33
ports :
18
34
- " 3000:3000"
35
+ volumes :
36
+ - assets:/usr/share/nginx/html
37
+ - configs:/etc/nginx/conf.d
19
38
depends_on :
20
39
- prod_db
40
+ - webserver
Original file line number Diff line number Diff line change
1
+ #! /bin/bash -e
2
+
3
+ docker-compose -f docker-compose.prod.yml " $@ "
Original file line number Diff line number Diff line change 1
- #! /bin/sh
1
+ #! /bin/bash -e
2
2
3
3
if [[ -a /tmp/puma.pid ]]; then
4
4
rm /tmp/puma.pid
5
5
fi
6
6
7
+ if [[ $RAILS_ENV == " production" ]]; then
8
+ rake assets:precompile
9
+ mkdir -p /usr/share/nginx/html
10
+ cp -R public/* /usr/share/nginx/html
11
+ mkdir -p /etc/nginx/conf.d/
12
+ cp site.conf /etc/nginx/conf.d/default.conf
13
+ fi
14
+
7
15
rails server -b 0.0.0.0 -P /tmp/puma.pid
Original file line number Diff line number Diff line change
1
+ server {
2
+ listen 80;
3
+
4
+ # Properly server assets
5
+ location ~ ^/(assets)/ {
6
+ root /usr/share/nginx/html;
7
+ gzip_static on;
8
+ expires max;
9
+ add_header Cache-Control public;
10
+ add_header ETag "";
11
+ }
12
+
13
+ # Proxy request to rails app
14
+ location / {
15
+ proxy_set_header Host $host;
16
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
17
+ proxy_pass_header Set-Cookie;
18
+ proxy_pass http://prod_app:3000;
19
+ }
20
+ }
You can’t perform that action at this time.
0 commit comments