about summary refs log tree commit diff
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2016-03-16 12:57:01 +0100
committerEugen Rochko <eugen@zeonfederated.com>2016-03-16 12:57:01 +0100
commit48d66a205567f7a3d59ce21eb024e11b5eb18b75 (patch)
tree42557386da40533f6478a21a2f057ccafac72e6e
parent2c374cd97cea67447cccee004ae7fe189db9abc5 (diff)
Fixing the docker container setup (with assets compilation &co)
-rw-r--r--.env.production.sample6
-rw-r--r--Dockerfile2
-rw-r--r--README.md6
-rw-r--r--config/database.yml9
-rw-r--r--config/environments/production.rb4
-rw-r--r--docker-compose.yml3
6 files changed, 23 insertions, 7 deletions
diff --git a/.env.production.sample b/.env.production.sample
index 346032881..070aa0c3a 100644
--- a/.env.production.sample
+++ b/.env.production.sample
@@ -1,5 +1,11 @@
 # Service dependencies
 REDIS_HOST=redis
+REDIS_PORT=6379
+DB_HOST=db
+DB_USER=postgres
+DB_NAME=postgres
+DB_PASS=
+DB_PORT=5432
 
 # Federation
 LOCAL_DOMAIN=example.com
diff --git a/Dockerfile b/Dockerfile
index 7b8fdc160..bb4c70d87 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -14,4 +14,4 @@ RUN bundle install --deployment --without test --without development
 
 ADD . /mastodon
 
-VOLUME ['/mastodon/public/system']
+VOLUME ["/mastodon/public/system", "/mastodon/public/assets"]
diff --git a/README.md b/README.md
index f02e5cddd..a1f7b2e27 100644
--- a/README.md
+++ b/README.md
@@ -48,3 +48,9 @@ And finally
 As usual, the first thing you would need to do would be to run migrations:
 
     docker-compose run web rake db:migrate
+
+And since the instance running in the container will be running in production mode, you need to pre-compile assets:
+
+    docker-compose run web rake assets:precompile
+
+The container has two volumes, for the assets and for user uploads. The default docker-compose.yml maps them to the repository's `public/assets` and `public/system` directories, you may wish to put them somewhere else. Likewise, the PostgreSQL and Redis images have data containers that you may wish to map somewhere where you know how to find them and back them up.
diff --git a/config/database.yml b/config/database.yml
index 8914ab16d..259244e6f 100644
--- a/config/database.yml
+++ b/config/database.yml
@@ -17,7 +17,8 @@ test:
 
 production:
   <<: *default
-  database: postgres
-  username: postgres
-  password:
-  host: db
+  database: <%= ENV['DB_NAME'] || 'mastodon_production' %>
+  username: <%= ENV['DB_USER'] || 'mastodon' %>
+  password: <%= ENV['DB_PASS'] || '' %>
+  host: <%= ENV['DB_HOST'] || 'localhost' %>
+  port: <%= ENV['DB_PORT'] || 5432 %>
diff --git a/config/environments/production.rb b/config/environments/production.rb
index b0236d09e..1f08fad5a 100644
--- a/config/environments/production.rb
+++ b/config/environments/production.rb
@@ -22,7 +22,7 @@ Rails.application.configure do
 
   # Disable serving static files from the `/public` folder by default since
   # Apache or NGINX already handles this.
-  config.serve_static_files = ENV['RAILS_SERVE_STATIC_FILES'].present?
+  config.serve_static_files = true
 
   # Compress JavaScripts and CSS.
   config.assets.js_compressor = :uglifier
@@ -42,7 +42,7 @@ Rails.application.configure do
   # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
 
   # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
-  # config.force_ssl = true
+  config.force_ssl = ENV['LOCAL_HTTPS'] == 'true'
 
   # Use the lowest log level to ensure availability of diagnostic information
   # when problems arise.
diff --git a/docker-compose.yml b/docker-compose.yml
index 20fb500b8..ed29808b0 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -12,4 +12,7 @@ services:
     depends_on:
       - db
       - redis
+    volumes:
+      - ./public/assets:/mastodon/public/assets
+      - ./public/system:/mastodon/public/system
     env_file: .env.production