Skip to content

Instantly share code, notes, and snippets.

@chrisedington
chrisedington / dockerup
Created January 20, 2016 05:48
Initialize Docker terminal with Fish shell
Fish shell didn't play well with Docker Quickstart Terminal at first, this seems to solve the problem.
Create a shell script named dockerup (chmod +x dockerup) and place it in /usr/bin/
To initialize the Docker terminal, you can "dockerup".
✘ 07:46 ~ cat /usr/bin/dockerup
#! /usr/local/bin/fish
sh '/Applications/Docker/Docker Quickstart Terminal.app/Contents/Resources/Scripts/start.sh'
@chrisedington
chrisedington / circleci-api
Created January 20, 2016 05:54
Some useful undocumented CircleCI API stuff
# Adding a GitHub repo to CircleCI
curl -s "https://circleci.com/api/v1/project/{{ORGANISATION}}/{{REPO_NAME}}/follow?circle-token={{TOKEN}}" -H "Accept: application/json" -H "Content-type: application/json" -X POST
# Adding private key to CircleCI to enable deployment
curl -s -H "Content-Type: application/json" --data "{"hostname":"{{HOSTNAME}}","private_key":"{{PRIVATE KEY}}"}" "https://circleci.com/api/v1/project/{{ORGANISATION}}/{{REPO_NAME}}/ssh-key?circle-token={{TOKEN}}"
# Use an official, light-weight Ruby image
FROM ruby:2.2.3-slim
# Install essential Linux packages (use one RUN command to reduce layer complexity)
# IF YOU NEED ImageMagick, ADD THESE TO THE END OF THE LINE BELOW: libmagickwand-dev imagemagick
# IF YOU NEED MySQL, ADD THESE TO THE LINE BELOW: mysql-server mysql-client libmysqlclient-dev
RUN apt-get update -qq && apt-get install -y build-essential libpq-dev postgresql-client
# IF YOU NEED PostgreSQL, uncomment the line below:
# service configuration for our dockerized Rails app
app:
# use the Dockerfile next to this file
build: .
# sources environment variable configuration for our app
env_file: .env
# rely on the RAILS_ENV value of the host machine
environment:
RAILS_ENV: $RAILS_ENV
# makes the app container aware of the DB container
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
# 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
.git
.env
.dockerignore
#!/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;
# 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
# 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