docker build -t 'my_image_name:latest' . && tutum image push my_image_name:latest
Last active
September 14, 2016 17:58
-
-
Save kitwalker12/2e5ae0e2b715b00a30a8 to your computer and use it in GitHub Desktop.
Dockerized Rails on Tutum (Passenger + HAProxy)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
AWS_ACCESS_KEY_ID=ABCXYZ | |
AWS_SECRET_ACCESS_KEY=ABCXYZ | |
RACK_ENV=production | |
RAILS_ENV=production | |
DATABASE_URL=postgres://myuser:mypass@localhost:5432/web |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM phusion/passenger-ruby20:0.9.17 | |
# Set correct environment variables. | |
ENV HOME /root | |
# Expose Nginx HTTP service | |
EXPOSE 80 | |
EXPOSE 443 | |
# Start Nginx / Passenger | |
RUN rm -f /etc/service/nginx/down | |
# Remove the default site | |
RUN rm /etc/nginx/sites-enabled/default | |
# Add the nginx site and config | |
ADD nginx.conf /etc/nginx/sites-enabled/web.conf | |
ADD rails-env.conf /etc/nginx/main.d/rails-env.conf | |
# Install bundle of gems | |
WORKDIR /tmp | |
COPY Gemfile Gemfile | |
COPY Gemfile.lock Gemfile.lock | |
RUN bundle install | |
# Add the Rails app | |
ADD . /home/app/web | |
RUN chown -R app:app /home/app/web | |
WORKDIR /home/app/web | |
RUN set -a && . /home/app/web/.env && bundle exec rake assets:precompile --trace |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
server { | |
listen 80; | |
server_name localhost; | |
root /home/app/web/public; | |
passenger_enabled on; | |
passenger_user app; | |
passenger_app_env <my environment, Ex: staging, production>; | |
passenger_ruby /usr/bin/ruby2.0; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#All Environment Variables you need preserved because passenger deletes them all by default | |
env AWS_ACCESS_KEY_ID; | |
env AWS_SECRET_ACCESS_KEY; | |
env RAILS_ENV; | |
env RACK_ENV; | |
env DATABASE_URL; | |
env REDIS_URL; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
redis: | |
image: 'tutum/redis:latest' | |
environment: | |
- REDIS_PASS=mypass | |
ports: | |
- '6379:6379' | |
restart: always | |
roles: | |
- global | |
db: | |
image: 'postgres:9.4' | |
environment: | |
- POSTGRES_PASSWORD=mypass | |
- POSTGRES_USER=myuser | |
ports: | |
- '5432:5432' | |
restart: always | |
roles: | |
- global | |
lb: | |
image: 'tutum/haproxy:latest' | |
environment: | |
- 'DEFAULT_SSL_CERT=<paste cert here. Method here: https://github.com/tutumcloud/haproxy#user-content-ssl-termination>' | |
links: | |
- web | |
ports: | |
- '80:80' | |
- '443:443' | |
restart: always | |
roles: | |
- global | |
web: | |
image: 'my_image_name' | |
command: '/sbin/my_init' | |
environment: | |
#All my env vars | |
- AWS_ACCESS_KEY_ID=ABCXYZ | |
- AWS_SECRET_ACCESS_KEY=ABCXYZ | |
- 'DATABASE_URL=postgres://myuser:mypass@db:5432/web' | |
- RACK_ENV=<my environment> | |
- RAILS_ENV=<my environment> | |
- 'REDIS_URL=redis://:mypass@redis:6379/0' | |
- 'VIRTUAL_HOST=http://mydomain.com,https://mydomain.com' | |
expose: | |
- '80' | |
- '443' | |
links: | |
- db | |
- redis | |
restart: on-failure | |
roles: | |
- global | |
target_num_containers: 2 | |
sidekiq: | |
image: 'my_image_name' | |
command: 'bundle exec sidekiq' | |
environment: | |
#All my env vars | |
- AWS_ACCESS_KEY_ID=ABCXYZ | |
- AWS_SECRET_ACCESS_KEY=ABCXYZ | |
- 'DATABASE_URL=postgres://myuser:mypass@db:5432/web' | |
- RACK_ENV=<my environment> | |
- RAILS_ENV=<my environment> | |
- 'REDIS_URL=redis://:mypass@redis:6379/0' | |
links: | |
- db | |
- redis | |
restart: on-failure | |
roles: | |
- global |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment