Skip to content

Instantly share code, notes, and snippets.

@epintos
epintos / README.md
Last active August 29, 2015 14:22
Pre push github hook

Run:

  • chmod +x pre-push.sh
  • ln -s ../../pre-push.sh .git/hooks/pre-push

and the script will be executed before each git push. You can skip the hook by adding --no-verify to your git push.

@epintos
epintos / [Jenkins] Build Execute Shell
Last active March 12, 2018 13:38
Ruby on Rails Continuous Integration with Jenkins and Docker Compose
#!/bin/bash +x
set -e
# Remove unnecessary files
echo -e "\033[34mRemoving unnecessary files...\033[0m"
rm -f log/*.log &> /dev/null || true &> /dev/null
rm -rf public/uploads/* &> /dev/null || true &> /dev/null
# Build Project
echo -e "\033[34mBuilding Project...\033[0m"
@epintos
epintos / [Jenkins] Post-build Actions Execute Shell
Created June 25, 2015 23:44
Ruby on Rails Continuous Integration with Jenkins and Docker Compose
#!/bin/bash +x
docker-compose --project-name=${JOB_NAME} stop &> /dev/null || true &> /dev/null
docker-compose --project-name=${JOB_NAME} rm --force &> /dev/null || true &> /dev/null
docker stop `docker ps -a -q -f status=exited` &> /dev/null || true &> /dev/null
docker rm -v `docker ps -a -q -f status=exited` &> /dev/null || true &> /dev/null
docker rmi `docker images --filter 'dangling=true' -q --no-trunc` &> /dev/null || true &> /dev/null
@epintos
epintos / Dockerfile
Created June 25, 2015 23:46
Ruby on Rails Continuous Integration with Jenkins and Docker Compose
FROM ruby:2.2.2
RUN apt-get update -qq && apt-get install -y build-essential libpq-dev nodejs
# Install RMagick
# RUN apt-get install -y libmagickwand-dev imagemagick
# Install Nokogiri
# RUN apt-get install -y zlib1g-dev
RUN mkdir /myapp
@epintos
epintos / docker-compose.yml
Last active October 29, 2016 14:33
Ruby on Rails Continuous Integration with Jenkins and Docker Compose
db:
image: postgres
ports:
- "5432"
redis:
image: redis
ports:
- "6379"
@epintos
epintos / database.yml
Last active August 29, 2015 14:23
Ruby on Rails Continuous Integration with Jenkins and Docker Compose
development: &default
adapter: postgresql
encoding: unicode
database: your-project_development
pool: 5
username: <%= ENV.fetch('DB_USERNAME', 'your-project') %>
password: <%= ENV.fetch('DB_PASSWORD', 'your-project') %>
host: <%= ENV.fetch('DB_1_PORT_5432_TCP_ADDR', 'localhost') %>
port: <%= ENV.fetch('DB_1_PORT_5432_TCP_PORT', '5432') %>
@epintos
epintos / [Jenkins] Build Execute Shell MongoId
Created June 25, 2015 23:48
Ruby on Rails Continuous Integration with Jenkins and Docker Compose
cat >config/mongoid.yml <<EOF
test:
sessions:
default:
database: ${JOB_NAME}_test
hosts:
- <%= "#{ENV['DB_1_PORT_27017_TCP_ADDR']}:#{ENV['DB_1_PORT_27017_TCP_PORT']}" %>
EOF
@epintos
epintos / Gemfile
Created July 11, 2015 18:39
Ruby on Rails deploy with Capistrano 3
group :development do
gem 'capistrano', '3.2.1'
gem 'capistrano-maintenance', github: 'capistrano/maintenance', require: false
gem 'capistrano-rails'
gem 'capistrano-rbenv', '~> 2.0'
gem 'capistrano-rbenv-install', '~> 1.2.0'
gem 'capistrano-nginx-unicorn'
gem 'capistrano-sidekiq'
gem 'capistrano-rails-console'
gem 'capistrano-postgresql', '~> 4.2.0'
@epintos
epintos / deploy.rb
Created July 11, 2015 18:40
Ruby on Rails deploy with Capistrano 3
# Config valid only for Capistrano 3.2.1
lock '3.2.1'
set :application, 'your-project'
set :repo_url, '[email protected]:organization/your-repository.git'
ask :branch, proc { `git rev-parse --abbrev-ref HEAD`.chomp }.call
set :scm, :git
set :deploy_to, "/home/ubuntu/apps/#{fetch(:application)}"
@epintos
epintos / Capfile
Created July 11, 2015 18:41
Ruby on Rails deploy with Capistrano 3
require 'capistrano/setup'
require 'capistrano/deploy'
require 'capistrano/rbenv'
require 'capistrano/rbenv_install'
require 'capistrano/bundler'
require 'capistrano/rails/assets'
require 'capistrano/rails/migrations'
require 'capistrano/nginx_unicorn'
require 'capistrano/sidekiq'
require 'whenever/capistrano'