Fixing the docker container setup (with assets compilation &co)
parent
2c374cd97c
commit
48d66a2055
|
@ -1,5 +1,11 @@
|
||||||
# Service dependencies
|
# Service dependencies
|
||||||
REDIS_HOST=redis
|
REDIS_HOST=redis
|
||||||
|
REDIS_PORT=6379
|
||||||
|
DB_HOST=db
|
||||||
|
DB_USER=postgres
|
||||||
|
DB_NAME=postgres
|
||||||
|
DB_PASS=
|
||||||
|
DB_PORT=5432
|
||||||
|
|
||||||
# Federation
|
# Federation
|
||||||
LOCAL_DOMAIN=example.com
|
LOCAL_DOMAIN=example.com
|
||||||
|
|
|
@ -14,4 +14,4 @@ RUN bundle install --deployment --without test --without development
|
||||||
|
|
||||||
ADD . /mastodon
|
ADD . /mastodon
|
||||||
|
|
||||||
VOLUME ['/mastodon/public/system']
|
VOLUME ["/mastodon/public/system", "/mastodon/public/assets"]
|
||||||
|
|
|
@ -48,3 +48,9 @@ And finally
|
||||||
As usual, the first thing you would need to do would be to run migrations:
|
As usual, the first thing you would need to do would be to run migrations:
|
||||||
|
|
||||||
docker-compose run web rake db:migrate
|
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.
|
||||||
|
|
|
@ -17,7 +17,8 @@ test:
|
||||||
|
|
||||||
production:
|
production:
|
||||||
<<: *default
|
<<: *default
|
||||||
database: postgres
|
database: <%= ENV['DB_NAME'] || 'mastodon_production' %>
|
||||||
username: postgres
|
username: <%= ENV['DB_USER'] || 'mastodon' %>
|
||||||
password:
|
password: <%= ENV['DB_PASS'] || '' %>
|
||||||
host: db
|
host: <%= ENV['DB_HOST'] || 'localhost' %>
|
||||||
|
port: <%= ENV['DB_PORT'] || 5432 %>
|
||||||
|
|
|
@ -22,7 +22,7 @@ Rails.application.configure do
|
||||||
|
|
||||||
# Disable serving static files from the `/public` folder by default since
|
# Disable serving static files from the `/public` folder by default since
|
||||||
# Apache or NGINX already handles this.
|
# 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.
|
# Compress JavaScripts and CSS.
|
||||||
config.assets.js_compressor = :uglifier
|
config.assets.js_compressor = :uglifier
|
||||||
|
@ -42,7 +42,7 @@ Rails.application.configure do
|
||||||
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
|
# 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.
|
# 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
|
# Use the lowest log level to ensure availability of diagnostic information
|
||||||
# when problems arise.
|
# when problems arise.
|
||||||
|
|
|
@ -12,4 +12,7 @@ services:
|
||||||
depends_on:
|
depends_on:
|
||||||
- db
|
- db
|
||||||
- redis
|
- redis
|
||||||
|
volumes:
|
||||||
|
- ./public/assets:/mastodon/public/assets
|
||||||
|
- ./public/system:/mastodon/public/system
|
||||||
env_file: .env.production
|
env_file: .env.production
|
||||||
|
|
Reference in New Issue