Skip to content

Instantly share code, notes, and snippets.

View Epigene's full-sized avatar

Augusts Bautra Epigene

View GitHub Profile
@Epigene
Epigene / PHP Dokku workflow
Last active August 29, 2015 14:13
A workflow for configuring and deploying PHP apps via dokku
# Make PHP app Dokku-friendly
# Add staging and production clauses to database.yml
# Tell docker how to start app, Add to Procfile (web server dependant)
# Simple puma setup
Make Procfile, add line:
web: bundle exec puma -t ${PUMA_MIN_THREADS:-1}:${PUMA_MAX_THREADS:-1} -w ${PUMA_WORKERS:-2} -p $PORT -e ${RACK_ENV:-production}
# Simple unicorn setup:
Make Procfile, add line:
web: bundle exec unicorn -p $PORT -c ./config/unicorn.rb
Make config/unicorn.rb, populate with default pre and post-fork blocks
@Epigene
Epigene / Dokku rails staging env
Last active August 29, 2015 14:14
Dokku rails app staging environment setup
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# Code is not reloaded between requests.
config.cache_classes = true
config.eager_load = false
# Full error reports are disabled and caching is turned on.
config.consider_all_requests_local = true
@Epigene
Epigene / Static dokku
Last active August 29, 2015 14:14
Static pages with dokku
# Static html serving via dokku:
1. make .env in root, include the line “export BUILDPACK_URL=https://github.com/florianheinemann/buildpack-nginx.git”;
2. make .static (an empty file for buildpack to pick up it will be a static app)
3. make www directory
4. place index.html along with .css into www folder to be served. (Assets come in www/assets/)
5. init git remote
$ git remote add dokku [email protected]:<domain.com>
6. $ git push dokku master
7. visit working site.
@Epigene
Epigene / Integer Summer
Created March 3, 2015 14:41
Simple ruby script that sums integers
s = ""
until s == "q" do
puts "Enter integers"
s = gets.chomp
r = s.split("").inject(0){|c,x| c + x.to_i }
puts "The sum is #{r}"
end
@Epigene
Epigene / RSpec Workflow
Created March 4, 2015 10:18
RSpec Workflow
========== RSpec Workflow ==========
1 # Add gem stack
group :development, :test do
# Test stack
gem "rspec-rails", '~> 3.2.0'
gem "spring-commands-rspec" #Spring for rspec ^
gem "factory_girl_rails"
gem "guard-rspec"
gem 'rb-fsevent', '~> 0.9.1'
gem "faker" #šis ģenerē dummy/fake datus pēc pieprasījuma
@Epigene
Epigene / IP Nginx for Puma
Created March 19, 2015 09:14
Simple IP-based nginx config for Puma
upstream puma {
server unix:/tmp/puma.socket fail_timeout=1;
}
server {
listen 80;
server_name <IP>;
return 307 http://www.google.lv$request_uri;
}
@Epigene
Epigene / docker ps -a
Created March 23, 2015 15:10
docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
c2ca257ba902 dokku/node:latest "/start web" 27 minutes ago Up 27 minutes reverent_franklin
7f0d4f5753d3 de9c63fa4504 "/bin/bash -c 'mkdir 27 minutes ago Exited (0) 27 minutes ago drunk_yalow
41bff5625e88 6e724a2af1a6 "/bin/bash -c 'mkdir 27 minutes ago Exited (0) 27 minutes ago sleepy_rosalind
1e4bb3a5a462 6e724a2af1a6 "/start web" 32 minutes ago Exited (137) 26 minutes ago reverent_sammet
d75f4e581ea4 126ee263be14 "/bin/bash -c 'mkdir 32 minutes ago Exited (0) 32 minutes ago loving_mayer
a7c30c082f6b
@Epigene
Epigene / app deploy
Created March 23, 2015 15:12
app deploy
Directer git:(master) git push dokku master
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = (unset),
LC_CTYPE = "UTF-8",
LANG = "en_US.UTF-8"
are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
Counting objects: 774, done.
@Epigene
Epigene / node deploy
Created March 23, 2015 15:13
node deploy
node-js-sample git:(master) git push dokku master
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = (unset),
LC_CTYPE = "UTF-8",
LANG = "en_US.UTF-8"
are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
Counting objects: 381, done.
@Epigene
Epigene / MB puma + Nginx settings
Last active December 28, 2020 19:35
MB puma + Nginx settings
# /config/puma.rb
app = "manabalss" # App-specific
root = "/home/deployer/apps/#{app}"
workers 5
threads 1, 1 # relying on many workers for thread-unsafe apps
rackup DefaultRackup
port 11592