Skip to content

Instantly share code, notes, and snippets.

View hungmi's full-sized avatar
🏠
Working from home

Hungmi hungmi

🏠
Working from home
View GitHub Profile
@hungmi
hungmi / deploy.rb
Last active August 8, 2018 15:02
config/deploy.rb
# config/deploy.rb
lock '3.11.0' # Edit this to match your capistrano version
set :application, 'AppName'
set :repo_url, '[email protected]:GitHubUserName/AppName.git' # Edit this to match your repository
set :branch, :master
set :deploy_to, '/home/deploy/apps/AppName'
set :linked_files, %w{config/database.yml config/application.yml config/secrets.yml}
set :linked_dirs, %w{log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system public/uploads}
set :bundle_binstubs, nil
@hungmi
hungmi / nginx.conf
Last active April 2, 2018 16:20
config/nginx.conf
# config/nginx.conf
upstream puma {
server unix:///home/deploy/apps/AppName/shared/tmp/sockets/puma.sock;
}
server {
listen 80 default_server deferred;
server_name DomainName;
# if you only use a static ip address
# listen 80;
# server_name <STATIC IP ADDRESS>;
@hungmi
hungmi / database.yml
Last active June 30, 2017 02:21
config/database.yml
# config/database.yml
default: &default
adapter: postgresql
encoding: unicode
pool: <%= ENV.fetch('RAILS_MAX_THREADS') { 5 } %>
development:
<<: *default
database: AppName_development
test:
<<: *default
@hungmi
hungmi / application.yml
Created June 16, 2017 15:50
config/application.yml
# config/application.yml
development:
secret_key_base: something_secret
test:
secret_key_base: something_else_secret
production:
SECRET_KEY_BASE: something_else_secret_generate_from_rails_secret
PG_DBNAME: ProductionDBName
PG_USERNAME: deploy
PG_PASSWORD: YourPostgresPassword
@hungmi
hungmi / Gemfile
Last active August 8, 2018 05:54
Gemfile
...
group :development do
gem 'capistrano', require: false
gem 'capistrano-rbenv', require: false
gem 'capistrano-rails', require: false
gem 'capistrano-bundler', require: false
gem 'capistrano3-puma', require: false
gem 'capistrano-sidekiq', require: false
end
gem ‘puma’
@hungmi
hungmi / Capfile
Last active August 8, 2018 15:01
Capfile
# Capfile
# Load DSL and Setup Up Stages
require 'capistrano/setup'
require 'capistrano/deploy'
require "capistrano/scm/git"
install_plugin Capistrano::SCM::Git
require 'capistrano/rails'
require 'capistrano/bundler'
require 'capistrano/rbenv'
@hungmi
hungmi / options-ssl-nginx.conf
Last active August 29, 2018 01:21
/etc/letsencrypt/options-ssl-nginx.conf
# /etc/letsencrypt/options-ssl-nginx.conf
ssl_session_timeout 5m;
ssl_session_cache shared:SSL:50m;
ssl_session_timeout 1440m;
ssl_session_cache shared:ssl_session_cache:10m;
ssl_session_tickets off;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
ssl_ciphers 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';
@hungmi
hungmi / DomainName
Last active October 12, 2018 08:19
/etc/nginx/sites-available/DomainName
# config/nginx.conf
upstream puma {
server unix:///home/deploy/apps/AppName/shared/tmp/sockets/puma.sock;
}
server {
server_name example.com www.example.com.tw;
root /home/deploy/apps/AppName/current/public;
access_log /home/deploy/apps/AppName/current/log/nginx.access.log;
error_log /home/deploy/apps/AppName/current/log/nginx.error.log info;
@hungmi
hungmi / edit.html.erb
Last active February 6, 2018 16:10
say you have a model named Article, and you wanna use Quilljs to edit it's content.
<!-- Include Quill stylesheet -->
<link href="https://cdn.quilljs.com/1.3.5/quill.snow.css" rel="stylesheet">
<div id="form-container">
<%= form_for @portfolio do |f| %>
<div class="form-group">
<%= f.label :title %>
<%= f.text_field :title, class: "form-control" %>
</div>
<div class="form-group">
@hungmi
hungmi / puma.service of RVM
Last active March 13, 2020 14:14
Use systemd to restart puma after reboot. Put this file at /etc/systemd/system/puma.service. Please check those paths in ExecStart and ExecStop carefully.
[Unit]
Description=Puma HTTP Server
After=network.target
[Service]
Type=simple
User=deploy
WorkingDirectory=/home/deploy/apps/shiftweb/current
Environment=RAILS_ENV=production
ExecStart=/home/deploy/.rvm/bin/rvm ruby-2.6.5 do bundle exec puma -C /home/deploy/apps/shiftweb/shared/puma.rb