Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Try not to mount app directory only /public/system #4858

Closed
wants to merge 12 commits into from
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,4 @@ WORKDIR /app

RUN yarn install && yarn upgrade
RUN passenger-config compile-nginx-engine --connect-timeout 60 --idle-timeout 60
RUN rake assets:precompile && rake tmp:cache:clear
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the main insight to put assets inside the Docker container. This way we can push to production without running bundler / yarn in production.

10 changes: 4 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ build:

redeploy-container:
docker-compose build --pull
docker-compose run --rm web yarn install
docker-compose run --rm web bash -c "rake db:migrate && rake assets:precompile && rake tmp:cache:clear"
docker-compose run --rm web bash -c "rake db:migrate"
docker-compose run --rm web bash -c "rake db:migrate"
docker-compose down --remove-orphans
rm -f ./tmp/pids/server.pid
docker-compose up -d
Expand All @@ -18,8 +18,8 @@ redeploy-container:
docker-compose exec -T web service cron start

deploy-container:
docker-compose run --rm web yarn install
docker-compose run --rm web bash -c "sleep 5 && rake db:migrate && rake assets:precompile"
docker-compose run --rm web bash -c "sleep 5 && rake db:migrate"
docker-compose run --rm web bash -c "sleep 5 && rake db:migrate"
rm -f ./tmp/pids/server.pid
docker-compose up -d
docker-compose exec -T web bash -c "echo 172.19.0.1 smtp >> /etc/hosts"
Expand All @@ -32,8 +32,6 @@ test-container:
docker-compose up -d
docker-compose exec -T web rake db:setup
docker-compose exec -T web rake db:migrate
docker-compose exec -T web yarn install
docker-compose exec -T web rake assets:precompile
docker-compose exec -T web rake test:all
docker-compose exec -T web rails test -d
docker-compose down
Expand Down
1 change: 1 addition & 0 deletions config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ class Application < Rails::Application

# Enable the asset pipeline
config.assets.enabled = true
config.assets.initialize_on_precompile = false

I18n.available_locales = [:en, :de, "zh-CN"]
config.i18n.default_locale = :en
Expand Down
8 changes: 5 additions & 3 deletions containers/docker-compose-production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ services:
- WEBSITE_HOST_PATTERN=${WEBSITE_HOST_PATTERN}
- TWEET_SEARCH=${TWEET_SEARCH}
volumes:
- ..:/app
- ../public/system:/app/public/system
- ../log:/app/log
- ../test/reports:/app/test/reports
- /etc/passwd:/etc/passwd:ro
- /etc/group:/etc/group:ro
links:
Expand All @@ -64,7 +66,7 @@ services:
- db
- redis
volumes:
- ..:/app
- ../public/system:/app/public/system
environment:
- RAILS_ENV=${RAILS_ENV}
- REDIS_URL=redis://redis:6379/0
Expand All @@ -80,5 +82,5 @@ services:
- USERNAME=${USERNAME}
- EMAIL_PASSWORD=${EMAIL_PASSWORD}
volumes:
- ..:/app
- ../public/system:/app/public/system
restart: always
10 changes: 7 additions & 3 deletions containers/docker-compose-stable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ services:
- WEBSITE_HOST_PATTERN=${WEBSITE_HOST_PATTERN}
- TWEET_SEARCH=${TWEET_SEARCH}
volumes:
- ..:/app
- ../public/system:/app/public/system
- ../log:/app/log
- ../test/reports:/app/test/reports
- /etc/passwd:/etc/passwd:ro
- /etc/group:/etc/group:ro
links:
Expand All @@ -64,7 +66,8 @@ services:
- db
- redis
volumes:
- ..:/app
- ../public/system:/app/public/system
- ../log:/app/log
environment:
- RAILS_ENV=${RAILS_ENV}
- REDIS_URL=redis://redis:6379/0
Expand All @@ -79,4 +82,5 @@ services:
- USERNAME=${USERNAME}
- EMAIL_PASSWORD=${EMAIL_PASSWORD}
volumes:
- ..:/app
- ../public/system:/app/public/system
- ../log:/app/log
12 changes: 7 additions & 5 deletions containers/docker-compose-testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,10 @@ services:
links:
- redis
volumes:
- ..:/app
- js_libs:/app/public/lib
- ../public/system:/app/public/system
- ../.git:/app/.git
- ../log:/app/log
- ../test/reports:/app/test/reports
restart: unless-stopped
sidekiq:
build: ..
Expand All @@ -44,8 +46,8 @@ services:
- db
- redis
volumes:
- .:/app
- ../public/system:/app/public/system
- ../log:/app/log
- ../test/reports:/app/test/reports
environment:
- REDIS_URL=redis://redis:6379/0
volumes:
js_libs:
10 changes: 7 additions & 3 deletions containers/docker-compose-unstable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ services:
- WEBSITE_HOST_PATTERN=${WEBSITE_HOST_PATTERN}
- TWEET_SEARCH=${TWEET_SEARCH}
volumes:
- ..:/app
- ../public/system:/app/public/system
- ../log:/app/log
- ../test/reports:/app/test/reports
- /etc/passwd:/etc/passwd:ro
- /etc/group:/etc/group:ro
links:
Expand All @@ -64,7 +66,8 @@ services:
- db
- redis
volumes:
- ..:/app
- ../public/system:/app/public/system
- ../log:/app/log
environment:
- RAILS_ENV=${RAILS_ENV}
- REDIS_URL=redis://redis:6379/0
Expand All @@ -79,4 +82,5 @@ services:
- USERNAME=${USERNAME}
- EMAIL_PASSWORD=${EMAIL_PASSWORD}
volumes:
- ..:/app
- ../public/system:/app/public/system
- ../log:/app/log