Skip to content

Instantly share code, notes, and snippets.

# Rename local branch
git branch -m old new
# Remove old branch
git push origin :old
# Create and push the new branch and set the local branch to track the new remote branch
git push --set-upstream origin new
default: &default
adapter: postgresql
encoding: unicode
host: db
port: 5432
username: postgres
password: <%= ENV['POSTGRES_PASSWORD'] %>
development:
<<: *default
# Where our application lives. $RAILS_ROOT is defined in our Dockerfile.
app_path = ENV['RAILS_ROOT']
# Set the server's working directory
working_directory app_path
# Define where Unicorn should write its PID file
pid "#{app_path}/tmp/pids/unicorn.pid"
# Bind Unicorn to the container's default route, at port 3000
# This is a template. Referenced variables (e.g. $RAILS_ROOT) need
# to be rewritten with real values in order for this file to work.
# To learn about all the directives used here, and more, see
# http://nginx.org/en/docs/dirindex.html
# define our application server
upstream unicorn {
server app:3000;
}
# build from the official Nginx image
FROM nginx
# install essential Linux packages
RUN apt-get update -qq && apt-get -y install apache2-utils
# establish where Nginx should look for files
ENV RAILS_ROOT /var/www/myapp
# Set our working directory inside the image
# service configuration for production database (Postgres)
db:
# use stock postgres image
image: postgres:9.4.5
# persist the database between containers by storing it in a volume
volumes:
- myapp-postgres:/var/lib/postgresql/data
#!/usr/bin/env bash
# Prefix `bundle` with `exec` so unicorn shuts down gracefully on SIGTERM (i.e. `docker stop`)
exec bundle exec unicorn -c config/containers/unicorn.rb -E $RAILS_ENV;
.git
.env
.dockerignore
# use SSHKit directly instead of Capistrano
require 'sshkit'
require 'sshkit/dsl'
include SSHKit::DSL
# set the identifier used to used to tag our Docker images
deploy_tag = ENV['DEPLOY_TAG']
# set the name of the environment we are deploying to (e.g. staging, production, etc.)
deploy_env = ENV['DEPLOY_ENV'] || :production
app:
# map our application source code, in full, to the application root of our container
volumes:
- .:/var/www/myapp
web:
# use whatever volumes are configured for the app container
volumes_from:
- app