Skip to content

Instantly share code, notes, and snippets.

@cerico
Last active September 11, 2024 16:04
Show Gist options
  • Select an option

  • Save cerico/1d9ba5f18612ae3a1e27a6db75ddaad9 to your computer and use it in GitHub Desktop.

Select an option

Save cerico/1d9ba5f18612ae3a1e27a6db75ddaad9 to your computer and use it in GitHub Desktop.

Revisions

  1. cerico revised this gist Oct 28, 2018. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion build-server.sh
    Original file line number Diff line number Diff line change
    @@ -62,7 +62,7 @@ wget https://dl.eff.org/certbot-auto
    chmod a+x certbot-auto

    cd /root
    wgethttps://gist.github.com/cerico/1d9ba5f18612ae3a1e27a6db75ddaad9/raw/371b224dfc78b48f804124676374fc237609f29d/create-sample-rails.sh
    wget https://gist.github.com/cerico/1d9ba5f18612ae3a1e27a6db75ddaad9/raw/81840effe34c42270e475f0084a05562cbcd30f2/create-sample-rails.sh
    curl https://gist.github.com/cerico/1d9ba5f18612ae3a1e27a6db75ddaad9/raw/efba4f61fdb615453629636cfb442c1eee6038a9/rails.conf > /etc/nginx/conf.d/hello-rails.conf

    git clone https://github.com/cerico/dotfiles.git
  2. cerico revised this gist Oct 28, 2018. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion create-sample-rails.sh
    Original file line number Diff line number Diff line change
    @@ -3,4 +3,4 @@ rails new hello-rails --database=postgresql && cd hello-rails
    bundle install
    bundle exec rake db:create
    bundle exec rake db:migrate
    wget https://gist.github.com/cerico/1d9ba5f18612ae3a1e27a6db75ddaad9/raw/efba4f61fdb615453629636cfb442c1eee6038a9/run.sh
    wget https://gist.github.com/cerico/1d9ba5f18612ae3a1e27a6db75ddaad9/raw/5559fc1488145275454078324339432c1bf467a2/run.sh
  3. cerico revised this gist Oct 28, 2018. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion build-server.sh
    Original file line number Diff line number Diff line change
    @@ -25,6 +25,7 @@ sudo apt-get install mongodb-org python3-setuptools default-jre libreadline-dev
    ###--- zsh ---###
    if [ ! -d ~/.oh-my-zsh ]; then
    sh -c "$(curl -fsSL https://raw.githubusercontent.com/cerico/dotfiles/master/zfiles/oh-my-zsh/scripted-install.sh)"
    exit
    fi

    ###--- Rails & Ruby ---###
    @@ -61,7 +62,7 @@ wget https://dl.eff.org/certbot-auto
    chmod a+x certbot-auto

    cd /root
    https://gist.github.com/cerico/1d9ba5f18612ae3a1e27a6db75ddaad9/raw/b4dc3e27c0e0f3e86880b450c2436bbdc819f1fd/create-sample-rails.sh
    wgethttps://gist.github.com/cerico/1d9ba5f18612ae3a1e27a6db75ddaad9/raw/371b224dfc78b48f804124676374fc237609f29d/create-sample-rails.sh
    curl https://gist.github.com/cerico/1d9ba5f18612ae3a1e27a6db75ddaad9/raw/efba4f61fdb615453629636cfb442c1eee6038a9/rails.conf > /etc/nginx/conf.d/hello-rails.conf

    git clone https://github.com/cerico/dotfiles.git
  4. cerico revised this gist Oct 28, 2018. 1 changed file with 9 additions and 1 deletion.
    10 changes: 9 additions & 1 deletion build-server.sh
    Original file line number Diff line number Diff line change
    @@ -64,4 +64,12 @@ cd /root
    https://gist.github.com/cerico/1d9ba5f18612ae3a1e27a6db75ddaad9/raw/b4dc3e27c0e0f3e86880b450c2436bbdc819f1fd/create-sample-rails.sh
    curl https://gist.github.com/cerico/1d9ba5f18612ae3a1e27a6db75ddaad9/raw/efba4f61fdb615453629636cfb442c1eee6038a9/rails.conf > /etc/nginx/conf.d/hello-rails.conf


    git clone https://github.com/cerico/dotfiles.git

    if [ ~/dotfiles ]; then
    touch ~/dotfiles/zfiles/rfy
    touch ~/.zshrc.local
    ln -s ~/dotfiles/.zshrc ~/.zshrc
    ln -s ~/dotfiles/.zprofile ~/.zprofile
    ln -s ~/dotfiles/zfiles ~/zfiles
    fi
  5. cerico revised this gist Oct 28, 2018. 2 changed files with 5 additions and 0 deletions.
    1 change: 1 addition & 0 deletions create-sample-rails.sh
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,6 @@
    #!/bin/bash
    rails new hello-rails --database=postgresql && cd hello-rails
    bundle install
    bundle exec rake db:create
    bundle exec rake db:migrate
    wget https://gist.github.com/cerico/1d9ba5f18612ae3a1e27a6db75ddaad9/raw/efba4f61fdb615453629636cfb442c1eee6038a9/run.sh
    4 changes: 4 additions & 0 deletions rails.conf
    Original file line number Diff line number Diff line change
    @@ -2,6 +2,10 @@ server {
    if ($host = hello-rails.io37.cc) {
    return 301 https://$host$request_uri;
    } # managed by Certbot

    listen 80;
    server_name hello-rails.io37.cc;
    return 301 https://$host$request_uri;
    }

    server {
  6. cerico revised this gist Oct 28, 2018. 1 changed file with 1 addition and 2 deletions.
    3 changes: 1 addition & 2 deletions run.sh
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,2 @@
    #!/bin/bash
    port=54000
    pm2 start 'rails s -p "$(echo $port)" -b 0.0.0.0' --name "$(basename `pwd`)"
    pm2 start 'rails s -p 54000 -b 0.0.0.0' --name "$(basename `pwd`)"
  7. cerico revised this gist Oct 28, 2018. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion build-server.sh
    Original file line number Diff line number Diff line change
    @@ -61,7 +61,7 @@ wget https://dl.eff.org/certbot-auto
    chmod a+x certbot-auto

    cd /root
    wget https://gist.github.com/cerico/1d9ba5f18612ae3a1e27a6db75ddaad9/raw/efba4f61fdb615453629636cfb442c1eee6038a9/create-sample-rails.sh
    https://gist.github.com/cerico/1d9ba5f18612ae3a1e27a6db75ddaad9/raw/b4dc3e27c0e0f3e86880b450c2436bbdc819f1fd/create-sample-rails.sh
    curl https://gist.github.com/cerico/1d9ba5f18612ae3a1e27a6db75ddaad9/raw/efba4f61fdb615453629636cfb442c1eee6038a9/rails.conf > /etc/nginx/conf.d/hello-rails.conf


  8. cerico revised this gist Oct 28, 2018. 1 changed file with 0 additions and 2 deletions.
    2 changes: 0 additions & 2 deletions build-server.sh
    Original file line number Diff line number Diff line change
    @@ -63,7 +63,5 @@ chmod a+x certbot-auto
    cd /root
    wget https://gist.github.com/cerico/1d9ba5f18612ae3a1e27a6db75ddaad9/raw/efba4f61fdb615453629636cfb442c1eee6038a9/create-sample-rails.sh
    curl https://gist.github.com/cerico/1d9ba5f18612ae3a1e27a6db75ddaad9/raw/efba4f61fdb615453629636cfb442c1eee6038a9/rails.conf > /etc/nginx/conf.d/hello-rails.conf
    wget https://gist.github.com/cerico/1d9ba5f18612ae3a1e27a6db75ddaad9/raw/efba4f61fdb615453629636cfb442c1eee6038a9/run.sh



  9. cerico revised this gist Oct 28, 2018. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions build-server.sh
    Original file line number Diff line number Diff line change
    @@ -63,6 +63,7 @@ chmod a+x certbot-auto
    cd /root
    wget https://gist.github.com/cerico/1d9ba5f18612ae3a1e27a6db75ddaad9/raw/efba4f61fdb615453629636cfb442c1eee6038a9/create-sample-rails.sh
    curl https://gist.github.com/cerico/1d9ba5f18612ae3a1e27a6db75ddaad9/raw/efba4f61fdb615453629636cfb442c1eee6038a9/rails.conf > /etc/nginx/conf.d/hello-rails.conf
    wget https://gist.github.com/cerico/1d9ba5f18612ae3a1e27a6db75ddaad9/raw/efba4f61fdb615453629636cfb442c1eee6038a9/run.sh



  10. cerico revised this gist Oct 28, 2018. 2 changed files with 7 additions and 1 deletion.
    5 changes: 5 additions & 0 deletions build-server.sh
    Original file line number Diff line number Diff line change
    @@ -60,4 +60,9 @@ cd /opt
    wget https://dl.eff.org/certbot-auto
    chmod a+x certbot-auto

    cd /root
    wget https://gist.github.com/cerico/1d9ba5f18612ae3a1e27a6db75ddaad9/raw/efba4f61fdb615453629636cfb442c1eee6038a9/create-sample-rails.sh
    curl https://gist.github.com/cerico/1d9ba5f18612ae3a1e27a6db75ddaad9/raw/efba4f61fdb615453629636cfb442c1eee6038a9/rails.conf > /etc/nginx/conf.d/hello-rails.conf



    3 changes: 2 additions & 1 deletion create-sample-rails.sh
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,5 @@
    #!/bin/bash
    rails new hello-rails --database=postgresql && cd hello-rails
    bundle exec rake db:create
    bundle exec rake db:migrate
    bundle exec rake db:migrate
    wget https://gist.github.com/cerico/1d9ba5f18612ae3a1e27a6db75ddaad9/raw/efba4f61fdb615453629636cfb442c1eee6038a9/run.sh
  11. cerico created this gist Oct 28, 2018.
    63 changes: 63 additions & 0 deletions build-server.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,63 @@
    #!/bin/bash

    ###--- Basics ---###
    sudo apt-get update
    sudo apt-get install -y tree software-properties-common git-core openssl libssl-dev git vim curl zsh

    ###--- Node ---###
    curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -

    sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 2930ADAE8CAF5059EE73BB4B58712A2291FA4AD5
    echo "deb http://repo.mongodb.org/apt/debian jessie/mongodb-org/3.6 main" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.6.list


    ###--- Elixir ---###
    wget https://packages.erlang-solutions.com/erlang-solutions_1.0_all.deb && sudo dpkg -i erlang-solutions_1.0_all.deb

    ###--- Docker ---###
    curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add -
    sudo apt-add-repository "deb [arch=amd64] https://download.docker.com/linux/$(. /etc/os-release; echo "$ID") $(lsb_release -cs) stable"
    sudo apt-get update

    ###--- Main Installs ---###
    sudo apt-get install mongodb-org python3-setuptools default-jre libreadline-dev inotify-tools esl-erlang elixir nodejs docker-ce build-essential apt-transport-https ca-certificates gnupg2 autoconf bison build-essential libssl-dev libyaml-dev libreadline6-dev zlib1g-dev libncurses5-dev libffi-dev libgdbm3 libgdbm-dev git-core libpq-dev postgresql postgresql-client -y

    ###--- zsh ---###
    if [ ! -d ~/.oh-my-zsh ]; then
    sh -c "$(curl -fsSL https://raw.githubusercontent.com/cerico/dotfiles/master/zfiles/oh-my-zsh/scripted-install.sh)"
    fi

    ###--- Rails & Ruby ---###
    git clone https://github.com/rbenv/rbenv.git ~/.rbenv
    git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
    export PATH="$HOME/.rbenv/bin:$PATH" && rbenv install 2.4.3
    rbenv global 2.4.3
    echo "gem: --no-document" > ~/.gemrc
    ~/.rbenv/shims/gem install bundler
    ~/.rbenv/shims/gem install rails

    ###--- Postgres ---###
    sudo -u postgres createuser root -s
    sudo su postgres -c "psql -c \"CREATE ROLE root SUPERUSER LOGIN PASSWORD 'root'\" "
    sudo su postgres -c "createdb -E UTF8 -T template0 --locale=en_US.utf8 -O root root"


    ###--- Docker Compose ---###
    sudo curl -L https://github.com/docker/compose/releases/download/1.17.1/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
    sudo chmod +x /usr/local/bin/docker-compose


    ###--- Nginx ---###
    gpg --keyserver keyserver.ubuntu.com --recv-keys 561F9B9CAC40B2F7
    gpg --armor --export 561F9B9CAC40B2F7 | sudo apt-key add -
    sudo sh -c 'echo deb https://oss-binaries.phusionpassenger.com/apt/passenger jessie main > /etc/apt/sources.list.d/passenger.list'
    sudo apt-get update
    sudo apt-get install -y nginx-extras passenger

    npm install pm2 -g

    cd /opt
    wget https://dl.eff.org/certbot-auto
    chmod a+x certbot-auto


    4 changes: 4 additions & 0 deletions create-sample-rails.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,4 @@
    #!/bin/bash
    rails new hello-rails --database=postgresql && cd hello-rails
    bundle exec rake db:create
    bundle exec rake db:migrate
    19 changes: 19 additions & 0 deletions rails.conf
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,19 @@
    server {
    if ($host = hello-rails.io37.cc) {
    return 301 https://$host$request_uri;
    } # managed by Certbot
    }

    server {
    listen 443 ssl;
    server_name hello-rails.io37.cc;

    location / {
    proxy_pass http://localhost:54000;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection 'upgrade';
    proxy_set_header Host $host;
    proxy_cache_bypass $http_upgrade;
    }
    }
    3 changes: 3 additions & 0 deletions run.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,3 @@
    #!/bin/bash
    port=54000
    pm2 start 'rails s -p "$(echo $port)" -b 0.0.0.0' --name "$(basename `pwd`)"